Skip to main content
GameDev.net gamedev.net
🔒 Locked

Screen Coordinates

Started by Machlana Jan 19, 2005 at 7:11 PM 1 replies 750+ views
Original Post
Machlana
Machlana
How would i go onto getting the xyz coordinates of the screen with my mouse or even the camera btw im using irrlicht but it can be dx code if it has to
jvff
jvff
If you want to know the mouse position on the screen you will need a Win32 routine. If you want to know about object-picking (ie. selecting 3D objects with the mouse), you have to create a ray from the 2D screen coordinates and test it against all triangles on the scene (you can use spatial subdivision methods to speed it up and tho) and get the nearest intersection distance. From that distance you can calculate the exact intersection point. There are tons of object-picking articles on the net. Search for "object picking 3D" and you will find something.

Hope this helps,
JVFF
ThanQ, JVFF (Janito Vaqueiro Ferreira Filho)
fproto
fproto
Well all you have to do is switch to orthographic view
with D3DXMatrixOrthoLH or D3DXMatrixOrthoRH.
After that, whatever positions you specify will be in pixels.
If you just want the coords of the cursor, use GetCursorPos.
If you are talking about the SCREEN coordinates, meaning
relative to the top-left of you monitor, and not just your
window, then add the position of your window.
Also remember that in orthographic view, the origin is
at the center of the window, not at the top-left, while
the cursor origin is at the top-left.
[Ortho:]       +y        ^        | -x <----o----> +x        |         v       -y[GetCursorPos:]o--> +x|v  +y
function(prototype);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.