bounding box does not appear

Problems building or running the engine, queries about how to use features etc.
Post Reply
wizumwalt
Gnoblar
Posts: 3
Joined: Sat Apr 27, 2019 11:06 pm

bounding box does not appear

Post by wizumwalt » Sat Jun 01, 2019 3:42 am

I'm using 2.1 on linux. I have a manual object, yet, when I show it, I can't seem to get the bounding box to appear. On my object, I make the following calls.

Code: Select all

    manObj._setBounds(Ogre::Aabb(Ogre::Vector3::ZERO, Ogre::Vector3::UNIT_SCALE));
    manObj._setBoundingSphereRadius(3.0);
Is there anything else I need to do to visualize the box? My mesh appears fine. Also, can anyone explain the _setBoundingSphereRadius call? Also, what should be appropriate values here?
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4066
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 228
Contact:

Re: bounding box does not appear

Post by dark_sylinc » Sat Jun 01, 2019 2:56 pm

Hi!

Those calls set the bounding box of the ManualObject, but it doesn't visualize the aabb.

To visualize AABBs, use WireAabb, like this:

Code: Select all

Ogre::WireAabb *wireAabb = sceneManager->createWireAabb();
wireAabb->track( manObj );

//Once you're done:
sceneManager->destroyWireAabb( wireAabb );
Cheers
Matias
0 x

rpgplayerrobin
Gremlin
Posts: 151
Joined: Wed Mar 18, 2009 3:03 am
x 16

Re: bounding box does not appear

Post by rpgplayerrobin » Sat Jun 01, 2019 6:51 pm

It is important to understand what the bounds do. They are used for culling the object when rendering it, and can also be used for ray intersection and other simple collision tests. It is never visible, it is just something under the hood.
The bounds SHOULD cover the whole mesh, not less and not more. Same with the bounding sphere radius. You can easily do this though by using the merge function in AxisAlignedBox and then just get the furthest away corner in that box to get the bounding sphere radius.
You want to set the bounds if they are not calculated automatically somehow in 2.1, otherwise you will have many problems such as the object disappearing when it is still visible on the screen (because the bounds are then not the same as the visual mesh is).
Also, can anyone explain the _setBoundingSphereRadius call? Also, what should be appropriate values here?
As I am using Ogre 1.11.2 I cannot be 100% sure about this, but it seems in my source it is only used for LOD. It might be used for something else in 2.1, the best way to see what it is used for in 2.1 is to just search the source code for getBoundingSphereRadius.
1 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4066
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 228
Contact:

Re: bounding box does not appear

Post by dark_sylinc » Sat Jun 01, 2019 7:12 pm

Regarding sphere radius, more info here.
0 x

wizumwalt
Gnoblar
Posts: 3
Joined: Sat Apr 27, 2019 11:06 pm

Re: bounding box does not appear

Post by wizumwalt » Sun Jun 02, 2019 8:56 pm

I have a few questions on bounding boxes.

Should there be one box for each mesh?

If I have two meshes, but only see one bounding box, could that mean that somehow the two meshes are really connected (I may have done it wrong when creating them) and therefore, there would only be one bounding box?

I may have misread this, but I thought in some post that I can't find, only one bounding box can be shown at a time?

In another mesh I made, I have a cube and was expecting a bounding box to be the same size as the cube, but the box is quite large and the cube takes up a small area in the center of the box. I was expecting the following to match the size of the cube but it does not.

obj._setBounds(Ogre::Aabb(Ogre::Vector3::ZERO,
Ogre::Vector3::UNIT_SCALE));
obj._setBoundingSphereRadius(1.0f);

Thoughts?
0 x

rpgplayerrobin
Gremlin
Posts: 151
Joined: Wed Mar 18, 2009 3:03 am
x 16

Re: bounding box does not appear

Post by rpgplayerrobin » Mon Jun 03, 2019 4:50 pm

Should there be one box for each mesh?
Yes.

If I have two meshes, but only see one bounding box, could that mean that somehow the two meshes are really connected (I may have done it wrong when creating them) and therefore, there would only be one bounding box?
It could mean that, or it might be that the rendering of the bounding box does not happen on the second one for some reason.
If you create two entities there should be two bounding boxes (but if they are instanced and batched together, the answer might be different).

I may have misread this, but I thought in some post that I can't find, only one bounding box can be shown at a time?
If that is the case, then that would be very bad design. I use my own manager to render bounding boxes of objects, which I posted the code of in point 17: viewtopic.php?f=25&t=92538
However, note that this is using Ogre 2.0 so it might need some changes for it to work on 2.1.

In another mesh I made, I have a cube and was expecting a bounding box to be the same size as the cube, but the box is quite large and the cube takes up a small area in the center of the box. I was expecting the following to match the size of the cube but it does not.
If I did not misread the link that God (dark_sylinc) posted, it seems that the bounds are half-size, which would mean that:
obj._setBounds(Ogre::Aabb(Ogre::Vector3::ZERO, Ogre::Vector3::UNIT_SCALE));
should in that case be:
obj._setBounds(Ogre::Aabb(Ogre::Vector3::ZERO, Ogre::Vector3::UNIT_SCALE * 0.5f));
0 x

Post Reply