Ejemplo n.º 1
0
        /// <summary>
        /// Animate camera so that focusPoint moves to center of camera, at distance distanceW along cam.Forward
        /// Camera target is also set to focusPoint
        /// </summary>
        public void AnimatePanZoomFocus(Vector3f focusPoint, CoordSpace eSpace, float distanceW, float duration)
        {
            if (duration > 0 && ShowTargetDuringAnimations)
            {
                UseCamera.SetTargetVisible(true);
            }

            Vector3f focusPointS = (eSpace == CoordSpace.WorldCoords) ? UseScene.ToSceneP(focusPoint) : focusPoint;
            Vector3f startFocusS = UseScene.ToSceneP(UseCamera.GetTarget());
            float    startDistW  = UseCamera.GetPosition().Distance(UseCamera.GetTarget());

            Action <float> tweenF = (t) => {
                float    smooth_t   = MathUtil.WyvillRise01(t);
                Vector3f newTargetS = Vector3f.Lerp(startFocusS, focusPointS, smooth_t);
                UseCamera.Manipulator().PanFocusOnScenePoint(UseScene, UseCamera, newTargetS);

                float curDist = UseCamera.GetPosition().Distance(UseCamera.GetTarget());
                float toDist  = MathUtil.Lerp(startDistW, distanceW, smooth_t);
                float dolly   = toDist - curDist;
                UseCamera.Manipulator().SceneZoom(UseScene, UseCamera, -dolly);
            };

            if (duration > 0)
            {
                TweenAnimator anim = new TweenAnimator(tweenF, duration)
                {
                    OnCompletedF = () => { UseCamera.SetTargetVisible(false); }
                };
                UseScene.ObjectAnimator.Register(anim);
            }
            else
            {
                tweenF(1.0f);
            }
        }
Ejemplo n.º 2
0
        void generate_grid_lines(LineSet lines, Vector3f axis1, Vector3f axis2, int nExtentCount1, int nExtentCount2, float stepSize)
        {
            Vector2f minPos = stepSize * new Vector2f(-nExtentCount1, -nExtentCount2);
            Vector2f maxPos = stepSize * new Vector2f(nExtentCount1, nExtentCount2);
            int      n1 = 2 * nExtentCount1, n2 = 2 * nExtentCount2;

            int start1 = (IncludeEnds) ? 0 : 1, end1 = (IncludeEnds) ? n1 : n1 - 1;

            for (int i1 = start1; i1 <= end1; i1++)
            {
                float    t  = (float)i1 / (float)n1;
                float    tx = MathUtil.Lerp(minPos.x, maxPos.x, t);
                Vector3f p0 = tx * axis1 + minPos.y * axis2;
                Vector3f p1 = tx * axis1 + maxPos.y * axis2;
                lines.Segments.Add(new Segment3d(p0, p1));
            }

            int start2 = (IncludeEnds) ? 0 : 1, end2 = (IncludeEnds) ? n2 : n2 - 1;

            for (int i2 = start2; i2 <= end2; i2++)
            {
                float    t  = (float)i2 / (float)n2;
                float    ty = MathUtil.Lerp(minPos.y, maxPos.y, t);
                Vector3f p0 = minPos.x * axis1 + ty * axis2;
                Vector3f p1 = maxPos.x * axis1 + ty * axis2;
                lines.Segments.Add(new Segment3d(p0, p1));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Ortho variant of Turntable-rotate to set azimuth/altitude, while also re-centering camera on target at given distance.
        /// </summary>
        public void AnimateOrbitZoomFocusToOrtho(float toAzimuth, float toAltitude, float targetHeight, Vector3f toTargetS, float duration = 0.25f)
        {
            if (duration > 0 && ShowTargetDuringAnimations)
            {
                UseCamera.SetTargetVisible(true);
            }

            Vector3f startTargetS     = UseScene.ToSceneP(UseCamera.GetTarget());
            float    startAltitude    = UseCamera.Manipulator().TurntableAltitudeD;
            float    startAzimuth     = UseCamera.Manipulator().TurntableAzimuthD;
            float    startOrthoHeight = UseCamera.OrthoHeight;

            Action <float> tweenF = (t) => {
                Vector3f newTargetS = Vector3f.Lerp(startTargetS, toTargetS, t);
                //Vector3f newTargetW = UseScene.ToWorldP(newTargetS);
                //UseCamera.Manipulator().ScenePanFocus(UseScene, UseCamera, newTargetW, false);
                UseCamera.Manipulator().PanFocusOnScenePoint(UseScene, UseCamera, newTargetS);

                float alt = MathUtil.Lerp(startAltitude, toAltitude, t);
                float az  = MathUtil.Lerp(startAzimuth, toAzimuth, t);
                UseCamera.Manipulator().SceneOrbit(UseScene, UseCamera, az, alt, true);

                float curHeight = UseCamera.OrthoHeight;
                float toHeight  = MathUtil.Lerp(startOrthoHeight, targetHeight, t);
                float dh        = toHeight - curHeight;
                UseCamera.Manipulator().SceneZoom(UseScene, UseCamera, -dh);
            };

            if (duration > 0)
            {
                TweenAnimator anim = new TweenAnimator(tweenF, duration)
                {
                    OnCompletedF = () => { UseCamera.SetTargetVisible(false); }
                };
                UseScene.ObjectAnimator.Register(anim);
            }
            else
            {
                tweenF(1.0f);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Ortho variant of Tumble scene to given orientation, while also re-centering camera on target at given distance.
        /// </summary>
        public void AnimateTumbleZoomFocusToOrtho(Quaternionf toOrientation, float targetHeight, Vector3f toTargetS, float duration = 0.25f)
        {
            if (duration > 0 && ShowTargetDuringAnimations)
            {
                UseCamera.SetTargetVisible(true);
            }

            Vector3f startTargetS     = UseScene.ToSceneP(UseCamera.GetTarget());
            Frame3f  startF           = UseScene.SceneFrame;
            float    startOrthoHeight = UseCamera.OrthoHeight;

            Action <float> tweenF = (t) => {
                Vector3f newTargetS = Vector3f.Lerp(startTargetS, toTargetS, t);
                UseCamera.Manipulator().PanFocusOnScenePoint(UseScene, UseCamera, newTargetS);

                Quaternionf rot = Quaternion.Slerp(startF.Rotation, toOrientation, t);
                UseScene.RootGameObject.SetLocalRotation(rot);

                float curHeight = UseCamera.OrthoHeight;
                float toHeight  = MathUtil.Lerp(startOrthoHeight, targetHeight, t);
                float dh        = toHeight - curHeight;
                UseCamera.Manipulator().SceneZoom(UseScene, UseCamera, -dh);
            };

            if (duration > 0)
            {
                TweenAnimator anim = new TweenAnimator(tweenF, duration)
                {
                    OnCompletedF = () => { UseCamera.SetTargetVisible(false); }
                };
                UseScene.ObjectAnimator.Register(anim);
            }
            else
            {
                tweenF(1.0f);
            }
        }
Ejemplo n.º 5
0
 float dist_thresh(float fCurveRadius, float fSceneScale)
 {
     // when you zoom in you can draw smoother curves, but not too much smoother...
     return(MathUtil.Lerp(fCurveRadius, fCurveRadius * fSceneScale, 0.35f));
     //return fCurveRadius;
 }