Notifications
Clear all
[Closed] Get safe frame user percentages
Dec 17, 2013 8:32 pm
Is there any way (MXS or SDK) to get the user defined values of safe frames? I believe it’s saved in the scene, but I don’t see an API to retrieve the values (other than ui accessor hacks).
5 Replies
2 Replies
it’s in some parameter block… i don’t remember where. once i found it but… can’t find a code now.
Thanks, at least I know to keep looking.
@Klunk-1 : The values I’m actually trying to retrieve are not whether or not safe frames are enabled or not, and not the dimensions of the active viewport area, but the percentages of safe frames the user can select (see attached image).
Dec 17, 2013 8:32 pm
from the sdk this would add knowing if your are in safeframe mode to mxs…
def_visible_primitive(isViewportSafe, "isViewportSafe");
Value* isViewportSafe_cf(Value **arg_list, int count)
{
check_arg_count(isViewportSafe, 0, count);
ViewExp* vp = MAXScript_interface->GetActiveViewport();
int safe = vp->getSFDisplay();
MAXScript_interface->ReleaseViewport(vp);
return bool_result(safe);
}
and this will compute the width of a horizontal safe frame, you’ll have to work out how the vertical one works
fn GetSafeFrameWidth =
(
focal_dist = viewport.getFocalDistance();
vp_center_ws = [0,0,-focal_dist] * inverse(viewport.getTM());
-- get the height of the viewport in worldspace
scrn_scale = viewport.GetScreenScaleFactor vp_center_ws;
rd_aspect = renderWidth as float/renderHeight as float;
vp_width = scrn_scale * rd_aspect;
vp_topleft_ws = [-vp_width * 0.5,scrn_scale * 0.5,-focal_dist] * inverse(viewport.getTM());
scrn_coords = gw.wTransPoint vp_topleft_ws;
scrn_coords.x + 1;
)