コード例 #1
0
ファイル: CActorHierarchy.cs プロジェクト: q4a/OpenC1
        public void RenderSingle(CActor actor)
        {
            Matrix m = actor.Matrix;

            m.Translation = Vector3.Zero;
            GameVars.CurrentEffect.World = m * GameVars.CurrentEffect.World;

            actor.Model.Render(actor.Material);
        }
コード例 #2
0
ファイル: CActorHierarchy.cs プロジェクト: vaginessa/OpenC1
        public void RecalculateActorParent(CActor actor)
        {
            actor.Parent.Children.Remove(actor); //remove it from current parent

            bool found = false;

            for (int i = 0; i < _actors.Count; i++)
            {
                MoveChildren(actor, _actors[i], null, ref found);
            }
        }
コード例 #3
0
ファイル: CActorHierarchy.cs プロジェクト: vaginessa/OpenC1
        private void ScaleTransformations(Vector3 scale, CActor actor)
        {
            if (actor.IsAnimated)
            {
                return;
            }
            actor.Matrix = actor.Matrix * Matrix.CreateScale(scale);

            foreach (CActor child in actor.Children)
            {
                ScaleTransformations(scale, child);
            }
        }
コード例 #4
0
ファイル: CActorHierarchy.cs プロジェクト: vaginessa/OpenC1
        private void ResolveTransformations(Matrix world, CActor actor, List <BaseGroove> grooves)
        {
            if (grooves != null && grooves.Exists(g => g.ActorName == actor.Name))
            {
                actor.ParentMatrix = world;
                actor.IsAnimated   = true;
                return;
            }
            //Debug.WriteLine(actor.Name + ", " + actor.ModelName + ", " + actor.Flags[0] + ":" + actor.Flags[1] + "Animated: " + actor.IsAnimated);
            actor.Matrix = world * actor.Matrix;

            foreach (CActor child in actor.Children)
            {
                ResolveTransformations(actor.Matrix, child, grooves);
            }
        }
コード例 #5
0
ファイル: Vehicle.cs プロジェクト: vaginessa/OpenC1
        public Vehicle(string filename, IDriver driver)
        {
            Driver         = driver;
            Driver.Vehicle = this;

            Config = new VehicleFile(filename);

            if (driver is PlayerDriver)
            {
                if (Config.WindscreenMaterial != "none")
                {
                    Config.Funks.Add(new WindscreenFunk(Config.WindscreenMaterial, this));
                }
            }

            _model = new VehicleModel(Config, false);

            Audio = new VehicleAudio(this);

            Chassis = new VehicleChassis(this);

            CActor actor2 = _model.GetActor(Path.GetFileNameWithoutExtension(_model.ModelName));

            if (actor2 != null)
            {
                _deformableModel          = (CDeformableModel)actor2.Model;
                _deformableModel._actor   = Chassis.Actor;
                _deformableModel._carFile = Config;
            }

            _crushSection = Config.CrushSections[1];

            CMaterial crashMat = ResourceCache.GetMaterial(Config.CrashMaterialFiles[0]);

            _vehicleBitsEmitter = new ParticleEmitter(new VehicleBitsParticleSystem(crashMat), 3, Vector3.Zero);
            _vehicleBitsEmitter.DumpsPerSecond = 0.7f;

            DamageSmokeEmitter         = new ParticleEmitter(new DamageSmokeParticleSystem(Color.Gray), 5, Vector3.Zero);
            DamageSmokeEmitter.Enabled = false;

            _flames        = new PixmapBillboard(new Vector2(0.7f, 0.25f), "flames.pix");
            SkidMarkBuffer = new SkidMarkBuffer(this, 150);
        }
コード例 #6
0
ファイル: CActorHierarchy.cs プロジェクト: vaginessa/OpenC1
        private void MoveChildren(CActor actorToMove, CActor parent, CActor parentParent, ref bool found)
        {
            if (found || parent.BoundingBox.Max.X == 0)
            {
                return;
            }

            if (parent.BoundingBox.Contains(actorToMove.PhysXActor.GlobalPosition) == ContainmentType.Contains)
            {
                foreach (CActor child in parent.Children)
                {
                    MoveChildren(actorToMove, child, parent, ref found);
                }
                if (!found)
                {
                    if (!parent.Children.Contains(actorToMove))
                    {
                        parent.Children.Add(actorToMove);
                    }
                    found = true;
                }
            }
        }
コード例 #7
0
ファイル: CActorHierarchy.cs プロジェクト: sikora507/OpenC1
        private void ScaleTransformations(Vector3 scale, CActor actor)
        {
            if (actor.IsAnimated) return;
            actor.Matrix = actor.Matrix * Matrix.CreateScale(scale);

            foreach (CActor child in actor.Children)
                ScaleTransformations(scale, child);
        }
