3D Picking (Not Picking)
Posted: Sun Feb 13, 2005 9:49 pm
I am having and issue where my picking routine is not picking an entity I have in my scene. basically it is just a scenen with a single mesh (ninja) and a mouse cursor thanks to CEGUI. I do not get any errors at all just no pick when the mouse is over the mesh in the rendering window ?? please find snippets below:
void Pick(Real MouseX,Real MouseY,Camera* mCamera,SceneManager* mSceneMgr)
{
// Start a new ray query
Ray cameraRay = mCamera->getCameraToViewportRay( MouseX, MouseY );
RaySceneQuery *raySceneQuery = mSceneMgr->createRayQuery( cameraRay );
raySceneQuery->setSortByDistance(true,1);
RaySceneQueryResult& result = raySceneQuery->execute();
MovableObject *mCurrMO = NULL;
RaySceneQueryResult::iterator it = result.begin();
std::list< RaySceneQueryResultEntry >::iterator rayIterator;
if (it != result.end())
{
mCurrMO = it->movable;
}
else
{
mCurrMO = NULL;
}
raySceneQuery->clearResults( );
mSceneMgr->destroyQuery( raySceneQuery );
}
Now MouseX and MouseY are just "e->getRelX()" and "e->getRelY()" passed from my mouse listener.
I have tried both ST_GENERIC and ST_EXTERIOR_FAR without success.
My model is just added to the scenen in my create scene function...
void GameApplication::createScene()
{
mModel = mSceneMgr->createEntity("TestModel","ninja.mesh");
mModelNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mModelNode->attachObject(mModel);
mSceneMgr->setAmbientLight(ColourValue(0.5,0.5,0.5));
}
As hopefully you can see... nothing much extravegant going on here just a simple mesh and trying to get a mouseover type effect... just can't pick it...
To test I set a break point at "mCurrMO = it->movable;" and it NEVER gets called... the result list is always empty.
void Pick(Real MouseX,Real MouseY,Camera* mCamera,SceneManager* mSceneMgr)
{
// Start a new ray query
Ray cameraRay = mCamera->getCameraToViewportRay( MouseX, MouseY );
RaySceneQuery *raySceneQuery = mSceneMgr->createRayQuery( cameraRay );
raySceneQuery->setSortByDistance(true,1);
RaySceneQueryResult& result = raySceneQuery->execute();
MovableObject *mCurrMO = NULL;
RaySceneQueryResult::iterator it = result.begin();
std::list< RaySceneQueryResultEntry >::iterator rayIterator;
if (it != result.end())
{
mCurrMO = it->movable;
}
else
{
mCurrMO = NULL;
}
raySceneQuery->clearResults( );
mSceneMgr->destroyQuery( raySceneQuery );
}
Now MouseX and MouseY are just "e->getRelX()" and "e->getRelY()" passed from my mouse listener.
I have tried both ST_GENERIC and ST_EXTERIOR_FAR without success.
My model is just added to the scenen in my create scene function...
void GameApplication::createScene()
{
mModel = mSceneMgr->createEntity("TestModel","ninja.mesh");
mModelNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mModelNode->attachObject(mModel);
mSceneMgr->setAmbientLight(ColourValue(0.5,0.5,0.5));
}
As hopefully you can see... nothing much extravegant going on here just a simple mesh and trying to get a mouseover type effect... just can't pick it...
To test I set a break point at "mCurrMO = it->movable;" and it NEVER gets called... the result list is always empty.