hitwangxiaolu
15-11-2010 06:52:56
I ran into a problem,plz help me if you know .
as you see above ,it`s for creating a new body when you right click a body existed.
So I shoud know the name to decide whether to create or not.How can i create a body that have a wanted entity `s name.
[code]bool shiyan3D::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
{
CEGUI::System::getSingleton().injectMouseButtonDown(convertButton(id));
if (id == OIS::MB_Left)
{
CEGUI::MouseCursor::getSingleton().hide();
mLMouseDown = true;
}
else if (id == OIS::MB_Right)
{
// 打开包围盒
/*if (selectedbody)
selectedbody->showBoundingBox(false);*/
// Setup the ray scene query, use CEGUI's mouse position
CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition();
Ogre::Ray mouseRay = mCamera->getCameraToViewportRay(mousePos.d_x/float(arg.state.width), mousePos.d_y/float(arg.state.height));
mRaySceneQuery->setRay(mouseRay);
mRaySceneQuery->setSortByDistance(true);
// Execute query
Ogre::RaySceneQueryResult &result = mRaySceneQuery->execute();
Ogre::RaySceneQueryResult::iterator itr;
// Get results, create a node/entity on the position
for ( itr = result.begin(); itr != result.end(); itr++ )
{
if (itr->movable && itr->movable->getName().substr(0, 6) != "Ground" && itr->movable->getName().substr(0,8) != "UbotLink")
{
//添加函数获得ID
itr->movable->getParentSceneNode()->showBoundingBox(true);
Critter::Body* mCube = mRenderSystem->createBody(NxOgre::BoxDescription(1, 1, 1), NxOgre::Vec3(mCamera->getPosition().x,
mCamera->getPosition().y, mCamera->getPosition().z), "cube.1m.mesh");
break;
} // if
} // for
}
return true;
}[/code]
as you see above ,it`s for creating a new body when you right click a body existed.
So I shoud know the name to decide whether to create or not.How can i create a body that have a wanted entity `s name.