Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Charleh

Still trying to figure out how to get the cursor in the right place

This topic is 5227 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 drawing in perspective mode at -1000 units on the screen - I want to be able to draw an object thats under the mouse in perspective mode (not ortho) that has the correct x/y to be under the mouse cursor but a z of -1000 If you think perspective, an object at 100, 100, -1000 is not going to be in the same place on the screen as an object at 100, 100, 0 I need to scale the position of this object by some amount but I'm not sure by what or how - any ideas? [edited by - Charleh on February 28, 2004 10:22:10 PM]

Share this post


Link to post
Share on other sites
Advertisement
Addition: it actually works if I scale the movement by 0.925 - but that just seems like an ugly hack to me - any know the proper way of doing it?

Share this post


Link to post
Share on other sites
This is trivial if you know how the rendering matrices work. You can actually derive an easy form expression by just studying the projection matrix.

If you don''t know how it works, you can still do it by following this magic formula:

1) run your vertex through your modelviewprojection matrix
2) change the "Z" you get out (which will be in the range 0-1)
3) run this changed vertex back through the inverse of the modelviewprojection matrix

Voila!

Share this post


Link to post
Share on other sites

  • 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!