"Bounding box" position

s0lidnuts

02-08-2008 21:52:46

When the object gets selected, I'm showing the ogre node's bounding box, and creating a cube shape on it's physics body so that future Raycasts won't miss through the robot's legs for example. Here is the code:

//set current actor, creates cube shape for future raycasting, and show ogre's bounding box
m_CurrentActor = actor;
Ogre::SceneNode *node = m_SceneMgr->getSceneNode(actor->getName());
Ogre::AxisAlignedBox box = node->_getWorldAABB();
m_CurrentBBox = new NxOgre::Cube(box.getSize());
actor->addShape(dynamic_cast<NxOgre::Shape *>(m_CurrentBBox));
node->showBoundingBox(true);


but the cube gets added on the half of the body, so I need to add it with an offset of the size of half of the body. How to do this offset?

Mesh Cube
I
I............I
I............I
.............I

Thanks.

betajaen

02-08-2008 22:21:34

Use "offset/mLocalPose" in the shape params to offset the shape. BTW: You don't need that dynamic_cast there.

s0lidnuts

02-08-2008 22:22:16

Ok thanks =)
PS.: it was needed in the previous code =P but well.. still learning casts anyway =)