steph31
08-11-2009 15:24:04
Hello, I have a question concerning Rayscenequery and PLSM , is possible to select an entity with mouse ?
To note that the selection works very well when I work with a 'classic' scenemanager but with the scenemanager of PLSM it don't work.
code for mousepick :
Thank you in advance.
(sorry for english, i'm french... lol )
To note that the selection works very well when I work with a 'classic' scenemanager but with the scenemanager of PLSM it don't work.
code for mousepick :
RaySceneQuery *mRay_Selection_Perso = mSceneMgr->createRayQuery(Ray());
const Real clickX = static_cast <Real> (arg.state.X.abs/float(arg.state.width));
const Real clickY = static_cast <Real> (arg.state.Y.abs/float(arg.state.height));
Ray mouseRay = mCamera->getCameraToViewportRay(clickX, clickY);
mouseRay.setDirection(Vector3::UNIT_Y);
mRay_Selection_Perso->setQueryMask(QueryFlags::ENTITY_MASK);
mRay_Selection_Perso->setRay(mouseRay);
mRay_Selection_Perso->setSortByDistance(true);
mRay_Selection_Perso->execute();
RaySceneQueryResult &result = mRay_Selection_Perso->getLastResults();
RaySceneQueryResult::iterator itr;
for (itr = result.begin(); itr != result.end(); itr++)
{
if (itr->movable)
{
MessageBoxA(NULL,itr->movable->getName().c_str(), Utilitaires::toString(itr->distance).c_str(), MB_OK);
mCurrentObject = itr->movable->getParentSceneNode();
if (mCurrentObject) mCurrentObject->showBoundingBox(true);
break;
}
else if (itr->worldFragment)
{
}
}
Thank you in advance.
(sorry for english, i'm french... lol )