Jump to content
  • Advertisement
Sign in to follow this  
TheRussian25

Find Triangle Mouse Is Pointing At

This topic is 2719 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

Hi, I'm trying to make a map editor for my game using C sharp. (similar to the Far Cry 2 map editor)

My terrain consists of a grid of vertices, and I'd like to find out which vertice the mouse is pointing at. I suspect I'd need to do ray tracing from the camera position, but I have no idea how to do so. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
The concept you're searching for is "picking." There should be a Pick example in the SDK that demonstrates the concept.

Share this post


Link to post
Share on other sites
If you get the projection matrix and the position of you mouse, you can indeed cast a ray into the screen and check with what polygons it intersects.

This is a matter of calculating if a line intersects with a plane. You can use this, this or this.




assainator

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!