Jump to content
  • Advertisement
Sign in to follow this  
stealth

3d mouse???

This topic is 5056 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
Advertisement
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
^^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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!