[Closed] Kind of 2D Bounding Box
Hi,
i would like to make a maxscript, which does the following:
The script adjusts the render region(vray -vfb) of each rendererd frame, so it fits to the selected object.
So the first thing I need to figure out is:
How i can get some kind of Bouding box for each frame for the selected object.
So i can set the coordinates for the render region that it holds the whole object for each frame.
Thanks!
Why not use the max-intern region rendering with “Auto Region Selected”?
Because there are more then one object in the scene and I need just the part of the render where the selected object is visible.
Yes, that´s exactly how it works.
Maybe i don´t fully understand what you try to achieve.
What would be different to “Auto Region Selected”?
Oh ok, I need to try it. I think I never tried this feature yet.
as an interesting exercise/puzzle
fn render_a_mesh obj =
(
gw.setTransform(Matrix3 1)
-- compute viewport min and max bounding box
scrn_pos = gw.wTransPoint (getvert obj 1);
top = bottom = scrn_pos.y;
left = right = scrn_pos.x;
for v = 2 to obj.numverts do
(
scrn_pos = gw.wTransPoint (getvert obj v);
if scrn_pos.x < left then left = scrn_pos.x;
if scrn_pos.x > right then right = scrn_pos.x;
if scrn_pos.y < top then top = scrn_pos.y;
if scrn_pos.y > bottom then bottom = scrn_pos.y;
)
-- convert from viewport coords to render coords
vp_size = getViewSize();
hscale = renderWidth/vp_size.x;
vscale = renderHeight/vp_size.y;
render_region = #(left * hscale,top * vscale,right * hscale,bottom * vscale);
-- render the region
render renderType:#region region:render_region vbf:true
)
Thanks for the max script example.
It’s useful to know how this works.
I will try it out.
I tried the “auto region selected” with an animated camera and it doesn’t refresh the region.
So the region stays at the postion of the frist frame.
So I have to write my own script.
I will try Klunks’s script example…
this thread might help to http://forums.cgsociety.org/showthread.php?f=98&t=977505&highlight=TransPoint
Thanks for the hint, Denis!
I will have a look at it if I find some spare time.