Jump to content

  • Log In with Google      Sign In   
  • Create Account


youpi1

Member Since 29 Oct 2012
Offline Last Active Jan 25 2013 08:59 AM
-----

Posts I've Made

In Topic: OpenGL / HUD - Computation of a good initial value for scale line

16 January 2013 - 05:12 PM

Its impossible to give one number for how wide it is without a distance.

 

 

So when I do :

 

gluPerspective(45.0f, (float)w_width / w_height, g_nearPlane, g_farPlane);"
gluLookAt (0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

 

I can't say that the width and height are equals to : width = height = 2 *tan(45) * distance ;  with distance = 3 ?


In Topic: OpenGL / HUD - Computation of a good initial value for scale line

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

Attached File  test3.png   241.05KB   21 downloads

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

Attached File  test4.png   126.61KB   37 downloads

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

In Topic: OpenGL / HUD - Computation of a good initial value for scale line

16 January 2013 - 04:25 AM

I don't understand why I have to use Ortho projection, Perspective allows me to make diplay  particles smaller/bigger when they get far away/closer (with zoom out/in that I have implemented) while Ortho is for 2D stuff.


In Topic: draw multiple 2D textured elements at once

30 October 2012 - 08:43 AM

Thanks a lot mhagain, It works ! I understand better now. Actually, I was confusing between array passed to glVertexPointer and glTexCoordPointer. Your code shows that we have to compute the coordinates of each quad vertex and this FOR each body. I thought that we would just need the "raw" positions of each body (containing in the "pos" array) without doing the shift.

So now, I am going to increase the performance of display by using texured objects with VBO.

Maybe I will bore you again on this forum :)

PARTNERS