コード例 #8
0
ファイル: CActorHierarchy.cs プロジェクト: sikora507/OpenC1
        private void ResolveTransformations(Matrix world, CActor actor, List<BaseGroove> grooves)
        {
            if (grooves != null && grooves.Exists(g => g.ActorName == actor.Name))
            {
                actor.ParentMatrix = world;
                actor.IsAnimated = true;
                return;
            }
            //Debug.WriteLine(actor.Name + ", " + actor.ModelName + ", " + actor.Flags[0] + ":" + actor.Flags[1] + "Animated: " + actor.IsAnimated);
            actor.Matrix = world * actor.Matrix;

            foreach (CActor child in actor.Children)
                ResolveTransformations(actor.Matrix, child, grooves);
        }
コード例 #9
0
ファイル: CActorHierarchy.cs プロジェクト: sikora507/OpenC1
        private void RenderChildren(BoundingFrustum frustum, CActor actor, Matrix world, bool parentAnimated)
        {
            if (RenderWheelsSeparately && actor.IsWheel) return;

            bool intersects;

            if (frustum == null)
            {
                intersects = true;
            }
            else
            {
                intersects = actor.BoundingBox.Max.X == 0;
                if (!intersects)
                {
                    frustum.Intersects(ref actor.BoundingBox, out intersects);
                    GameVars.NbrSectionsChecked++;
                }
            }

            if (intersects)
            {
                Matrix m = actor.GetDynamicMatrix();

                if (actor.IsAnimated || parentAnimated)
                {
                    if (actor.IsAnimated && !parentAnimated)
                    {
                        world = m * actor.ParentMatrix * GameVars.ScaleMatrix * world;
                    }
                    else
                    {
                        world = m * world;
                    }

                    GameVars.CurrentEffect.World = world;
                    parentAnimated = true;
                }
                else
                {
                    GameVars.CurrentEffect.World = m * world;
                }

                GameVars.CurrentEffect.CommitChanges();

                if (actor.Model != null)
                {
                    actor.Model.Render(actor.Material);
                    if (actor.Model is CDeformableModel)
                    {
                        Models.SetupRender();
                    }
                }

                GameVars.NbrSectionsRendered++;

                foreach (CActor child in actor.Children)
                    RenderChildren(frustum, child, world, parentAnimated);
            }
        }
コード例 #10
0
ファイル: CActorHierarchy.cs プロジェクト: sikora507/OpenC1
        private void MoveChildren(CActor actorToMove, CActor parent, CActor parentParent, ref bool found)
        {
            if (found || parent.BoundingBox.Max.X == 0)
            {
                return;
            }

            if (parent.BoundingBox.Contains(actorToMove.PhysXActor.GlobalPosition) == ContainmentType.Contains)
            {
                foreach (CActor child in parent.Children)
                    MoveChildren(actorToMove, child, parent, ref found);
                if (!found)
                {
                    if (!parent.Children.Contains(actorToMove))
                    {
                        parent.Children.Add(actorToMove);
                    }
                    found = true;
                }
            }
        }
コード例 #11
0
ファイル: CActorHierarchy.cs プロジェクト: sikora507/OpenC1
        public void RenderSingle(CActor actor)
        {
            Matrix m = actor.Matrix;
            m.Translation = Vector3.Zero;
            GameVars.CurrentEffect.World = m * GameVars.CurrentEffect.World;
            GameVars.CurrentEffect.CommitChanges();

            actor.Model.Render(actor.Material);
        }
コード例 #12
0
ファイル: VehicleModel.cs プロジェクト: vaginessa/OpenC1
 public void RenderSinglePart(CActor actor)
 {
     _actors.RenderSingle(actor);
 }
コード例 #13
0
ファイル: CWheelActor.cs プロジェクト: sikora507/OpenC1
 public CWheelActor(CActor actor, bool driven, bool steerable)
 {
     Actor = actor;
     IsDriven = driven;
     IsSteerable = steerable;
 }
コード例 #14
0
ファイル: CActorHierarchy.cs プロジェクト: vaginessa/OpenC1
 public void Add(CActor actor)
 {
     _actors.Add(actor);
 }
