Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualyoupi1

Posted 16 January 2013 - 09:11 AM

I am not sure I have all understood. There are 2 things :

- 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 2D
So, 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) :

[attachment=13275:test3.png]

Now another picture with the same zoom but with also a rotation by mouse, this is a view by side of the galaxy :

[attachment=13276:test4.png]

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 ?

Thanks

#3youpi1

Posted 16 January 2013 - 09:07 AM

I am not sure I have all understood. There are 2 things :

- 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 2D
So, 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) :

[attachment=13275:test3.png]

Now another picture with the same zoom but with also a rotation by mouse, this is a view by side of the galaxy :

[attachment=13276:test4.png]

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 ?

Thanks

#2youpi1

Posted 16 January 2013 - 07:16 AM

I am not sure I have all understood. There are 2 things :

- 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 2D
So, 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) :

[attachment=13275:test3.png]

Now another picture with the same zoom but with also a rotation by mouse, this is a view by side of the galaxy :

[attachment=13276:test4.png]

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 ?

Thanks

#1youpi1

Posted 16 January 2013 - 06:03 AM

I am not sure I have all understood. There are 2 things :

 

- 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 2D

So, 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) :

 

[attachment=13275:test3.png]

 

Now another picture with the same zoom but with also a rotation by mouse, this is a view by side of the galaxy :

 

[attachment=13276:test4.png]

 

wintertime, you say this distance is difficult to calculate correctly with perspective projection, could you give me some clue ?

 

Thanks

 

 


PARTNERS