private void StartButton_OnClick(object sender, RoutedEventArgs e)
        {
            StartButton.IsEnabled = false;

            Camera1.RotateTo(20, -30, 500, Ab3d.Animation.EasingFunctions.CubicEaseInOutFunction);
            Camera1.AnimationController.AnimationCompleted += OnStartupAnimationCompleted;
        }
예제 #2
0
        private void AnimateCameraRotationTo(double targetHeading, double targetAttitude, bool useShortestPath = true)
        {
            Camera1.RotateTo(targetHeading,
                             targetAttitude,
                             animationDurationInMilliseconds: 1000,
                             easingFunction: Ab3d.Animation.EasingFunctions.QuadraticEaseInOutFunction,
                             useShortestPath: true);

            DumpTextBox.Text = string.Format("Camera1.RotateTo({0}, {1}, 1000, Ab3d.Animation.EasingFunctions.QuadraticEaseInOutFunction, useShortestPath: true);\r\n\r\n", targetHeading, targetAttitude);

            // We can get details about the animation with calling GetDumpString method on AnimationController or any other animation related class.
            // It is also possible to call Dump method in the Visual Studio immediate method. This will dump the details to the same window.
            DumpTextBox.Text += Camera1.AnimationController.GetDumpString();


            // The following commented code shows how to start animation manually without RotateTo method:

            /*
             * double startHeading  = Camera1.Heading;
             * double startAttitude = Camera1.Attitude;
             *
             * if (double.IsNaN(targetHeading))
             *  targetHeading = startHeading;
             *
             * if (double.IsNaN(targetAttitude))
             *  targetAttitude = startAttitude;
             *
             *
             * // Adjust start heading and attitude so that we will come with the shortest path to the target heading and attitude
             * if (useShortestPath)
             * {
             *  startHeading  = Ab3d.Utilities.CameraUtils.GetClosestPathStartAngle(startHeading,  targetHeading);
             *  startAttitude = Ab3d.Utilities.CameraUtils.GetClosestPathStartAngle(startAttitude, targetAttitude);
             * }
             *
             *
             * // Create a new CameraAnimationNode that will animate the Camera1
             * var cameraAnimationNode = new CameraAnimationNode(Camera1);
             *
             * // Start with current camera Heading and Attitude
             * cameraAnimationNode.RotationTrack.Keys.Add(new CameraRotationKeyFrame(0, startHeading, startAttitude));
             *
             * // Animate to the specified heading and attitude in 100 frames
             * cameraAnimationNode.RotationTrack.Keys.Add(new CameraRotationKeyFrame(100, targetHeading, targetAttitude));
             *
             *
             * // It is possible to set different interpolation mode to each KeyFrame, but it is easier
             * // to set the same interpolation mode to all key frames with SetInterpolationToAllKeys method.
             * cameraAnimationNode.RotationTrack.SetEasingFunctionToAllKeys(Ab3d.Animation.EasingFunctions.QuadraticEaseInOutFunction);
             *
             *
             * // Set this animation as one-time only
             * _animationController.AutoRepeat = false;
             * _animationController.AutoReverse = false;
             *
             * // Use StartAnimation helper method to stop current animation and start the animation defined in cameraAnimationNode
             * StartAnimation(cameraAnimationNode);
             */
        }
예제 #3
0
        private void RotateToSideButton_OnClick(object sender, RoutedEventArgs e)
        {
            Camera1.RotateTo(targetHeading: 30,
                             targetAttitude: -20,
                             animationDurationInMilliseconds: 800,
                             easingFunction: Ab3d.Animation.EasingFunctions.CubicEaseInOutFunction);

            // See Animations/CameraAnimation for advanced camera animation samples.
        }
예제 #4
0
        private void RotateToTopButton_OnClick(object sender, RoutedEventArgs e)
        {
            // Animate camera to -90 attitude; current camera's heading is preserved
            Camera1.RotateTo(targetHeading: double.NaN,
                             targetAttitude: -90,
                             animationDurationInMilliseconds: 800,
                             easingFunction: Ab3d.Animation.EasingFunctions.CubicEaseInOutFunction);

            // See Animations/CameraAnimation for advanced camera animation samples.
        }
        private void MainDXViewportViewOnSceneRendered(object sender, EventArgs e)
        {
            // This method should be executed only after the first frame is rendered
            MainDXViewportView.SceneRendered -= MainDXViewportViewOnSceneRendered;

            // Do a hit test of all hit objects
            GetAllHitTestObjects();

            // Now animate the camera so that it will show the hit 3D line
            Camera1.RotateTo(40, -15, 1000);
        }
예제 #6
0
        private void AnimateCameraRotationTo(Point3D targetCameraPosition, Vector3D targetUpDirection)
        {
            var animationType = (SphericalInterpolationCheckBox.IsChecked ?? false)
                ? FreeCameraAnimationNode.FreeCameraAnimationTypes.SphericalInterpolation
                : FreeCameraAnimationNode.FreeCameraAnimationTypes.LinearInterpolation;

            // The easiest way to rotate the free camera it to use RotateTo method.
            Camera1.RotateTo(targetCameraPosition, targetUpDirection,
                             animationDurationInMilliseconds: 1000,
                             easingFunction: Ab3d.Animation.EasingFunctions.QuadraticEaseInOutFunction,
                             animationType: animationType);

            // But if you want more control, it is possible to manually define the rotation.
            // The following code does the same as Camera1.RotateTo (except that it uses our own _animationController instead of Camera1.AnimationController):

            //// Create a new CameraAnimationNode that will animate the Camera1
            //var freeCameraAnimationNode = new FreeCameraAnimationNode(Camera1);

            //freeCameraAnimationNode.AnimationType = animationType;

            //if (Camera1.CameraPosition != targetCameraPosition)
            //{
            //    freeCameraAnimationNode.CameraPositionTrack.Keys.Add(new Position3DKeyFrame(0,   Camera1.CameraPosition));
            //    freeCameraAnimationNode.CameraPositionTrack.Keys.Add(new Position3DKeyFrame(100, targetCameraPosition));

            //    // It is possible to set different interpolation mode to each KeyFrame, but it is easier
            //    // to set the same interpolation mode to all key frames with SetInterpolationToAllKeys method.
            //    freeCameraAnimationNode.CameraPositionTrack.SetEasingFunctionToAllKeys(Ab3d.Animation.EasingFunctions.QuadraticEaseInOutFunction);
            //}

            //if (Camera1.UpDirection != targetUpDirection)
            //{
            //    freeCameraAnimationNode.UpDirectionTrack.Keys.Add(new Vector3DKeyFrame(0,   Camera1.UpDirection));
            //    freeCameraAnimationNode.UpDirectionTrack.Keys.Add(new Vector3DKeyFrame(100, targetUpDirection));

            //    freeCameraAnimationNode.UpDirectionTrack.SetEasingFunctionToAllKeys(Ab3d.Animation.EasingFunctions.QuadraticEaseInOutFunction);
            //}

            //// It is possible to set different interpolation mode to each KeyFrame, but it is easier
            //// to set the same interpolation mode to all key frames with SetInterpolationToAllKeys method.
            //freeCameraAnimationNode.TargetPositionTrack.SetEasingFunctionToAllKeys(Ab3d.Animation.EasingFunctions.QuadraticEaseInOutFunction);


            //// Set this animation as one-time only
            //_animationController.AutoRepeat = false;
            //_animationController.AutoReverse = false;

            //// Use StartAnimation helper method to stop current animation and start the animation defined in cameraAnimationNode
            //StartAnimation(freeCameraAnimationNode);
        }