Bounding Box Problem

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
emre2345
Posts: 37
Joined: Mon Jul 09, 2007 7:02 pm

Bounding Box Problem

Post by emre2345 »

I get the bounding box of IAnimatedMeshNode and send the edges to PhysX. But the dimensions of rendered image and Physx bounding box does not match. I must have divide the edges to 2 if i wanted to make physx bounding box with the same size of rendered image(sceneNodes bounding box). What can be the problem? Below you can see the code

Code: Select all

	roomMesh = smgr->getMesh("model/Oda.3ds");

	roomNode = smgr->addAnimatedMeshSceneNode(this->roomMesh, 0, -1, vector3df(0, 0, 0), vector3df(0, 0, 0), vector3df(1.0f, 1.0f, 1.0f));
        roomNode->setMaterialFlag(EMF_LIGHTING, false);
	roomNode->setMaterialTexture(0, drv->getTexture("model/Textured.jpg"));

	NxActorDesc actorDesc;
	NxBoxShapeDesc boxDesc;

	aabbox3d<f32> boundingBox = roomNode->getTransformedBoundingBox();
	vector3d<f32> roomEdges[8];
	boundingBox.getEdges(roomEdges);

	vector3d<f32> xDim = roomEdges[4] - roomEdges[0];
	vector3d<f32> zDim = roomEdges[2] - roomEdges[0];
	vector3d<f32> yDim = roomEdges[1] - roomEdges[0];

	boxDesc.dimensions.set(xDim.getLength() / 2, yDim.getLength() / 2, zDim.getLength() / 2);
	
	actorDesc.shapes.pushBack(&boxDesc);
	actorDesc.body = NULL;

	ActorRoom = gScene->createActor(actorDesc);

	ActorRoom->setGlobalPosition(NxVec3(0, 0, 10));
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Interesting... though i think i've come across a similar thing when using Physx outside of Irrlicht.

To be fair if it's as easy as dividing by 2 to get the right dimensions then there's no problem, just do that and remember you might have to do that to other things when comparing between the physical and graphical representations of your world.

The only thing i would think of was that you scaled your node and used getBoundingBox instead of getTransformedBoundingBox but that certainly doesn't seem to be the case here!
Image Image Image
emre2345
Posts: 37
Joined: Mon Jul 09, 2007 7:02 pm

Post by emre2345 »

Yes you' r rigth but there should not be any difference else there could be problems when the scene grows.

There possibilities can be:

1. Irrlicht gives the dimensions of bounding box wrong. But when i look my mesh in 3dsmax the dimensions seem to be right.

2. Irrlicht render the scene with a scale value.

3. Physx bounding boxes are drawed in wrong dimensions. Maybe in visual debugger of physx there can be a scale value.

or something else that i can not think:)
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

The PhysX documentation which you also possess as part of your SDK and which I have helpfully BOLDED for you, with no prior knowledge of PhysX but after taking 5 minutes to download it and about 30 seconds to search for NxBoxShape, click on the first search result, look at the pretty picture and read the text wrote: Boxes (class NxBoxShape) have a dimensions property. The elements of this vector are the volume's half width, half height and half depth.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
emre2345
Posts: 37
Joined: Mon Jul 09, 2007 7:02 pm

Post by emre2345 »

Thanx.
Post Reply