Rotated node + bounding box issues...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
teamAlpha
Posts: 68
Joined: Sun Mar 08, 2009 4:14 pm

Rotated node + bounding box issues...

Post 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?.
Alpha::AppleBoy
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

maybe getTransformedBoundingBox? xD
Image
Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
teamAlpha
Posts: 68
Joined: Sun Mar 08, 2009 4:14 pm

Post 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!
Alpha::AppleBoy
Post Reply