createRayQuery question

Genie

07-03-2006 13:10:00

are OSM scenes compatibile with createRayQuery? I have created few scenes (succesfully implemented loading a scene in my little application) but I cannot get entities to work with my object selection (createRayQuery) function.

is that possible at all? or I'm just too green :) .

Lioric

07-03-2006 16:08:05

OSM Scenes supports all SceneManagers and SceneQueries are fully supported

See if you are using the correct camera for creating the ray

Genie

07-03-2006 16:15:52

Solved! :)

ok.. here is the deal ..

I was using selection function from Xavier tutorials (btw great ones)

http://artis.imag.fr/Membres/Xavier.Dec ... rial2.html

and there (in short) that function goes

void
MyApplication::mouseReleased(Ogre::MouseEvent* e)
{
if (e->getButtonID() == InputEvent::BUTTON0_MASK && e->isShiftDown()) // Shift+Left
{
// Deselect old one if any
if (mSelected) mSelected->getParentSceneNode()->showBoundingBox(false);
mWindow->setDebugText("");
// Use a ray scene query to find where we clicked
Ray mouseRay = mCamera->getCameraToViewportRay(e->getX(),e->getY());
mRaySceneQuery->setRay(mouseRay);
mRaySceneQuery->setSortByDistance(true);
RaySceneQueryResult &result = mRaySceneQuery->execute();
if (!result.empty())
{
RaySceneQueryResultEntry& re = result.front();
if (re.movable && re.movable->getMovableType() == "Entity")
{
mSelected = (Entity*)(re.movable);
mSelected->getParentSceneNode()->showBoundingBox(true);
mWindow->setDebugText("Selected "+mSelected->getName());
}
}
}
}

now..
RaySceneQueryResult &result = mRaySceneQuery->execute();

was giving all the rigt results.. BUT the first one on the list was CAMERA! :D

so.. when second part of code comes in

RaySceneQueryResultEntry& re = result.front();

what you do is choose a firt thing on the list (camera) and then you have a problem :D

ALSO .. I had to add

mCamera = mWindow->getViewport(0)->getCamera(); so I could be shure that I'm working with the camera I'm using at the moment

and of course I have changed if(!result.empty()) query to

if (!result.empty())
{
for ( itr = result.begin( ); itr != result.end(); itr++ )
{
if (itr->movable && itr->movable->getMovableType() == "Entity")
{
mSelected = (Entity*)(itr->movable);
Selected->getParentSceneNode()->showBoundingBox(true);
mWindow->setDebugText("Selected "+mSelected->getName());
break; // you found one? great! break!
}
}
}

that's all folks

Genie

07-03-2006 16:17:11

OSM Scenes supports all SceneManagers and SceneQueries are fully supported

See if you are using the correct camera for creating the ray


well the camera somehow was the problem ;)

is it normal to be first on the list when you use ray? it seems that before using OSM it was not...