Advertisement

Mouse Click into 3D world Coordinates?

Started by September 05, 2000 11:13 AM
5 comments, last by nPawn 24 years, 4 months ago
Is there a good way of converting a mouse point click into 3d world coordinates so i can see if the user has clicked on an object in a 3d world (Direct3D)?
If I''m not mistaken, it is physically impossible to actually click the mouse in 3-D space on a computer screen which is always flat. Detect if the mouse click is over any objects and if it is, check the coordinates of that particular object.
Advertisement
I think another way to do it is change your 2d coordinates into a ray or line going out into 3d space and see if it collides with anything while heading out?
Unfortunately i''m pretty new to 3D, so i''m not sure how I would approach turning the 2d into 3d, could you guide me through the process a bit or help get me started?
Project is very tough. You must count the projection matrix, and verify the intersection in all faces (or some algorithm to work only in some faces). And next, check if the face is front or opposite. And finally return the "near" face selected.


-eng3d.softhome.net-
-----------------------------------------------"Cuando se es peon, la unica salida es la revolución"
with opengl u use gluUnProject(..) theres prolly something simular for d3d
Advertisement
Basicly all 3-D graphics must be displayed in DirectDraw(2-D) when they are actually painted to the screen.

The idea of 3-D could be thought of as having all of your objects in your world stored in matrices. Whenever you want to update your data, the camera angle, or whatever you apply some sort of formula to that matrix. After you have transformed the matrix into what you want displayed, you perform another formula on it to translate that 3-D scene onto a two-dimensional surface. Finally, that 2-D surface is put into video memory and displayed on your monitor.

This topic is closed to new replies.

Advertisement