Bounding Box Size Incorrect

Problems building or running the engine, queries about how to use features etc.
User avatar
Mr_Ridd
Goblin
Posts: 297
Joined: Fri Jun 04, 2004 10:01 pm
Location: South Africa
x 1

Bounding Box Size Incorrect

Post by Mr_Ridd »

Hi

I am busy implementing OgreNewt and I came across a bounding box issue.

I created a scenenode and showed the bounding box and the size of the bb was quite a bit greater than the actual mesh. The size also got worse as the scenenode moved.

To test I put two tests together and I got the following results. The two nodes in the image are straight OGRE nodes with no physics.

Image

The code is as follows:

Code: Select all

SceneNode* n1 = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		Entity* e1 = mSceneMgr->createEntity("sadas1", "crate.mesh");
		e1->setNormaliseNormals(true);
		n1->attachObject(e1);
		n1->setPosition(Vector3(1300, 350, 1300));
		n1->showBoundingBox(true);

		n = mSceneMgr->getRootSceneNode()->createChildSceneNode();
		Entity* e = mSceneMgr->createEntity("sadas", "crate.mesh");
		e->setNormaliseNormals(true);
		n->attachObject(e);
		n->setPosition(Vector3(1280, 350, 1300));
		n->showBoundingBox(true);
The second mesh is rotating.

As you can imagine this gives horrible results when applying physics as the objects elevate off the ground. Are there any fixes for this or is this a bug?

The meshes are from the OgreNewt demos.

Thanks
The ability to succeed is the ability to adapt
Van
Hobgoblin
Posts: 512
Joined: Fri Nov 19, 2004 3:56 am

Post by Van »

You will need to confirm this but I recall that the bounding box is the actuall bounds of the Entity and does NOT take into account the scene node scale.

This was a bug in OgreNewt I thought was corrected. In all cases, the itteration through the ogre entity should be multiplied by the scene node scale to yield the correct collision mesh.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8

Post by haffax »

Not a bug. This is a padding in the Mesh's AABB. You can set the padding factor to 1.0 prior to loading your meshes using MeshManager::setBoundsPaddingFactor.

Also note, that the bounding box is axis aligned, so if the mesh is not parallel to the world's main axes, the box grows, so that all fits still in. This is what happens with your second box.
The reason for this is, that an axis aligned box is *much* faster to operate with compared to an oriented bounding box.

This only applies to the box in Ogre. Newton's box collision is oriented and behaves as wanted.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine

Post by yuriythebest »

in your 3d program try setting the pivot point to the exact center of thje mesh
User avatar
Mr_Ridd
Goblin
Posts: 297
Joined: Fri Jun 04, 2004 10:01 pm
Location: South Africa
x 1

Post by Mr_Ridd »

Thanks a lot guys, helps me a lot.
The ability to succeed is the ability to adapt
User avatar
Mr_Ridd
Goblin
Posts: 297
Joined: Fri Jun 04, 2004 10:01 pm
Location: South Africa
x 1

Post by Mr_Ridd »

I tried to set the padding to 1 and that make the bounds even bigger, setting it to 0 put it back to the way it was originally.

Is there something I'm doing wrong?

Code: Select all

MeshManager::getSingleton().setBoundsPaddingFactor(0.0);
The ability to succeed is the ability to adapt
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine

Post by yuriythebest »

just a wild guess but have you tried setting it to a negative amount- hopefully that will not give an error.
lewap
Gnoblar
Posts: 13
Joined: Wed Oct 25, 2006 12:40 pm

Post by lewap »

setBoundsPaddingFactor - add a given value not multiply.

But I have the same problem with bounding boxes. Does anybody found a solution ?