How safe frame is calculated in 3ds Max. I want to know the relationship between Viewport width and height, Render width and height(aspect ratio) in the calculation of safe frame width and height.
My final goal is to find the distance between top left corner of the plane and top left corner of the safe frame.
what I require is
- Length of safe frame (red horizontal arrow)
- Height of safe frame (red vertical arrow)
- distance between viewport and safe frame (violet horizontal arrow)
Best How To :
The following MAXScript function demonstrates how to calculate a
box2 of the safe frame dimensions, given a
point2 of the viewport size and the render size.
We need to account for two separate cases: one where the differences in aspect result in spacing on the left and right, and one where they result in spacing on the top and bottom.
fn getViewportSafeFrameSize viewSize renderSize =
local viewAspect = viewSize.x as float / viewSize.y
local renderAspect = renderSize.x as float / renderSize.y
local x, y, w, h
if (viewAspect > renderAspect) then
h = viewSize.y
w = (h * renderAspect) as integer
y = 0
x = (viewSize.x - w) / 2
w = viewSize.x
h = (w / renderAspect) as integer
x = 0
y = (viewSize.y - h) / 2
return box2 x y w h
getViewportSafeFrameSize [gw.getWinSizeX(), gw.getWinSizeY()] [renderWidth, renderHeight]