コード例 #1
0
        /// <summary>
        /// Animate camera so that centerPt moves to center of camera, and height is visible.
        /// Camera target is also set to centerPt
        /// </summary>
        public void AnimateFitHeightToView(Vector3f centerPt, float height, CoordSpace eSpace, float duration)
        {
            if (eSpace != CoordSpace.WorldCoords)
            {
                height = UseScene.ToWorldDimension(height);
            }
            float    fFitDistW   = UseCamera.Manipulator().GetFitHeightCameraDistance(height);
            Vector3f focusPointW = (eSpace == CoordSpace.WorldCoords) ? centerPt : UseScene.ToWorldP(centerPt);

            AnimatePanZoomFocus(focusPointW, CoordSpace.WorldCoords, fFitDistW, duration);
        }
コード例 #2
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));
        }
コード例 #3
0
        /// <summary>
        /// Animate camera so that centerPt moves to center of camera, and width is visible.
        /// Camera target is also set to centerPt
        /// </summary>
        public void AnimateFitWidthToView(Vector3f centerPt, float width, CoordSpace eSpace, float duration)
        {
            if (eSpace != CoordSpace.WorldCoords)
            {
                width = UseScene.ToWorldDimension(width);
            }
            Vector3f focusPointW = (eSpace == CoordSpace.WorldCoords) ? centerPt : UseScene.ToWorldP(centerPt);

            if (UseCamera.IsOrthographic)
            {
                float targetHeight = UseCamera.AspectRatio * width;
                AnimatePanZoomFocusOrtho(focusPointW, CoordSpace.WorldCoords, targetHeight, duration);
            }
            else
            {
                float fFitDistW = UseCamera.Manipulator().GetFitWidthCameraDistance(width);
                AnimatePanZoomFocus(focusPointW, CoordSpace.WorldCoords, fFitDistW, duration);
            }
        }