ShapeBlueprints and AABB

dbrock

18-12-2007 05:25:00

Let's say our modeler created a mesh called "Crate.mesh" and I'm not sure what the dimensions of it are in 3DSMax.

When selecting which collision shape to use (an NxOgre::CubeShape in this situation), we need to specify it's sizing information.

Should I be passing in the bounding box information from the entity? Or the scaling information from the Scene Node.

If it's the bounding box information, does anyone happen to know where I can get a quick start on getting AABB information from an entity, and converting it to legible information such as length, width, height, radius, etc.

This will be for my PropManager, and Prop class which load information from an xml file, and create the shape based on the <prop name="crate" mesh="crate.mesh" scale="1 1 1" pos="0 0 0" ori="0 0 0" shape="cube"/> setting for example.

Thanks in advance!

Edit: I may have found what I was looking for regarding AABB, does this look correct?
Ogre::Entity *propEntity = sceneMgr->createEntity( "entity", propMeshFile );
Ogre::SceneNode *propEntityNode = sceneMgr->getRootSceneNode()->createChildSceneNode( "entity" );
Ogre::SceneNode *propModelNode = propEntityNode->createChildSceneNode( "entity_model" );

propModelNode->attachObject( propEntity );
propEntityNode->setScale( propScale );

Ogre::AxisAlignedBox propAAB = propModelNode->getAttachedObject( "entity" )->getBoundingBox();
Ogre::Vector3 min = ( propAAB.getMinimum() * propEntityNode->getScale() );
Ogre::Vector3 max = ( propAAB.getMaximum() * propEntityNode->getScale() );
Ogre::Vector3 center = ( propAAB.getCenter() * propEntityNode->getScale() );

Ogre::Vector3 propSize( fabs( max.x - min.x), fabs( max.y - min.y), fabs( max.z - min.z ) );
Ogre::Real propRadius = ( propSize.x > propSize.z ) ? propSize.z / 2.0f : propSize.x / 2.0f;


If it is, then I should be able to pass propShape.x for length, propShape.y for height, and propShape.z for width to fill in the CubeShape, and pretty much every other shape now that I have a radius as well.

luis

18-12-2007 09:12:18

If it's the bounding box information, does anyone happen to know where I can get a quick start on getting AABB information from an entity, and converting it to legible information such as length, width, height, radius, etc.
I'm using EntityInformer class from OgreOde to do it, and it works perfect ;)

dbrock

18-12-2007 09:15:28

Any examples? :)

luis

18-12-2007 09:47:27

Go and open EntityInformer.h and see the interface first ;)
then read this:

// visuals and collision primitive dimensions
Entity *bodyEntity = sm->createEntity( mName + "_bodyEntity", meshFile );
bodyEntity->setNormaliseNormals(true);
bodyEntity->setCastShadows(true);
SceneNode* node = sm->getRootSceneNode()->createChildSceneNode( mName + "_bodySceneNode" );
node->attachObject( bodyEntity );
EntityInformer ei( bodyEntity,Matrix4::getScale( node->getScale() ) );
Vector3 dimentions = ei.getSize();

dbrock

18-12-2007 23:26:32

Awesome! Thanks

I'm still failing @ getting CubeShape/SphereShape/CapsuleShape to work in my world, they act all funny, and I know it's because the settings they're receiving must be off, because in the visual debugger, the shapes are off =).

But for a demo, ConvexShape will suffice since they haven't failed me yet.

I think perhaps a tutorial on creating a Table from 3dsmax, to exporting the mesh, to bringing it into your physics world would be a sweet tutorial to get you started on just about any shape after that.