PDA

View Full Version : Smart way of retrieving the scene extents?


^Lele^
03-24-2009, 02:20 PM
It's a very minor issue, but i'd like to understand if i missed something in the maxscript help file.
The goal would be to retrieve the BBMin and Max for the whole scene, so to set a distance falloff material max value automagically.
I could simply iterate through the whole scene and grab the absolute min and max, but it's unpractical.
Or i could group the whole scene, grab the group BB and explode it, but it's pretty risky and i cannot safely go down that route.
Is there a third, better way to go about it?
Thanks in advance to anyone that may chime in and help :)

Bobo
03-24-2009, 02:41 PM
It's a very minor issue, but i'd like to understand if i missed something in the maxscript help file.
The goal would be to retrieve the BBMin and Max for the whole scene, so to set a distance falloff material max value automagically.
I could simply iterate through the whole scene and grab the absolute min and max, but it's unpractical.
Or i could group the whole scene, grab the group BB and explode it, but it's pretty risky and i cannot safely go down that route.
Is there a third, better way to go about it?
Thanks in advance to anyone that may chime in and help :)

Ciao!

AFAIK, Max is doing something like this internally when generating Shadow Maps with Relative Bias, but strangely enough there is no method exposed to MAXScript to get the scene bbox at once. You will have to iterate through the bounding boxes and collect the mins and maxes. You could put the Min.x, Min.y, Min.z, Max.x, Max.y, Max.z of each geometry object into a separate array and call amin() resp. amax() on each array to get the min value instead of performing IFs for each one of them, then build the two Point3s out of the results - have not tested it for speed, but it might be slightly faster.

OT - Carnegie's owner is asking us every day about an email from you. So am I. ;)

^Lele^
03-24-2009, 02:45 PM
Hey Bobo! :)

I haven't disappeared, i just took a good two weeks break, and am ramping up here in Germany ;)
Watch for a bugmail from me tonight :)

Thorsten just found out a very clever way: objects.min and objects.max works a charme.

As per usual, thanks for your invaluable help, I miss having you around bigtime :P

Zbuffer
03-24-2009, 02:47 PM
Hi,

I think you could select everything, and use $.min and $.max to get the sceneExtents

something like:
(
Allobjs=for o in objects collect o -- collects hidden objects too
select Allobjs
bMax=$.max
bMin=$.min
bCenter=$.center
clearselection()
b=box pos:[bCenter.x, bCenter.y, bMin.z]width:(bMax.x-bMin.x) length:(bMax.y-bMin.y) height:(bMax.z-bMin.z)
)


OOppps, too late ;)

Bobo
03-24-2009, 05:10 PM
Hey Bobo! :)

I haven't disappeared, i just took a good two weeks break, and am ramping up here in Germany ;)
Watch for a bugmail from me tonight :)

Thorsten just found out a very clever way: objects.min and objects.max works a charme.

As per usual, thanks for your invaluable help, I miss having you around bigtime :P

Wow, that is a cool approach, one never stops learning!
Say thanks to Thorsten from me!

instinct-vfx
03-24-2009, 05:45 PM
I gotta mark today in the calendar. This will be a first and a last

/me bows :D

Regards,
Thorsten

instinct-vfx
03-24-2009, 07:07 PM
After re-reading that it sounds strange...just to put that straight! I didnt mean that you dont say Thanks Bobo, but that i am rarely of use :P

Regards,
Thorsten

CGTalk Moderation
03-24-2009, 07:07 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.