converting 3d coordinate to 2d raster position.

Started by
5 comments, last by Jesper T 22 years, 7 months ago
Im making a small prog to make 3D models in, with curved spline patch surfaces based on a few control points. When making large models, the amount of control points makes it hard to select/mark specific points for manipulation with just using keyboard commands etc.. I need to be able to click on a point (which I only have the 3D coordinate of) with the mouse to select it. I know how to detect mouseclicks, but I cant find out how to get the pixel coordinate on the screen of a given 3D coordinate in the scene. I''d appreciate it if anyone could help me with this.
Advertisement
gluProject(..) will tell u in screen coords a world coords position
do you mind a little detail about that function?

This is called "picking", do a search on the web for an algorithm. Basically you have to take the inverse of the projection matrix to recover the original 3D point. This is covered in most gfx texts.

ECKILLER
ECKILLER
I mean.....how would I go about implementing that function? How would I know where, for example, a cube at coordinates (1, 2, 3) was in terms of the screen?
download the opengl1.3 spec from www.opengl.org
also check here its pretty selfexplanatory
http://www.cevis.uni-bremen.de/~uwe/opengl/gluProject.html
gluProject(..) ok, right thanks

This topic is closed to new replies.

Advertisement