private void CreateAndStartAnimations() { // Get the scene nodes that we want to animate using their names (as defined // in the .fbx file). _frontWheelLeft = _tank.GetSceneNode("l_steer_geo"); _frontWheelLeftRestPose = _frontWheelLeft.PoseLocal; _frontWheelRight = _tank.GetSceneNode("r_steer_geo"); _frontWheelRightRestPose = _frontWheelRight.PoseLocal; _hatch = _tank.GetSceneNode("hatch_geo"); _hatchRestPose = _hatch.PoseLocal; _turret = _tank.GetSceneNode("turret_geo"); _turretRestPose = _turret.PoseLocal; _cannon = _tank.GetSceneNode("canon_geo"); _cannonRestPose = _cannon.PoseLocal; // Create and start some animations. For general information about the DigitalRune Animation // system, please check out the user documentation and the DigitalRune Animation samples. // The front wheel should rotate left/right; oscillating endlessly. var frontWheelSteeringAnimation = new AnimationClip <float>( new SingleFromToByAnimation { From = -0.3f, To = 0.3f, Duration = TimeSpan.FromSeconds(3), EasingFunction = new SineEase { Mode = EasingMode.EaseInOut } }) { Duration = TimeSpan.MaxValue, LoopBehavior = LoopBehavior.Oscillate, }; AnimationService.StartAnimation(frontWheelSteeringAnimation, _frontWheelSteeringAngle) .AutoRecycle(); // The hatch opens using a bounce ease. var bounceOpenAnimation = new SingleFromToByAnimation { By = -0.8f, Duration = TimeSpan.FromSeconds(1), EasingFunction = new BounceEase { Mode = EasingMode.EaseOut } }; // Then it should close again. var bounceCloseAnimation = new SingleFromToByAnimation { By = 0.8f, Duration = TimeSpan.FromSeconds(0.5f), }; // We combine the open and close animation. The close animation should start // 2 seconds after the open animation (Delay = 2) and it should stay some // time in the final position (Duration = 2). var bounceOpenCloseAnimation = new TimelineGroup { bounceOpenAnimation, new TimelineClip(bounceCloseAnimation) { Delay = TimeSpan.FromSeconds(2), Duration = TimeSpan.FromSeconds(2) }, }; // The bounceOpenCloseAnimation should loop forever. var hatchAnimation = new TimelineClip(bounceOpenCloseAnimation) { Duration = TimeSpan.MaxValue, LoopBehavior = LoopBehavior.Cycle, }; AnimationService.StartAnimation(hatchAnimation, _hatchAngle) .AutoRecycle(); // The turret rotates left/right endlessly. var turretAnimation = new AnimationClip <float>( new SingleFromToByAnimation { From = -0.5f, To = 0.5f, Duration = TimeSpan.FromSeconds(4), EasingFunction = new HermiteEase { Mode = EasingMode.EaseInOut } }) { Duration = TimeSpan.MaxValue, LoopBehavior = LoopBehavior.Oscillate, }; AnimationService.StartAnimation(turretAnimation, _turretAngle) .AutoRecycle(); // The cannon rotates up/down endlessly. var cannonAnimation = new AnimationClip <float>( new SingleFromToByAnimation { By = -0.7f, Duration = TimeSpan.FromSeconds(6), EasingFunction = new HermiteEase { Mode = EasingMode.EaseInOut } }) { Duration = TimeSpan.MaxValue, LoopBehavior = LoopBehavior.Oscillate, }; AnimationService.StartAnimation(cannonAnimation, _cannonAngle) .AutoRecycle(); }