- the line I draw is done in "headupdisplay" function by :
//Setup for 2D glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, w_width, w_height, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // begin draw scale line glDisable(GL_TEXTURE_2D); glLineWidth(2.0f); glBegin(GL_LINES); glVertex2d(350, 12); glVertex2d(450, 12); glVertex2d(350, 9); glVertex2d(350, 15); glVertex2d(450, 9); glVertex2d(450, 15); glEnd(); glEnable(GL_TEXTURE_2D); // end draw glMatrixMode( GL_PROJECTION ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); glPopMatrix(); // end for 2DSo, this line has 100 pixel length.
- I want the value right to this line to represent the distance of the foreground plane, i.e the 2D projection of the 3D scene.
For example, I show you the result when I zoom (the value equals to 45.8 kpc) :
Now another picture with the same zoom but with also a rotation by mouse, this is a view by side of the galaxy :
wintertime, you say this distance is difficult to calculate correctly with perspective projection, could you give me some clue ?
I just want to get a value corresponding to the foreground objects, i.e the 2D projection in (xy) plane of the 3D scene without taking into account of the z coordinates. That's why you advise me to use Ortho projection ?