Hey !...
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?.
Rotated node + bounding box issues...
Rotated node + bounding box issues...
Alpha::AppleBoy
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...
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
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);
Travis
Thanks for your help , it finally works as it should!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...
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.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);
Travis
Alpha::AppleBoy