private MotionEntity CreateNPC(Vector2 position)
        {
            Vector3 translation = new Vector3(position, 3);
            var     npc         = new MotionEntity
            {
                MainGraphic = new MetaModel
                {
                    SkinnedMesh = new SkinnedMeshFromFile("Models/Units/Zombie1.x"),
                    Texture     = new TextureFromFile("Models/Units/Zombie1.png"),
                    World       = SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.1f, 0.1f, 0.1f),
                    IsBillboard = false,
                },
                Translation = translation
            };
            var mo = motionSimulation.CreateNPC();

            mo.LocalBounding   = new Common.Bounding.Cylinder(Vector3.Zero, 1f, 0.5f);
            mo.Position        = translation;
            mo.SteeringEnabled = true;
            mo.RunSpeed        = 2f;

            npc.MotionObject            = mo;
            npc.VisibilityLocalBounding = CreateBoundingBoxFromModel((MetaModel)npc.MainGraphic);

            Graphics.Renderer.Renderer.EntityAnimation ea = scene.View.Content.Peek <Graphics.Renderer.Renderer.EntityAnimation>(npc.MetaEntityAnimation);
            ea.PlayAnimation(new AnimationPlayParameters("Idle1", true));

            return(npc);
        }
Esempio n. 2
0
        private MotionEntity CreateUnit(Vector3 position)
        {
            var unit = new MotionEntity
            {
                MainGraphic = new MetaModel
                {
                    SkinnedMesh = new SkinnedMeshFromFile("goblin_blade_master1.x"),
                    Texture     = new TextureFromFile("goblin_blade_master1.png"),
                    World       = SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.1f, 0.1f, 0.1f),
                    IsBillboard = false,
                },

                /*Animation = "idle1",
                 * AnimationLoop = true,*/
                Translation = position
            };

            var mo = motionSimulation.CreateUnit();
            var lb = new Common.Bounding.Cylinder(Vector3.Zero, 1f, 0.5f);

            mo.LocalBounding  = lb;
            mo.Position       = position;
            unit.MotionObject = mo;

            unit.VisibilityLocalBounding = new MetaBoundingBox
            {
                Mesh           = ((MetaModel)unit.MainGraphic).SkinnedMesh,
                Transformation = ((MetaModel)unit.MainGraphic).World
            };

            Graphics.Renderer.Renderer.EntityAnimation ea = scene.View.Content.Peek <Graphics.Renderer.Renderer.EntityAnimation>(unit.MetaEntityAnimation);
            ea.PlayAnimation(new AnimationPlayParameters("idle1", true));

            return(unit);
        }
        protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
            base.OnKeyDown(e);

            Graphics.Renderer.Renderer.EntityAnimation ea = Scene.View.Content.Peek <Graphics.Renderer.Renderer.EntityAnimation>(exquemelin.MetaEntityAnimation);

            if (e.KeyCode == System.Windows.Forms.Keys.F1)
            {
                //var bla = exquemelin.RendererGraphics.First().Value;
                ((Graphics.Content.MetaModel)exquemelin.MainGraphic).HasAlpha = true;
                ((Graphics.Content.MetaModel)exquemelin.MainGraphic).Opacity  = 0.4f;
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F2)
            {
                ((Graphics.Content.MetaModel)exquemelin.MainGraphic).HasAlpha = false;
                ((Graphics.Content.MetaModel)exquemelin.MainGraphic).Opacity  = 0.4f;
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F3)
            {
                ((Graphics.Content.MetaModel)exquemelin.MainGraphic).Texture = new Graphics.Content.TextureFromFile("Models/Units/Ghoul1.png");
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F4)
            {
                ((Graphics.Content.MetaModel)exquemelin.MainGraphic).Texture = new Graphics.Content.TextureFromFile("Models/Units/Zombie1.png");
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F5)
            {
                //ea.DisableTrack(1);
                ea.PlayAnimation(new AnimationPlayParameters("Idle1", true));
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F6)
            {
                //ea.DisableTrack(1);
                ea.PlayAnimation(new AnimationPlayParameters("MeleeThrust1", false));
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F7)
            {
                //ea.DisableTrack(1);
                ea.PlayAnimation(new AnimationPlayParameters("Run1", true));
            }
            else if (e.KeyCode == System.Windows.Forms.Keys.F8)
            {
                //ea.DisableTrack(1);
                ea.PlayAnimation(new AnimationPlayParameters("Death1", false));
            }
        }
        public override void Init()
        {
            Content.ContentPath = "Data";

            Scene        = new Scene();
            Scene.View   = this;
            Scene.Camera = new LookatCartesianCamera()
            {
                Position    = new Vector3(10, 10, 10),
                Lookat      = Vector3.Zero,
                ZFar        = 100,
                AspectRatio = AspectRatio
            };
            sceneQuadtree = new Common.Quadtree <Entity>(10);
            sbau          = new SceneBVHAutoSyncer(Scene, sceneQuadtree);

            StateManager = new Device9StateManager(Device9);

            Renderer = new Graphics.Renderer.Renderer(Device9)
            {
                Scene = Scene, StateManager = StateManager, Settings = new Graphics.Renderer.Settings {
                    ShadowQuality = Graphics.Renderer.Settings.ShadowQualities.NoShadows
                }
            };
            Renderer.Initialize(this);
            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Scene    = Scene,
                Renderer = Renderer
            };
            sceneRendererConnector.Initialize();

            Scene.Add(exquemelin = new Entity
            {
                MainGraphic = new Graphics.Content.MetaModel
                {
                    SkinnedMesh = new Graphics.Content.SkinnedMeshFromFile("Models/Units/Zombie1.x"),
                    Texture     = new Graphics.Content.TextureFromFile("Models/Units/Zombie1.png"),
                    World       = Graphics.Content.SkinnedMesh.InitSkinnedMeshFromMaya * Matrix.Scaling(0.5f, 0.5f, 0.5f),
                    HasAlpha    = false,
                },
                VisibilityLocalBounding = new Common.Bounding.NonfittableBounding(Vector3.Zero, false, true)
            });

            Graphics.Renderer.Renderer.EntityAnimation ea = Scene.View.Content.Peek <Graphics.Renderer.Renderer.EntityAnimation>(exquemelin.MetaEntityAnimation);

            ea.PlayAnimation(new AnimationPlayParameters("Idle1", true));

            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)Scene.Camera,
            };
        }
Esempio n. 5
0
 private void PlayAnimation(string s, float fadeTime)
 {
     Graphics.Renderer.Renderer.EntityAnimation ea = Scene.View.Content.Peek <Graphics.Renderer.Renderer.EntityAnimation>(exquemelin.MetaEntityAnimation);
     try
     {
         var a = ea.AnimationController.GetAnimationSet <AnimationSet>(s);
         ea.PlayAnimation(new AnimationPlayParameters(s, true)
         {
             FadeTime = fadeTime
         });
     }
     catch (Direct3D9Exception e)
     {
         Console.WriteLine("Error trying to find animation. " + s + "\nAdditional error information: " + e);
     }
 }