Bounding Box

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
watercolor
Posts: 12
Joined: Mon Feb 15, 2010 4:57 pm

Bounding Box

Post by watercolor »

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.
CuteAlien
Admin
Posts: 9661
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

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
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

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...

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);
Post Reply