Bounding Box
-
- Posts: 12
- Joined: Mon Feb 15, 2010 4:57 pm
Bounding Box
I want to get object-aligned bounding box for a scene node, for example, if I rotate a cube, I want bounding box rotate same way too,so it is not axis aligned anymore, how do I get this bounding box? thanks.
With ISceneNode::getTransformedBoundingBox ().
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
If you want an object space bounding box, you want ISceneNode::getBoundingBox(). If you use ISceneNode::getTransformedBoundingBox() you'll get a box that is aligned to the world space coordinate system which makes it larger than necessary when the object is rotated.
If you want to render the object space bounding box, you'd write...
If you want to render the object space bounding box, you'd write...
Code: Select all
const core::matrix4 matrix = node->getAbsoluteTransformation();
driver->setTransform(video::ETS_WORLD, matrix);
video::SMaterial material;
material.Lighting = false;
driver->setMaterial(material);
const core::aabbox3df box = node->getBoundingBox();
driver->draw3DBox(box);