Jump to content
  • Advertisement


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


Direct3D IM object picking

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


here''s a short algorithm for picking objects

1. Compute a ray with the origin in the camera position
2. Pick the object that this ray intersect closest to the camera

The keywords here are ''ray'' and ''intersect''.

The ray''s direction is computed by unprojecting a screen coordinate by multiplying it with (ViewMatrix*ProjectionMatrix*ViewportMatrix)-1 and then subtracting the camera''s position from the result.

Then you check for all objects if the ray intersect any of their triangles. Then finally you pick the objects which was intersected the closest to the camera.

You can find info on how to check if a ray intersects a triangle here: Fast ray/triangle intersection test

- WitchLord

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!