Inheritance: AnimationBase
Exemplo n.º 1
0
 public TimBehavior()
     : base("TimBehavior")
 {
     this.direction = NONE;
     this.anim2D = null;
     this.trans2D = null;
     MyScene.currentState = MyScene.AnimState.Idle;
 }
Exemplo n.º 2
0
        protected override void CreateScene()
        {            
            ViewCamera camera = new ViewCamera("MainCamera", new Vector3(2, 1, 2), new Vector3(0, 1, 0));
            camera.BackgroundColor = Color.CornflowerBlue;
            EntityManager.Add(camera.Entity);            

            Entity animatedModel = new Entity("Isis")
                .AddComponent(new Transform3D())
                .AddComponent(new BoxCollider())
                .AddComponent(new SkinnedModel("Content/isis.wpk"))
                .AddComponent(new MaterialsMap(new BasicMaterial("Content/isis-difuse.wpk")))
                .AddComponent(new Animation3D("Content/isis-animations.wpk"))
                .AddComponent(new SkinnedModelRenderer());

            anim = animatedModel.FindComponent<Animation3D>();
            EntityManager.Add(animatedModel);
        }
Exemplo n.º 3
0
        protected override void CreateScene()
        {
            #region Scene creation
            // Create the camera
            ViewCamera camera = new ViewCamera("MainCamera", new Vector3(2, 1, 2), new Vector3(0, 1, 0));
            camera.BackgroundColor = Color.CornflowerBlue;
            EntityManager.Add(camera.Entity);            

            // Create the model. Note of we add the Animation3D component.
            Entity animatedModel = new Entity("Isis")
                .AddComponent(new Transform3D())
                .AddComponent(new BoxCollider())
                .AddComponent(new SkinnedModel("Content/isis.wpk"))
                .AddComponent(new MaterialsMap(new BasicMaterial("Content/isis-difuse.wpk")))
                .AddComponent(new Animation3D("Content/isis-animations.wpk"))
                .AddComponent(new SkinnedModelRenderer())
                .AddComponent(new IsisBehavior());

            // Create the sound bank
            SoundBank spankerSlamSounds = new SoundBank();
            spankerSlamSounds.Add(SoundsManager.FootStep1);
            spankerSlamSounds.Add(SoundsManager.FootStep2);
            WaveServices.SoundPlayer.RegisterSoundBank(spankerSlamSounds);            
            #endregion

            #region Key Events
            // Add the key frames. The first parameter is the name of the animation, the second the number of frames and the third the name of the event. As you can see, we raise two events when
            // the animation is "Attack" ( see the Animation3D example for further information ). The first event is raised on frame 10 and the second on frame 25. See the SpankerBehavior class
            animation = animatedModel.FindComponent<Animation3D>()
                .AddKeyFrameEvent("Jog", 1, "DoFootstep")
                .AddKeyFrameEvent("Jog", 14, "DoFootstep")
                .AddKeyFrameEvent("Jog", 26, "DoFootstep")
                .AddKeyFrameEvent("Jog", 39, "DoFootstep");
            EntityManager.Add(animatedModel);
            #endregion
        }
Exemplo n.º 4
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.CornflowerBlue;

            //ViewCamera camera = new ViewCamera("MainCamera", new Vector3(0, 2f, -2.5f), new Vector3(0, 1, 0));
            camera = new FreeCamera("freeCamera", new Vector3(0, 2f, -3.5f), Vector3.UnitY * 0.9f)
            {
                Speed = 5
            };
            Entity animatedModel = new Entity("Isis")
                .AddComponent(new Transform3D())
                .AddComponent(new BoxCollider())
                .AddComponent(new SkinnedModel("Content/isis.wpk"))
                .AddComponent(new MaterialsMap(new BasicMaterial("Content/isis-difuse.wpk") { ReferenceAlpha = 0.5f }))
                .AddComponent(new Animation3D("Content/isis-animations.wpk"))
                .AddComponent(new SkinnedModelRenderer())
                .AddComponent(new TimBehavior());

            anim = animatedModel.FindComponent<Animation3D>();
            EntityManager.Add(animatedModel);

            Entity floor = new Entity("Floor")
                       .AddComponent(new Transform3D())
                       .AddComponent(new BoxCollider())
                       .AddComponent(new Model("Content/Model/floor.wpk"))
                       .AddComponent(new MaterialsMap(new BasicMaterial("Content/Texture/floorNight.wpk")))
                       .AddComponent(new ModelRenderer());

            //Suddenly columns! Thousand of them!  (4x2 columns)

            EntityManager.Add(floor);

            //Suddenly columns! Thousand of them!  (4x2 columns)
            /*int nColumns = 0;
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Entity column = new Entity("column_" + nColumns++)
                        .AddComponent(new Transform3D() { Position = new Vector3(4 - (8 * j), 0, 8 * i) })
                       .AddComponent(new Model("Content/Model/floor.wpk"))
                        .AddComponent(new ModelRenderer())
                       .AddComponent(new MaterialsMap(new BasicMaterial("Content/Texture/floorNight.wpk")));

                    EntityManager.Add(column);
                    Entity fern = new Entity("Fern" + nColumns++)
                             .AddComponent(new Transform3D() { Position = new Vector3(2f - (8 * j), 0f, 2.5f*i) })
                             .AddComponent(new BoxCollider())
                             .AddComponent(new Model("Content/Model/fern.wpk"))
                             .AddComponent(new MaterialsMap(new BasicMaterial("Content/Texture/FernTexture.wpk") { ReferenceAlpha = 0.5f }))
                             .AddComponent(new ModelRenderer());

                    EntityManager.Add(fern);
                }
            }*/

            camera.Entity.AddComponent(new CameraBehavior(EntityManager.Find("Isis")));

            //Add some light!
            PointLight light = new PointLight("light", Vector3.Zero)
            {
                Attenuation = 75,
                Color = new Color(1, 0.6f, 0.4f),
                IsVisible = true
            };
            light.Entity.AddComponent(new FollowCameraBehavior(camera.Entity));
            light.Entity.AddComponent(new TorchLightBehaviour());

            EntityManager.Add(light);
            EntityManager.Add(camera);
            RenderManager.SetActiveCamera(camera.Entity);
        }