Sign in to follow this  

3d mouse???

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this