Very wierd bug

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 09 September 2005   #1
Very wierd bug

In trying to get the dimensions of the bounding box of an object, I'm getting a very wierd error...

First of all, there doesn't seem to be a function built in to get this. The only way I see is to use getModContextBBoxMin and getModContextBBoxMax, which give the min and max corners of the bounding box given a modifier for context.

So, I must first add a modifier to the object -- any modifier, it doesn't matter which.

Then, for each of the 3 dimensions, I compute the difference between the max and min.

Finally, I delete the modifier.

Here's the strange issue...

If I run the function on an object that ALREADY HAS a modifier attached, it works.

If the object does not have a modifier, I add a modifier....but it doesn't work. If I run it again, it will work the next time though.

Now, perhaps you are thinking that after I add the modifier, there is not enough time for Max to actually setup the modifier before the code that uses it is run? So, I put it in a loop to wait for several seconds inbetween -- same results!??

This has got to be the wierdest bug ever...


function getBoundingBox o =
 (
 deleteFlag = false
  
 if (o.modifiers.count == 0) do
 (
	deleteFlag = true
	addModifier o (Bend()) --add temp modifier for the calc
 )
  
 
xdim = ceil (abs(((getModContextBBoxMin o o.modifiers[o.modifiers.count] - getModContextBBoxMax o o.modifiers[o.modifiers.count]) as point3).x))
 
ydim = ceil (abs(((getModContextBBoxMin o o.modifiers[o.modifiers.count] - getModContextBBoxMax o o.modifiers[o.modifiers.count]) as point3).y))
 
zdim = ceil (abs(((getModContextBBoxMin o o.modifiers[o.modifiers.count] - getModContextBBoxMax o o.modifiers[o.modifiers.count]) as point3).z))
 
 
if (deleteFlag == true) then
 deleteModifier o o.modifiers[1]
  
[ydim, xdim, zdim]
 
)


 
Old 09 September 2005   #2
Stuh505

I'm not sure what your bug is but if you want the bounding box of an object it is as simple as:


$.max-$.min


maybe I missed something = >

Josh.
__________________
www.joshuanewman.net
 
Old 09 September 2005   #3
$object.min and $object.max get's the minimum and maximum points of the object's bounding box.

Note that these are the points of an Axis Aligned bounding box and not an Object Aligned bounding box.

Edit: jman beat me to it, sorry for the double post.
__________________
||||| www.wahooney.net |||||
Head Towards the Light

Learning to use Blender3d
 
Old 09 September 2005   #4
thanks a lot!
 
Old 01 January 2006   #5
Hi Stuh, i was searching for some stuff about bounding box and stumbled on a explanation by Bobo on what was happening to you when trying to get modifier's bounding box. Here is the link, look towards the bottom:
http://forums.cgsociety.org/showthr...ht=bounding+box
__________________
Frustration free tools to make artists feel like artists again
http://www.75ive.com/tools


 
Old 01 January 2006   #6
Originally Posted by stuh505: In trying to get the dimensions of the bounding box of an object, I'm getting a very wierd error...

First of all, there doesn't seem to be a function built in to get this. The only way I see is to use getModContextBBoxMin and getModContextBBoxMax, which give the min and max corners of the bounding box given a modifier for context.

So, I must first add a modifier to the object -- any modifier, it doesn't matter which.

Then, for each of the 3 dimensions, I compute the difference between the max and min.

Finally, I delete the modifier.

Here's the strange issue...

If I run the function on an object that ALREADY HAS a modifier attached, it works.

If the object does not have a modifier, I add a modifier....but it doesn't work. If I run it again, it will work the next time though.

Now, perhaps you are thinking that after I add the modifier, there is not enough time for Max to actually setup the modifier before the code that uses it is run? So, I put it in a loop to wait for several seconds inbetween -- same results!??

This has got to be the wierdest bug ever...


When you add the modifier and read the data, the modifier stack has not been updated yet and the gizmo of the modifier does not "know" the size of the object.
You have to force an internal refresh of the modifier stack. The simplest and fastest way to do this is to call CLASSOF o before reading the bbox. Since Classof tries to return the class ON TOP of the modifier stack, it triggers an internal reevaluation of the stack where necessary and the gizmo gets its correct size. Then you delete the modifier as usual...
 
Old 01 January 2006   #7
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:16 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.