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
Thanks in advance!
Edit: I may have found what I was looking for regarding AABB, does this look correct?
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.
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.