# 3d mouse???

This topic is 5234 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm wondering how I would use a 2d co ordinate to select a position in 3d space , I'm guessing theres an equation or something that does this , if anybody can help me out or point me in the right directiont hat'd be cool , what I want to use it for is to test if the 2d mouse is over a 3d object , thats the best i can explain

##### Share on other sites
well are u using OpenGL or DirectX

with OGL there are functions such as gluProject and gluUnProject that do this (2D->3D, and 3D->2D). In DX there are D3DX functions for this (can't remember their names).

for a software implementation you can downlod the mesa3D library and see how the glu_ functions are implemented or [google] for the math.

##### Share on other sites
My first thought would be tracing a ray from the near clip plane to 'infinity' and checking if it intersects with an object.
You could access the depth buffer to get a reasonably good estimation of how far 'into' the screen the ray would have to travel to interset. You could even use the depth value and the 3d coordinates to reconstruct the 3d point.
If you go from 2D->3D you dont have enough information to construct a point, and you end up getting a line. Its this line that you would use to test for intersection on.
There are probably better ways, but this was off the top of my head.
Good luck!

##### Share on other sites
^^yeah I think thats the way I was thinkin of aswell , just how to calculate it is a bit out of it for me to even think about , hmmm

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013599
×