RaySceneQuery in SimpleVehicleDemo

vimes

30-04-2008 06:35:34

Hi,
I'm trying to implement a mouse picking 3D feature in the SimpleVehicleDemo port for Mogre.
I based my attempt on the the BSP Collision demo from the OgreSDK : it uses RaySceneQuery and represents the point of result of the query with a targetter (small red ball).
This is the code I added to CreateScene

rsq = sceneMgr.CreateRayQuery(new Ray());
rsq.SetSortByDistance(true, 1);

and here is the snippet I added to Scene_FrameStarted

rsq.Ray = camera.GetCameraToViewportRay(0.5f, 0.5f);
RaySceneQueryResult rsqResult = rsq.Execute();
bool bFirst = true;
for (RaySceneQueryResult.Iterator ri = rsqResult.Begin();
ri != rsqResult.End(); ri++)
{
RaySceneQueryResultEntry res = ri.Value;
if (bFirst)
{
Vector3 point = rsq.Ray.GetPoint(res.distance);
targetNode.SetPosition(point.x, point.y, point.z);
bFirst = false;
}
else if (res.movable != null )
// the engine never go through this branch.
{
RaySceneQueryResultEntry res2 = ri.Value;
}
}

The targetter seem to collide with the floor correctly but when I point directly at the vehicle, their is only 1 result, and it is still is the floor.
Query masks don't seem to be useful in this situation because, as I understand it, they filter the result, not help retrieving more :).

Could it be that because the vehicle is inside the bounding box of the terrain it is not considered to be hit by the ray; or is it an issue with the state of the body in (M)ogreNewt ?
Any kind of advice would be appreciated.