0

Possible Duplicate:
How to convert a 3D point into 2D perspective projection?

I am able to get the X Y Z coordinates of a Object in a 3D game. What I want to do is be able to set the cursor position to this location on the window. I am already familiar with mouse movements and do not need information about that. Thanks for any help provided on this subject . I am very clueless on how to accomplish this goal...

Ex: Say the Objects 3D position is (X,Y,Z) 145.435, 1765.74, 14.7 and the window size is 800x600 how would I be able to find out where to set the mouse coordinates on screen to match up to the object in the 3D plane.

Community
  • 1
  • 1
user1127093
  • 85
  • 1
  • 3
  • 8
  • 1
    "Project" (as in "projection") and "Unproject" are your friendly terms. The "eye" must be taken into account. –  Jun 26 '12 at 23:55

1 Answers1

1

One approach might be to use your collision system to cast a ray from the world coordinates of the camera in the direction of the click. The first triangle picked is is likely to have the 3D position that you're looking for.

JagWire
  • 269
  • 2
  • 16
  • Ok I am able to get the camera X Y Z and Matrix + X Y Z of the 3d Object + Window Size. How would the calculation look to determine where to point the mouse cursor if I have all this data? – user1127093 Jun 27 '12 at 00:29