Original Post
I am creating a cube and a cylinder using Mesh.Box and Mesh.Cylinder respectivly(Directx 9). I am trying to pick the closest vertex of the mesh. I am using Mesh.Intersect to do this. The code is something as below sub function Intersect() 'x, y are mouse coordinates vIn.X = x : vIn.Y = y 'Compute point on Near Clip plane at cursor vIn.Z = 0 vNear = Microsoft.DirectX.Vector3.Unproject(vIn, viewport, proj, view, meshmatworld) 'compute point on far clip plane at cursor vIn.Z = 1 vFar = Microsoft.DirectX.Vector3.Unproject(vIn, viewport, proj, view, meshmatworld) 'Comput direction vector vDir = Microsoft.DirectX.Vector3.Subtract(vFar, vNear) If Mesh.Intersect(vNear, vDir, ClosestHit) = True Then 'Find the closest vertex from the ClosestHit.FaceIndex(hit triangle) endif end sub Since I am using the Mesh.Intersect, I assume i dont have to do any transformation of the mesh vertices before I call the Mesh.Interset function. Is there anything obvious i am missing. Because this code works for the cube(most of the times and rarely it draws a picked point out of the cube) and for the cylinder it doesn't work at all(always the picked vertex is somewhere out of the cylinder).