Page 1 of 1

Rotated node + bounding box issues...

Posted: Fri May 15, 2009 10:33 am
by teamAlpha
Hey :lol: !...

I have noticed something interesting...

When you rotate an object too much , the bounding box gets extremely big , resulting in bad collision tests.

And my question , is :

Is there any way to make the bounding box to have the exact scale/position of the node when its rotated?.

Posted: Fri May 15, 2009 12:00 pm
by B@z
maybe getTransformedBoundingBox? xD

Posted: Sat May 16, 2009 3:13 am
by vitek
Actually, the problem is most likely that you are rendering the bounding box incorrectly. If the box changes shape or size when you rotate the node, then you are rendering the bounding box in world space. It sounds like you're expecting to see the bounding box in object space.

If you use node->setDebugDataVisible(scene::EDS_BBOX), it should show the object space bounding box. The other option would be to render the box like this...

Code: Select all

const core::matrix4 mat = node->getAbsoluteTransformation();
driver->setTransform (video::ETS_WORLD, mat);

video::SMaterial mtl;
mtl.Lighting = false;
driver->setMaterial (mtl);

const core::aabbox3df box = node->getBoundingBox();
driver->draw3DBox(box, color);
I actually posted some example code to show the different boxes here a long time ago. I'm pretty sure that the matrix4::transformBox() implementation has changed, so you may see the same box for two of the functions now, but the code should be simple enough to show what is going on.

Travis

Posted: Sun May 17, 2009 3:33 pm
by teamAlpha
vitek wrote:Actually, the problem is most likely that you are rendering the bounding box incorrectly. If the box changes shape or size when you rotate the node, then you are rendering the bounding box in world space. It sounds like you're expecting to see the bounding box in object space.

If you use node->setDebugDataVisible(scene::EDS_BBOX), it should show the object space bounding box. The other option would be to render the box like this...

Code: Select all

const core::matrix4 mat = node->getAbsoluteTransformation();
driver->setTransform (video::ETS_WORLD, mat);

video::SMaterial mtl;
mtl.Lighting = false;
driver->setMaterial (mtl);

const core::aabbox3df box = node->getBoundingBox();
driver->draw3DBox(box, color);
I actually posted some example code to show the different boxes here a long time ago. I'm pretty sure that the matrix4::transformBox() implementation has changed, so you may see the same box for two of the functions now, but the code should be simple enough to show what is going on.

Travis
Thanks for your help , it finally works as it should!