Advertisement

Direct3D IM object picking

Started by May 05, 2000 08:21 PM
1 comment, last by _Alex_ 24 years, 7 months ago
Could anyone help with a fast and clear Direct3D object picking algorithm?
we are havin the same problem as well!
if ya find a way out pls let me know at sandeep_kl@mailcity.com


Raptor
Advertisement
Hi,

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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement