diff --git a/animation/CameraAnimator.cs b/animation/CameraAnimator.cs
index fabf7c6..b98267f 100644
--- a/animation/CameraAnimator.cs
+++ b/animation/CameraAnimator.cs
@@ -121,6 +121,41 @@ public void AnimatePanZoomFocus(Vector3f focusPoint, CoordSpace eSpace, float di
}
+
+ ///
+ ///
+ public void AnimatePanZoomFocusOrtho(Vector3f focusPoint, CoordSpace eSpace, float targetHeight, 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 startHeight = UseCamera.OrthoHeight;
+
+ Action tweenF = (t) => {
+ float smooth_t = MathUtil.WyvillRise01(t);
+ Vector3f newTargetS = Vector3f.Lerp(startFocusS, focusPointS, smooth_t);
+ UseCamera.Manipulator().PanFocusOnScenePoint(UseScene, UseCamera, newTargetS);
+
+ float toHeight = MathUtil.Lerp(startHeight, targetHeight, t);
+ float curHeight = UseCamera.OrthoHeight;
+ 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);
+ }
+
+
+
+
///
/// Animate camera so that centerPt moves to center of camera, and width is visible.
/// Camera target is also set to centerPt
@@ -129,9 +164,14 @@ public void AnimateFitWidthToView(Vector3f centerPt, float width, CoordSpace eSp
{
if (eSpace != CoordSpace.WorldCoords)
width = UseScene.ToWorldDimension(width);
- float fFitDistW = UseCamera.Manipulator().GetFitWidthCameraDistance(width);
Vector3f focusPointW = (eSpace == CoordSpace.WorldCoords) ? centerPt : UseScene.ToWorldP(centerPt);
- AnimatePanZoomFocus(focusPointW, CoordSpace.WorldCoords, fFitDistW, duration);
+ 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);
+ }
}
@@ -143,9 +183,13 @@ public void AnimateFitHeightToView(Vector3f centerPt, float height, CoordSpace e
{
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);
+ if (UseCamera.IsOrthographic) {
+ AnimatePanZoomFocusOrtho(focusPointW, CoordSpace.WorldCoords, height, duration);
+ } else {
+ float fFitDistW = UseCamera.Manipulator().GetFitHeightCameraDistance(height);
+ AnimatePanZoomFocus(focusPointW, CoordSpace.WorldCoords, fFitDistW, duration);
+ }
}
diff --git a/platform/fCamera.cs b/platform/fCamera.cs
index f4d3f44..7904071 100644
--- a/platform/fCamera.cs
+++ b/platform/fCamera.cs
@@ -133,6 +133,7 @@ public Vector3f Right()
public bool IsOrthographic {
get { return camera.orthographic; }
+ set { camera.orthographic = value; }
}
//https://docs.unity3d.com/ScriptReference/Camera-orthographicSize.html
diff --git a/view/CameraTracking.cs b/view/CameraTracking.cs
index e51089b..72e279e 100644
--- a/view/CameraTracking.cs
+++ b/view/CameraTracking.cs
@@ -109,9 +109,13 @@ public CameraTracking() {
fCamera hudCamera;
fCamera uiCamera;
fCamera cursorCamera;
+
+ bool is_orthographic_view = false;
+
FContext controller;
+
public fCamera MainCamera {
get { return mainCamera; }
}
@@ -145,6 +149,8 @@ public void Initialize (FContext controller) {
}
}
+ is_orthographic_view = mainCamera.IsOrthographic;
+
List newCameras = new List();
Vector3f mainPos = mainCamera.GetPosition();
@@ -262,6 +268,25 @@ public void UpdateMainCamFarDistance(float distance)
cursorCamera.FarClipPlane = distance;
}
+
+ ///
+ /// configure the 3D-view cameras for orthographic/perspective
+ ///
+ public void UpdateOrthographic(bool orthographic)
+ {
+ if (is_orthographic_view == orthographic)
+ return;
+ if (mainCamera != null)
+ mainCamera.IsOrthographic = orthographic;
+ if (widgetCamera != null)
+ widgetCamera.IsOrthographic = orthographic;
+ if (hudCamera != null)
+ hudCamera.IsOrthographic = orthographic;
+ if (cursorCamera != null)
+ cursorCamera.IsOrthographic = orthographic;
+ is_orthographic_view = orthographic;
+ }
+
}
}
\ No newline at end of file