3D point selection
I am trying to make a 3d modeler but I need to be able find the postion of the rendered points on the 2d screen so you can select them. Any ideas?
Yes. Just project points onto screen yourself using matrices you used to render it.
If you use openGL:
all points is projected using projection_matrix*modelview_matrix;
so you need to
m=projection_matrix*modelview_matrix;
clipspace_point=m*point;
// projection transformation:
screen_point=clipspace_point*(1/clipspace_point.w);
and you'll get point so x and y is IIRC -1..1 with center on screen, z is 0..-1.
If you use openGL:
all points is projected using projection_matrix*modelview_matrix;
so you need to
m=projection_matrix*modelview_matrix;
clipspace_point=m*point;
// projection transformation:
screen_point=clipspace_point*(1/clipspace_point.w);
and you'll get point so x and y is IIRC -1..1 with center on screen, z is 0..-1.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement