Notifications
Clear all

[Closed] Smart way of retrieving the scene extents?

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

6 Replies

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.

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

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

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

I gotta mark today in the calendar. This will be a first and a last

/me bows

Regards,
Thorsten

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

Regards,
Thorsten