예제 #1
0
        public void BlendAnimation()
        {
            SceneTests.InitializeScene();

            ContentImporter.Import(SceneManager.Scene, @"C:\Users\ansel\Documents\3dsmax\export\Lighting\armed.DAE")
            .OnSceneAttach(SceneManager.Scene);
            ContentImporter.ImportAnimation(SceneManager.Scene, @"C:\Users\ansel\Documents\3dsmax\export\Lighting\walk.DAE")
            .OnSceneAttach(SceneManager.Scene);

            var armed = SceneManager.Scene.AnimManager.Animations[0];
            var walk  = SceneManager.Scene.AnimManager.Animations[1];

            Frame root        = SceneManager.Scene.EnumerateNodesPosOrden().First(x => x.Type == FrameType.Bone);
            var   resetter    = new BonesResetter(root);
            var   translation = root.LocalPosition;

            var cursorArmed = armed.GetCursor(0);
            var cursorWalk  = walk.GetCursor(0);

            cursorArmed.Looping = AnimationLooping.Loop;
            cursorWalk.Looping  = AnimationLooping.Loop;

            SceneManager.Scene.Dynamics.Add(
                new Dynamic(deltaT =>
            {
                resetter.Reset();

                walk.Update(deltaT, 0, 1, true);
                armed.Update(deltaT, 0, 1, true);

                root.LocalPosition = translation;
                root.CommitChanges();
            })
                );
        }
        public void CreateThirdPersonController()
        {
            const float startTimeWalk = 34f / 30f;
            const float endTimeWalk   = 63f / 30f;
            const float durationWalk  = endTimeWalk - startTimeWalk;
            const float startTimeIdle = 0;
            const float endTimeIdle   = 0;
            const float durationIdle  = endTimeIdle;
            const float blendDuration = 0.25f;

            const float startTimeRun = 15f / 30f;
            const float endRunTime   = 80f / 30f;
            const float durationRun  = endRunTime - startTimeRun;

            SceneTests.InitializeScene();
            SceneManager.Scene.Physics.Enable  = true;
            SceneManager.Scene.Physics.Visible = false;

            CharacterControllerTagProcessor.ControllerCreated += CharacterControllerTagProcessor_ControllerCreated;

            ContentImporter.Import(SceneManager.Scene, @"C:\Users\ansel\Documents\3dsmax\export\game_level0\game_level0.DAE");
            ContentImporter.ImportAnimation(SceneManager.Scene, @"C:\Users\ansel\Documents\3dsmax\export\Lighting\walk.DAE");
            ContentImporter.ImportAnimation(SceneManager.Scene, @"C:\Users\ansel\Documents\3dsmax\export\Lighting\run.DAE");

            CharacterController controller = CharacterControllerManager.Instance.Controllers[0];
            var animationWalk = SceneManager.Scene.AnimManager.Animations[1];
            var animationRun  = SceneManager.Scene.AnimManager.Animations[2];

            var character = (((Frame)controller.Affectable)).FindNode((Frame x) => x.Type == FrameType.Bone);

            SceneManager.Scene.FindNode("camera1").BindTo(character);

            ThirdPersonControllerDesc desc = new ThirdPersonControllerDesc
            {
                CollitionController = controller,
                Character           = character,
                CameraMaxDistance   = 100,
                CameraMinDistance   = 20,
                CameraMaxPich       = Numerics.ToRadians(45),
                CameraMinPich       = Numerics.ToRadians(25),
                TransitionTime      = blendDuration,
                Camera = SceneManager.Scene.FindNode("camera1"),
                Idle   = new KeyFrameAnimationPlayback(animationWalk, startTimeIdle, durationIdle, AnimationLooping.Loop),
                Walk   = new KeyFrameAnimationPlayback(animationWalk, startTimeWalk, durationWalk, AnimationLooping.Loop, velocity: 1),
                //Walk = new AnimationPlayback(animationRun, startTimeRun, durationRun, AnimationLooping.Secuential),
            };
            ThirdPersonController characterController = new ThirdPersonController(desc);

            SceneManager.Scene.Dynamics.Add(characterController);

            //EngineState.Shadow.ShadowMapping.Bias = 0.9e-2f;
            FrameLight.CreateShadowMapForAllLights(SceneManager.Scene);
        }