RaySceneQuery and worldFragment


07-02-2008 11:32:40

Hi guys. Is it possible to get worldFragment using RaySceneQuery on ETM ?
With this code:
CEGUI::Point mousePos = CEGUI::MouseCursor::getSingleton().getPosition();
Ray mouseRay = mCamera->getCameraToViewportRay(mousePos.d_x/float(e.state.width), mousePos.d_y/float(e.state.height));

RaySceneQueryResult &result = mRaySceneQuery->execute();

"result" returns only "movable" objects :?


07-02-2008 13:19:03

No, it's not. The RaySceneQueries are handled by the scene manager, and that's the only one which can insert world fragments into the results. Since ETM is not a scene manager it cannot produce world fragments. Therefore you need to query the terrain separately via ETM functions.


07-02-2008 13:26:38

The terrain tiles count as movable. If you want to filter them out you can set a QueryMask on your other entities and the camera, so everything without that mask in the query result should be a terrain-tile.

MovableObject* theObject;
res = mRayQuery->execute();
it = res.begin();
if (it != res.end())
while (it != res.end())
theObject = it->movable;

if (theObject->getQueryFlags() != MY_MASK)
cout << "rayquery hit a terraintile: " << theObject->getName().c_str() << "\n";
return theObject;


Something like that should do it.


07-02-2008 18:34:37

Thank you. Answer was in your demo :)

Ray mouseRay = mCamera->getCameraToViewportRay(arg.state.X.abs/float(arg.state.width), arg.state.Y.abs/float(arg.state.height));
std::pair<bool, Vector3> result = mTerrainInfo->rayIntersects(mouseRay);