コード例 #15
0
ファイル: CActorHierarchy.cs プロジェクト: vaginessa/OpenC1
        private void RenderChildren(BoundingFrustum frustum, CActor actor, Matrix world, bool parentAnimated)
        {
            if (RenderWheelsSeparately && actor.IsWheel)
            {
                return;
            }

            bool intersects;

            if (frustum == null)
            {
                intersects = true;
            }
            else
            {
                intersects = actor.BoundingBox.Max.X == 0;
                if (!intersects)
                {
                    frustum.Intersects(ref actor.BoundingBox, out intersects);
                    GameVars.NbrSectionsChecked++;
                }
            }

            if (intersects)
            {
                Matrix m = actor.GetDynamicMatrix();

                if (actor.IsAnimated || parentAnimated)
                {
                    if (actor.IsAnimated && !parentAnimated)
                    {
                        world = m * actor.ParentMatrix * GameVars.ScaleMatrix * world;
                    }
                    else
                    {
                        world = m * world;
                    }

                    GameVars.CurrentEffect.World = world;
                    parentAnimated = true;
                }
                else
                {
                    GameVars.CurrentEffect.World = m * world;
                }

                GameVars.CurrentEffect.CommitChanges();

                if (actor.Model != null)
                {
                    actor.Model.Render(actor.Material);
                    if (actor.Model is CDeformableModel)
                    {
                        Models.SetupRender();
                    }
                }

                GameVars.NbrSectionsRendered++;

                foreach (CActor child in actor.Children)
                {
                    RenderChildren(frustum, child, world, parentAnimated);
                }
            }
        }
コード例 #16
0
ファイル: CActorHierarchy.cs プロジェクト: sikora507/OpenC1
 public void Add(CActor actor)
 {
     _actors.Add(actor);
 }
コード例 #17
0
ファイル: CActorHierarchy.cs プロジェクト: sikora507/OpenC1
        public void RecalculateActorParent(CActor actor)
        {
            actor.Parent.Children.Remove(actor); //remove it from current parent

            bool found = false;
            for (int i = 0; i < _actors.Count; i++)
            {
                MoveChildren(actor, _actors[i], null, ref found);
            }
        }
コード例 #18
0
ファイル: VehicleModel.cs プロジェクト: sikora507/OpenC1
 public void RenderSinglePart(CActor actor)
 {
     _actors.RenderSingle(actor);
 }
コード例 #19
0
ファイル: VehicleModel.cs プロジェクト: vaginessa/OpenC1
        public VehicleModel(VehicleFile file, bool forDisplayOnly)
        {
            Config = file;

            if (file.DrivenWheelRefs.Count == 0 || file.NonDrivenWheelRefs.Count == 0)
            {
                throw new Exception("No wheel refs specified");
            }

            foreach (string pixFileName in file.PixFiles)
            {
                PixFile pixFile = new PixFile(pixFileName);
                ResourceCache.Add(pixFile);
            }

            foreach (string matFileName in file.MaterialFiles)
            {
                MatFile matFile = new MatFile(matFileName);
                ResourceCache.Add(matFile);
            }

            foreach (string matFileName in file.CrashMaterialFiles)
            {
                MatFile matFile = new MatFile(matFileName);
                ResourceCache.Add(matFile);
            }

            ResourceCache.ResolveMaterials();

            _grooves = new List <BaseGroove>();
            foreach (BaseGroove g in file.Grooves)
            {
                if (!g.IsWheelActor)
                {
                    _grooves.Add(g);
                }
            }

            ActFile actFile = new ActFile(file.ActorFile);

            _actors = actFile.Hierarchy;
            DatFile modelFile = new DatFile(_actors.Root.ModelName, !forDisplayOnly);

            ModelName = _actors.Root.ModelName;

            _actors.AttachModels(modelFile.Models);
            _actors.ResolveTransforms(!forDisplayOnly, _grooves);

            foreach (BaseGroove g in _grooves)
            {
                g.SetActor(_actors.GetByName(g.ActorName));
            }

            // link the funks and materials
            foreach (BaseFunk f in file.Funks)
            {
                f.Resolve();
            }

            Vector3 tireWidth = new Vector3(0.034f, 0, 0) * GameVars.Scale;

            foreach (int id in file.DrivenWheelRefs)
            {
                BaseGroove g = file.Grooves.Find(a => a.Id == id);
                if (g == null)
                {
                    continue;
                }
                CActor      actor = _actors.GetByName(g.ActorName);
                CWheelActor ca    = new CWheelActor(actor, true, false);
                ca.Position = actor.Matrix.Translation + (ca.IsLeft ? -1 * tireWidth : tireWidth);
                file.WheelActors.Add(ca);
            }
            foreach (int id in file.NonDrivenWheelRefs)
            {
                BaseGroove g     = file.Grooves.Find(a => a.Id == id);
                CActor     actor = _actors.GetByName(g.ActorName);
                if (actor == null)
                {
                    continue;                 //BUSTER.TXT does some weird shit for cockpit view of the front wheels
                }
                CWheelActor ca = new CWheelActor(actor, false, true);
                ca.Position = actor.Matrix.Translation + (ca.IsLeft ? -1 * tireWidth : tireWidth);
                file.WheelActors.Add(ca);
            }

            if (forDisplayOnly)
            {
                _actors.RenderWheelsSeparately = false;
            }
        }
コード例 #20
0
ファイル: CWheelActor.cs プロジェクト: vaginessa/OpenC1
 public CWheelActor(CActor actor, bool driven, bool steerable)
 {
     Actor       = actor;
     IsDriven    = driven;
     IsSteerable = steerable;
 }