Bounding box position not updating?

I have a BoundingBox around an object and I’m drawing it graphically. When I drag the object around, the BoundingBox moves with the object. However, when I System.out.println(the bounding box), the lower and upper corner point locations never seem to change. Are those points’ coordinates relative to the center of the object? How do I get the corner’s positions relative to the axes?

–DAT

Your object probably sits below a TransformGroup in the scenegraph and movement is accomplished by changing the transform in the TransformGroup rather than changing the coordinates of your object.

All coordinates related to your object, including ones in other objects below your object in the scenegraph hierarchy, are relative to the TransformGroup’s coordinate system. When you move your object, you are really just changing the location of the TransformGroup’s coordinate system relative to the world coordinate system (at the top of the Java3D scenegraph). However, the relation that your object’s coordinates have to TransformGroup’s coordinate system stays the same which is why the coordinates of the boxes won’t change.

You can think of your box as an object that lies in the trunk of a moving car. Its position relative to the car stays the same, but its position relative to the road changes as the car moves.

You can call the getLocalToVWorld method on your object to get a Transform3D that can transform your object’s coordinates into the world’s coordinate system.

Hi, thanks for clearing that up.

However, I am confused as to how about getting for instance the lower and upper corner Point3ds of a bounding box in the virtual coordinate system.

For instance, if I had something like:


boundingBox = new BoundingBox();
someSphere.setBoundsAutoCompute(false);
someSphere.setBounds(boundingBox);
boundingBox.setLower(-3.0, -3.0, -3.0);
boundingBox.setUpper(3.0, 3.0, 3.0);
boundingBoxLeaf = new BoundingLeaf(boundingBox);
boundingBoxLeaf.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);

I would be able to get the position of the boundingBox by saying
Vector3d pos = new Vector3d();
Transform3D T3D = new Transform3D();
boundingBoxBorderLeaf.getLocalToVworld(T3D);
T3D.get(pos);

However, that only gives me the position of the bounding leaf’s center (correct me if I’m wrong)…how can I actually get the virtual world coordinate positions of the upper and lower corners of the bounding box within the bounding leaf?

I think you should be able to do it by first getting the lower and upper corners of the box as points using the proper methods in the BoundingBox class and then transforming those points using the localToVworld transform of the box.

Thanks, that worked!