[Closed] setTM for Orthographic Views?
Hi, is there a way to save the true TM of an orthographic view? (LEFT, FRONT, TOP etc…)
Whenever I run the viewport.getTM(), I get values like these:
(matrix3 [1,0,0] [0,0,-1] [0,1,0] [-115.022,-16.7307,0])
(matrix3 [1,0,0] [0,0,-1] [0,1,0] [1.17456,-2.20587,0])
(matrix3 [1,0,0] [0,0,-1] [0,1,0] [158.041,128.517,0])
where it doesn’t seem to get any scale/zoom values.
I’m able to make use of the row4 position though, it’s just the zoom factor that’s missing.
The closest thing that I have right now is by using the viewport.ZoomToBounds function. But in order to use this properly, I need to supply the correct pointA and pointB arguments that it needs…
I tested the function using this:
viewport.ZoomToBounds false [-1, -1, -1] [1, 1, 1]
which works well, then I tried to get the screen scale factor:
getScreenScaleFactor [0,0,0]
it returned this number:
2.34651
Does anyone have any clue how the number was derived? I just wanted to have a clearer undertanding where this number came from.
I will be using the number to generate the required point3 data by the ZoomToBounds function. Here is the working function that I’m using:
fn getOrthoZoomBounds =
(
if not viewport.IsPerspView() do
(
theMagicNumber = 2.34651
viewFactor = ( getScreenScaleFactor [0,0,0] ) / theMagicNumber
theScale = [viewFactor, viewFactor, viewFactor]
viewOffset = -(inverse (getViewTM())).row4
pointA = -theScale - viewOffset
pointB = theScale - viewOffset
#(pointA, pointB)
)
)
Thanks in advance for any insights.
Hi Jeff,
I had something to do with the same issue while writing IC.SizeInScreen. I can barely remember I used to create a FreeCamera, align it to viewport, set it to Orthographic and working on its FOV. You can take a look at my code, from IllusionCatalyst website, it should be quite straightforward.
Mind that 3ds Max 2008 introduced some new methods for viewport manipulation, and my script works for 9 too, with some workarounds. Check the ‘if (iMaxVersion < 10) then …’ conditional.
- Enrico
Hi Enrico, thanks for the insight, you scripts are really well made. I love the clean and welcoming UI. I’ll have a look at those. Thanks!
right now, I’m still scratching my head for any info regarding the “magicnumber”