Hi,
I have an array of mesh ojects renderd in my world space at positions relating to the world.translate coordinates, when I call my pick method it returns true for only the top left objet, ie the first position of the first box in fact it thinks all of my meshes are at that position, if I tilt the world or rotate or zoom my view it still works but only for the top left box.
Here is my pick code.
Private Function DoesMouseHitMesh(ByVal i As Int16, ByVal themesh As Mesh, ByVal x As Single, ByVal y As Single) As Boolean
Dim Far As New Vector3(x, y, 1)
Near.Unproject(myDevice.Viewport, myDevice.Transform.Projection, myDevice.Transform.View, myDevice.Transform.World)
Far.Unproject(myDevice.Viewport, myDevice.Transform.Projection, myDevice.Transform.View, myDevice.Transform.World)
Far.Subtract(Near)
Dim direction As Vector3 = Vector3.Subtract(Far, Near)
Dim Closest As New IntersectInformation 'Stores intersection information.
'Check for intersection.
If themesh.Intersect(Near, direction, Closest) = True Then
Return True
Else
Return False
End If
Return False
end function
Returns true for all my meshes if I click on the top left mesh. Do I need to do something with the position vectors I transform the world with each time I draw a mesh or what? I am proper stuck!
Cheers
Steveo