Drawing BoundingBox

Hello,



I want to draw model bounds boundingBox around my object myObject. BoundingVolumes are not geometries, they only seem to be abstract descriptions for geometrical volumes or surfaces. So, I created a boundingBoxGeometry too.



I use a controler to draw the boundingBoxGeometry around my object myObject within the render method



[java]

@Override

public void render(RenderManager renderManager, ViewPort viewPort) {

boundingBoxGeometry.setLocalTransform(myObject.getWorldTransform());

renderManager.renderGeometry(boundingBoxGeometry);

}

[/java]



Everything works quite well, as long as myObject is on (0,0,0) position. If myObject moves, I have to update the position of the boundingBoxGeometry too. First I thought, I could simple use the setLocalTranslation method like shown above in the code. It seems as if the renderGeometry method ignores the position of boundingBoxGeometry. Is this correct?



Thanks.



Regards,

Equi

Ok, sorry. Solved the problem already…



[java]

@Override

public void update(float f) {

boundingBoxGeometry.setLocalTransform(myObject.getWorldTransform());

boundingBoxGeometry.updateGeometricState();

}



@Override

public void render(RenderManager rm, ViewPort vp) {

rm.renderGeometry(boundingBoxGeometry);

}

[/java]



Now I also know how I will implement selection highlighting.



Regards,

Equi

So if you transform your (a) Geometry, do you need to transform it’s boundingBox too?

Not per se, he uses anther geometry to outline the bounding box, thats why he has to update its position.

Indeed, I do not have to transform it. Once updated, everything else follows. Everything works perfect now.

You can watch a video if you are interessted…



http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/video-of-my-editor/



regards,

Equi