XNA Creators Club Online
Page 1 of 1 (1 items)
Sort Posts: Previous Next

Mesh Intersections going bonkers

Last post 5/14/2007 12:14 PM by Steveo. 0 replies.
  • 5/14/2007 12:14 PM

    Mesh Intersections going bonkers

    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

     

Page 1 of 1 (1 items) Previous Next