Results 1 to 4 of 4

Thread: DX8 - Mouses and Meshes

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118

    DX8 - Mouses and Meshes

    Hi

    I am using DX8 and am trying to determine if the mouse cursor is 'over' a mesh. I can imagine that this is possible using the bounding box of a mesh, however, I would like pixel perfect results. Is there any way of doing this please and if so what functions would be used?

    Thanks in advance

    Dan

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Calculate the ray from screen space into world space (google), and then see if that ray intersects any of the triangles in the mesh. Use a sort of heirarchial sysytem of tests... first a bound sphere test. If a hit, test the BB, if yes, check each triangle. Google to find out intersection tests for each =).

    Z.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2002
    Posts
    118
    Z

    Thanks Z I was thinking along similar lines. The problem I am having is where does the ray go from / to. I know u can use the D3DXIntersect or D3DXMesh Intersect (something like that) to check for intersection with a mesh. I also know u can use D3DVec3Unproject to convert the mouse cursor position to world space.

    U then make a ray from the unprojected position of the mouse to ??????????, see my problem!

    With the lens flare problem the ray was from the camera to the sun but in this case there seems to be no way of determining the start/end pos of the ray.

    NO luck on google so far on this one.

    Any ideas

    Thanks Dan

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Simple enough. In screen coordinates, the ray starts at (mouse_x, mouse_y, 0.0), and ends at (mouse_x, mouse_y, 1.0). Simply transform both of those, and you find a line segment stretching from the point clicked on the near clip plane that stretches to the far clip plane. Subtract these vectors to find the direction, and you have your ray.

    Z.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width