Boundin 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
sader
Posts: 28
Joined: Sat Sep 29, 2007 1:38 pm

Boundin box

Post by sader »

Not sure how update bounding boxes so that it would be roteted scaled and positioned right. Is it possible overall?

Couldn't find function in aabbox3d class or ISceneNode

I am drawing box like this

Code: Select all

g_Driver->draw3DBox(Node->getTransformedBoundingBox());
and this is what I get

correct
wrong
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Why not just enabling the debug mode to draw bbox? But for drawing a 3d box you will have to set a proper material and projection matrix to avoid interference with former draw calls.
sader
Posts: 28
Joined: Sat Sep 29, 2007 1:38 pm

Post by sader »

Cool :)

I enabled debug mode for my node and it looks is everything fine :) but anyway interesting why draw method doesn't draw box like it should
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The problem is that the transformed bounding box from getTransformedBoundingBox() is wrong when a scene node is rotated. It is very efficient compared with the correct method, but it is still wrong. I have commented on this many times.

http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=94967

Here is an image that illustrates the different bounding boxes that you can get for a single rotated cube.The green one is axis aligned in object space, the red one is axis aligned in world space. The blue one is just wrong as it doesn't even enclose the entire object. Once you have the incorrectly transformed bounding box from getTransformedBoundingBox(), there is no way to get something useful out of it without undoing the bad transform [which would be silly].

Image

If you want the correct world space bounding box, try the following.

Code: Select all

core::aabbox3df box = Node->getBoundingBox();
Node->getAbsoluteTransformation().transformBoxEx(box);
If you just want to render the meshes bounding box, it is easier to use the debug mode flag as suggested by hybrid [assuming you want to use that color].

Travis
sader
Posts: 28
Joined: Sat Sep 29, 2007 1:38 pm

Post by sader »

that very good explanation :)
but then goes question is this function getTransformedBoundingBox() usefull somehow/somewhere
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If you know absolutely that the object is aligned with the world axes, then it gets the same results as calling transformBoxEx(), except that it is more efficient. I don't believe that is a very good reason to keep it. Other than that I haven't really found a good reason for it to exist. Maybe someone could provide a reason.

Travis
Post Reply