Notifications
Clear all

[Closed] Preserve zoom when switching between orthographic/perspective mode

I often switch between orthographic and perspective mode when modeling. I have a custom shortcut that toggles between these modes with a hotkey. Everything works as expected, but when switching to orthographic it zooms the camera out, and when switching to perspective it zooms in.

I was wondering if there was some way to preserve the zoom when switching between these two modes? I’m guessing it’s not possible, but you guys have surprised me before

EDIT: Current code

-- Toggle between orthographic/perspective mode
if (gw.isPerspectiveView() == true) then (
    max vpt iso user
)
else (
    max vpt persp user
)
3 Replies

I’m sorry to bump this thread, I was just hoping someone (a bit brighter than me) maybe had some input on this.

I’ve realized that there’s probably be a convertable relationship between these two modes. The “zoom” in orthographic mode seems to be determined by the value retrieved by viewport.GetFOV() (which continually changes when navigating/zooming in orthographic mode), but as I want a constant FOV when in perspective mode (lets say 40) I would have to find a way to convert the orthographic zoom (FOV) into a position matrix for the camera (relative to it’s constant FOV of 40).

I’ve noticed that when using the default ‘U’ hotkey it “tries” to preserve the zoom when switching between the two modes, but there’s two problems. First, it doesn’t do a great job of preserving the zoom. Second (and most important), it actually changes to FOV of the perspective view also (based on the zoom when toggling out from a current orthographic view), which I don’t want.

Sorry again for bumping this, this may be a lot harder to do than I think, I just thought I’d give it another go just in case this thread had slipped past any of the wizards in here

For ortho, you can get FOV like this

fn getOrthoFOV =
(
	local size = getViewSize()
	local viewWidth = gw.getVPWorldWidth [0,0,0] * amax 1.0 (size.x / size.y)
	2 * atan (viewWidth / (2 * viewport.getFocalDistance()))
)

Sorry I didn’t see your reply until now. This might be totally obvious, but how would the returned value of this function be used to “translate” between orthographic and perspective mode?