View Full Version : SoResetTransform vs resetPath for Bounding Box
artmansoft
04-27-2010, 06:41 AM
Dear friends,
I have a node in my sceneGraph which I don't like to be involved in the calculation of the bounding box.
First, I tried to use a SoResetTransform with the value of whatToReset set to BBOX after the mentioned node, but when I use SoGetBoundingBoxAction, its result is the same as the sceneGraph without SoResetTransform node!
Second, I omitted the SoResetTransform node and instead used a reset path for the SoGetBoundingBoxAction by creating a path (resetPath) and appending the mentioned node and then setting SoGetBoundingBoxAction.setResetPath( resetPath, False ). It works fine with this method!
I have too many calls of SoGetBoundingBoxAction and cannot change all of them to have a reset path. Is there any way to reset it using SoResetTransform or any other method?
Thanks,
artmansoft
mikeheck
04-28-2010, 03:31 AM
I have too many calls of SoGetBoundingBoxAction and cannot change all of them to have a reset path. Is there any way to reset it using SoResetTransform or any other method?
I'm pretty sure that SoResetTransform works. Take a look at the 2D annotation example here:
http://www.mc3dviz.com/openinventor-forum/showthread.php?t=20
-Mike
artmansoft
04-28-2010, 05:03 AM
It may work for 2d annotations, but it does not work on my model. My new sceneGraph is something like:
DEF root Separator {
Transfrom {
# transform data
}
ResetTransform {
whatToReset BBOX
}
# the main model comes after this...
}
Is anything wrong? Do you have any idea?
mikeheck
04-28-2010, 05:34 AM
It may work for 2d annotations, but it does not work on my model.
I don't understand your scene graph. Where you put the ResetTransform node, there is nothing to reset...
In other words, since no geometry has been traversed yet, the scene bounding box is still empty.
Try putting the ResetTransform under a Separator, but after the geometry whose extent (bounding box) you want to ignore.
For example:
DEF root Separator {
DEF scene Separator {
# Geometry that should affect the scene bounding box
}
DEF annotation Separator {
# Geometry that should NOT affect the scene bounding box
ResetTransform {
whatToReset BBOX
}
}
}
}
-Mike
artmansoft
04-28-2010, 06:17 AM
I want to ignore the effect of the Transform node (the first node) on bounding box computation. What can I do?
Thanks,
artmnansoft
artmansoft
05-09-2010, 04:59 AM
Any new idea?
mikeheck
05-09-2010, 10:53 PM
I want to ignore the effect of the Transform node (the first node) on bounding box computation. What can I do?
Sorry, I misunderstood the question. In fact I understand what you want to do now, but I'm still not sure why... :-) If you apply the transform to the geometry for rendering, but compute the bounding box using UNtransformed geometry, the bounding box will be incorrect, right? ...
Using SoResetTransform you can reset the current transform (meaning it will not have any effect on rendering or bbox) or reset the current bounding box. It does not allow resetting the transform only for certain kinds of actions, e.g. only for GetBoundingBoxAction. It is of course possible to do this using an SoCallback node, but...
You can easily work around this using OIV 8.0 or newer. Just use an SoBBox node to set the bounding box to whatever you want. The GetBoundingBoxAction will use the values in this node and ignore the actual transforms/geometry.
Using an older version of OIV there is an ugly hack :-) that has the same effect. Use an SoResetTransform to "hide" the actual bounding box of the geometry (e.g. as the last child of the Separator that contains the geometry). And use an invisible SoCube to define the desired bounding box. (See SoDrawStyle::style to make geometry invisible.)
-Mike
artmansoft
05-10-2010, 04:05 AM
Thanks for the reply.
I cannot put the invisible cube in the Separator containing the geometry. So, where should I put the invisible cube?
Thanks,
artmansoft
mikeheck
05-10-2010, 04:19 AM
I cannot put the invisible cube in the Separator containing the geometry. So, where should I put the invisible cube?
I would put it under its own separator. Perhaps like this modification of the scene graph you proposed in a previous post:
DEF root Separator {
DEF BBox_Sep Separator {
DrawStyle { style INVISIBLE }
Cube { width ? height ? depth ? }
}
Transform { # transform data }
DEF Model_Sep {
# the main model...
ResetTransform { whatToReset BBOX }
}
}
artmansoft
05-10-2010, 05:42 AM
OK. Thanks a lot for the reply. I'll give it a shot.
artmansoft
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.