Display custom bounding boxes

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
Dr_Asik
Posts: 18
Joined: Wed Jun 02, 2010 2:15 am

Display custom bounding boxes

Post by Dr_Asik »

Hi,

I have created some custom bounding boxes (aabbox3df) based on some calculations on the geometry. Now I'd like to verify that they are correct by displaying them. I know that you can do:

Code: Select all

node->setDebugDataVisible(scene::EDS_BBOX);
to show a model's bounding box, but here it's not a model's bounding box, it's just some bounding boxes I've created myself and stored in a std::vector somewhere, which are not attached to any particular model.

Thanks for the help.
Dr_Asik
Posts: 18
Joined: Wed Jun 02, 2010 2:15 am

Post by Dr_Asik »

Nvm, found it (m_driver->draw3DBox()).

Now I have a weird problem. My nodes are set with no parent. I therefore assume getPosition() returns their absolute position, since having no parent == having 0,0,0 as the reference position, if I am not mistaken.

Now when I draw them, my bounding boxes appear to be translated by a certain amount compared to the shapes they are supposed to be laying upon, as if there was a delta in positions. I got the shape's position by using their getPosition() and basically used that to place the bounding boxes. What could be wrong?
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Post by blAaarg »

Pretty much all draw*() operations are done by the video device using whatever transformation was last used by the card.

IGUIEnvironment::drawAll () and ISceneManager::drawAll () set video device states for you before all the different draw operations they, then, call to the IVideoDevice. The other draw operations, however, call directly to the IVideoDevice but don't (re)set the state first. So, you may need to reset the transformations before calling draw3dBox().

According to the API:
virtual void irr::video::IVideoDriver::draw3DBox ( ...)

This method simply calls draw3DLine for the edges of the box. Note that the box is drawn using the current transformation matrix and material. So if you need to draw it independently of the current transformation, use

driver->setMaterial(someMaterial);
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);

for some properly set up material before drawing the box.
Whatever ISceneManager::setPosition/Rotation/Scale operations you call won't be used by the IVideoDevice when using IVideoDevice::draw*() operations. They're ignored by the video device.
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The code I posted in this thread shows three different ways to draw a node bounding box.

Travis
Post Reply