Issues with 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
scarecrow
Posts: 13
Joined: Mon Jun 19, 2006 5:57 pm

Issues with bounding Boxes

Post by scarecrow »

Hi, I already searched the forum but wasn't able to find a suitable answer:

When i use the boundingBox->getCenter() of a bounding box of a mesh,
I get strange results. The mesh is a simple circle. For indicating the center of the bounding box i set a billboard to the position returned by getCenter(), however its not in the middle of the circle but below it and not centered.

I tried to set the target of the camera to check if this is billboard specific but i got the same results : it pointed to a wrong position.

Can somebody help me?
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

Well since you searched the forums, you probably saw alot of people having issues with bounding boxe. I myself have never been able to get them to translate properly. They warp, and go completely off of where they should be, since I'm assuming you tested this by displaying the bounding boxes, you know this as well. :)

I remember seeing somewhere that hybrid had them working better, but they still don't work right.

I've come to completely ignore them as anything useful in Irrlicht until they're working 98% correctly.

On the other hand, you can use Newton for all of this and it works 98% correctly already. :)
Stout Beer
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There had been an error in Irrlicht 0.14 which has been fixed very soon after the release. right now only some animated mesh bounding boxes aren't correctly transformed (see the axe of the dwarf in mesh viewer example).
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

mmm.. Quick to jump on it hybrid eh?? I've only used Irrlicht 1.0 and have never had the bounding boxes work right after moving the node around, and using the get transformed bounding box method.

will setup a test right now and run it.

Image

Image

Hm. Well, thats not so horrible ?? What was my problem before.. So the getCenter should work right, but obviously, the bounding boxes still need some work :) Hybrid, these are static meshes.

When you use GetCenter() you should use it on the transformed bounding box, are you doing that?

It would be like this:

Code: Select all

		irr::core::aabbox3d<f32> box = Node->getTransformedBoundingBox();
		vector3d<f32> center = box.getCenter();
Otherwise, I can see how the center wouldn't line up.
Stout Beer
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It looks like you are rendering the bounding box yourself. If so, when rendering the bounding box, you want to make sure that you've set the correct world transform. You might just try to use setDebugDataVisible(true) also. It should be applying the correct transform.
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

Wow. I was about to get really really pissed off. Before, when I tried debugdatavisible, it always crashed, leaving me to believe it was not implemented in alot of scene nodes. But now, for some fee'd up reason its absolutely working correctly.

But also, does this mean when you want to get a useful aabbox you must use the world transform on it? Because I have not seen that explained anywhere that it must be done - Although, I have seen it done before without any explanation as to why.

Also I still think debugdatavisible isn't implemented in alot of nodes. Am I wrong?
Stout Beer
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yeah, the debug data is only enabled for some scene nodes.

All bounding boxes are useful, you just need to know which coordinate space they are in. If you are going to render a box, you need to set the appropriate world matrix before you render it, otherwise you'll get some weird results.

The following snips of code would draw the bounding box for a scene node. You will see a different bounding box depending on which one you use.

Code: Select all

Driver->setMaterial(video::SMaterial());

// box is in world coordinates, so local to world transform is identity matrix
Device->setTransform(video::ETS_WORLD, core::matrix());
Driver->draw3DBox(node->getTransformedBoundingBox(), video::SColor(255, 0, 192, 192));

Code: Select all

Driver->setMaterial(video::SMaterial());

// box is in object coordinates, so we must apply local to world transform
Driver->setTransform(video::ETS_WORLD, node->getAbsoluteTransformation()); 
Driver->draw3DBox(node->getBoundingBox(), video::SColor(255, 0, 192, 192));
Travis
Last edited by vitek on Sun Nov 19, 2006 3:50 pm, edited 1 time in total.
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

Ahhh. That is so much better! Thank you.
Stout Beer
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

So what about Irrlicht now :?: :D
Mikenoworth
Posts: 78
Joined: Sat May 27, 2006 9:24 pm
Location: Logan, UT

Post by Mikenoworth »

Hahaha, I've always liked Irrlicht, I'll never stop using it. But yeah, I did doubt the bounding boxes, and for that I am ashamed.


.. :D
Stout Beer
Post Reply