Beispiel #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);
            }
        }
Beispiel #2
0
        // set view position and target location explicitly, during a dip-to-black transition
        public void Teleport(Vector3f vMoveToLocation, Vector3f vNewTargetLocation)
        {
            // figure out the pan that we would apply to camera, then apply the delta to the scene
            Vector3f curPos = UseCamera.GetPosition();
            Vector3f newPos = vMoveToLocation;
            Vector3f delta  = curPos - newPos;

            StartCoroutine(
                SmoothDipToBlack(0.75f));
            StartCoroutine(
                SmoothTranslate(UseScene.RootGameObject.GetPosition() + delta, 0.75f));
            StartCoroutine(
                SmoothMoveTarget(vNewTargetLocation + delta, 0.1f));
        }
Beispiel #3
0
        public void PanFocus(Vector3f v)
        {
            // figure out the pan that we would apply to camera, then apply the delta to the scene
            Vector3f curPos = UseCamera.GetPosition();
            Vector3f curDir = UseCamera.GetWorldFrame().Z;
            float    fDist  = Vector3.Dot((v - curPos), curDir);
            Vector3f newPos = v - fDist * curDir;
            Vector3f delta  = curPos - newPos;

            StartCoroutine(
                SmoothTranslate(UseScene.RootGameObject.GetPosition() + delta, 0.5f));
            StartCoroutine(
                SmoothMoveTarget(v + delta, 0.1f));
        }
Beispiel #4
0
        // should not use this anymore...
        public void PanFocus(Vector3f focusPoint, CoordSpace eSpace = CoordSpace.WorldCoords, float duration = 0.5f)
        {
            Vector3f focusPointW = (eSpace == CoordSpace.WorldCoords) ? focusPoint : UseScene.ToWorldP(focusPoint);

            // figure out the pan that we would apply to camera, then apply the delta to the scene
            Vector3f curPos = UseCamera.GetPosition();
            Vector3f curDir = UseCamera.GetWorldFrame().Z;
            float    fDist  = Vector3.Dot((focusPointW - curPos), curDir);
            Vector3f newPos = focusPointW - fDist * curDir;
            Vector3f delta  = curPos - newPos;

            StartCoroutine(
                SmoothTranslate(UseScene.RootGameObject.GetPosition() + delta, duration));
            StartCoroutine(
                SmoothMoveTarget(focusPointW + delta, duration / 10.0f));
        }
Beispiel #5
0
        /// <summary>
        /// Turntable-rotate to set azimuth/altitude, while also re-centering camera on target at given distance.
        /// </summary>
        public void AnimateOrbitZoomFocusTo(float toAzimuth, float toAltitude, float toDistance, 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;

            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 curDist = UseCamera.GetPosition().Distance(UseCamera.GetTarget());
                float toDist  = MathUtil.SmoothInterp(curDist, toDistance, 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);
            }
        }
Beispiel #6
0
        IEnumerator Teleport_Level_Helper(Vector3f vMoveToLocation, Vector3f vNewTargetLocation, Vector3f vPivotAround, float fLevelRotateAngle, float duration)
        {
            yield return(null);

            Sequence mySequence = DOTween.Sequence();

            mySequence.Append(
                ((Material)fadeObject.GetMaterial()).DOFade(1.0f, duration / 3.0f).OnComplete(() => {
                fGameObject sceneGO = UseScene.RootGameObject;

                // set target to new target location explicitly, then reset orbit altitude.
                // now we are level with ground but not at location
                CameraTarget = vPivotAround;
                UseCamera.Manipulator().ResetSceneOrbit(UseScene, false, true, true);

                // add planar rotation if we need it
                if (fLevelRotateAngle != 0)
                {
                    UseCamera.Manipulator().SceneOrbit(UseScene, UseCamera, fLevelRotateAngle, 0.0f);
                }

                // figure out the pan that we would apply to camera, opposite is pan to scene
                Vector3f delta = UseCamera.GetPosition() - vMoveToLocation;
                sceneGO.SetPosition(sceneGO.GetPosition() + delta);
                // also have to shift scene target pos
                CameraTarget = vNewTargetLocation + delta;

                UseCamera.SetTargetVisible(true);
            }));
            mySequence.AppendInterval(duration / 3.0f);
            mySequence.Append(
                ((Material)fadeObject.GetMaterial()).DOFade(0.0f, duration / 3.0f));

            // add a delay before we hide target
            mySequence.AppendInterval(1.0f);
            mySequence.OnComplete(() => {
                UseCamera.SetTargetVisible(false);
            });
        }
Beispiel #7
0
        /// <summary>
        /// Tumble scene to given orientation, while also re-centering camera on target at given distance.
        /// </summary>
        public void AnimateTumbleZoomFocusTo(Quaternionf toOrientation, float toDistance, Vector3f toTargetS, float duration = 0.25f)
        {
            if (duration > 0 && ShowTargetDuringAnimations)
            {
                UseCamera.SetTargetVisible(true);
            }

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

            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 curDist = UseCamera.GetPosition().Distance(UseCamera.GetTarget());
                float toDist  = MathUtil.SmoothInterp(curDist, toDistance, 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);
            }
        }