public ThirdPersonController(ThirdPersonControllerDesc desc)
        {
            _character           = desc.Character;
            _collitionController = desc.CollitionController;
            _walk = desc.Walk;
            _idle = desc.Idle;

            _turn90Speed  = Numerics.PI / 2 / desc.TransitionTime;
            _turn180Speed = Numerics.PI / desc.TransitionTime;

            _cameraMaxDistance = desc.CameraMaxDistance;
            _cameraMinDistance = desc.CameraMinDistance;
            _cameraMaxPich     = desc.CameraMaxPich;
            _cameraMinPich     = desc.CameraMinPich;
            _camera            = desc.Camera;

            _resetter = new BonesResetter(_character);

            _idleWalk = new AnimationTransition(_idle, _walk, desc.TransitionTime);
            _walkIdle = new AnimationTransition(_walk, _idle, desc.TransitionTime);

            _walk.FirstPlayback.Animation.Sample(_walk.FirstPlayback.Cursor.StartTime);
            _initialForwardPositon = _character.LocalPosition;

            _walk.FirstPlayback.Animation.Sample(_walk.FirstPlayback.Cursor.StartTime + desc.TransitionTime);
            _lastAnimPosition = _character.LocalPosition;
            _walkForwardSpeed = _character.LocalPosition - _initialForwardPositon;

            _resetter.Reset();
            _initialHeading = _character.Heading;

            CreateStates();

            _cameraBindedToCharacter = _camera.Affector == _character;
        }
        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);
        }