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.
3D Picking (Not Picking)
-
JasonW
- Gnoblar
- Posts: 18
- Joined: Thu Feb 10, 2005 7:14 am
- Location: Mackay, QLD, Australia
- tuan kuranes
- OGRE Retired Moderator

- Posts: 2653
- Joined: Wed Sep 24, 2003 8:07 am
- Location: Haute Garonne, France
- x 4
- Contact:
- Clay
- OGRE Community Helper

- Posts: 518
- Joined: Wed Mar 17, 2004 4:14 am
- x 1
- Contact:
Try calling MouseX, MouseY with getX, getY instead of getRelX, getRelY.
Also, loop through the results:
Also, loop through the results:
Code: Select all
for (it = result.begin( ); it != result.end( ); it++)
if (it->movable)
mCurrMO = it->movable;- Clay
- OGRE Community Helper

- Posts: 518
- Joined: Wed Mar 17, 2004 4:14 am
- x 1
- Contact:
No problem. Be sure to read through the second and third intermediate tutorials http://ogrewiki.digitalsentience.com/in ... _Tutorials if the wiki ever comes back up.
It gives usage for ray scene queries for object and terrain selection, as well as using getRelX/Y for doing a mouse-look. (Though it looks like you already have this stuff down anyway.)
It gives usage for ray scene queries for object and terrain selection, as well as using getRelX/Y for doing a mouse-look. (Though it looks like you already have this stuff down anyway.)