How to get a point(x, y, z) where I clicked on?


20-10-2010 15:17:09

Hi, I'm trying to find a point when I click on movable object. When result entry is worldFragment I can get singleIntersection as point. But when result entry is movable (a mesh), I don't know how to get a point(x, y, z) where I clicked (on that mesh).

float offsetX, offsetY;
offsetX = InputMouse.MouseState.X.abs / InputMouse.MouseState.width;
offsetY = InputMouse.MouseState.Y.abs / InputMouse.MouseState.height;
mRaySceneQuery.Ray = camera.GetCameraToViewportRay(offsetX, offsetY);
RaySceneQueryResult rsq_results = mRaySceneQuery.Execute();
foreach (RaySceneQueryResultEntry r_entry in rsq_results)
if (r_entry.worldFragment != null)
Vector3 v = r_entry.worldFragment.singleIntersection;
else if (r_entry.movable != null)
//Vector3 v = ???


20-10-2010 18:28:13

Vector v3 = mRaySceneQuery.Ray.GetPoint(r_entry.distance);
Should work for worldFragments and movables.


23-10-2010 02:14:59

uh...the point(x,y,z) from RaySceneQuery is the collide point of ray and mesh's,it's not exact enough.
if u want get the collide point at triangle level, u should enum the all triangles in the result of RaySceneQuery.
WIKI have some infomation about this,sorry for forget the URL. :D