Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1212 connectés 

  FORUM HardWare.fr
  Programmation
  Divers

  [OpenGl] gluLookAt

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[OpenGl] gluLookAt

n°1715565
lordankou
Posté le 10-04-2008 à 13:15:12  profilanswer
 

Bonjour, je commence juste la programmation openGl pour les besoin d'un projet et j'avoue avoir du mal à comprendre pourquoi ça s'affiche mal (un problème de caméra mais je pense l'avoir pourtant bien régler).
 

Code :
  1. #include <GL/glut.h>   
  2. #include <stdlib.h>
  3. // function to display in OpenGl
  4. void affichage(void){
  5.     // clear everything
  6.     glClear(GL_COLOR_BUFFER_BIT);
  7.  glLoadIdentity();
  8.  gluLookAt(272974.05f, // position oeil X  --> + déplace la caméra vers la droite et - déplace la caméra vers la gauche  
  9.     176628.75f, // position oeil Y  --> + déplace la caméra vers le haut et - déplace la caméra vers le bas  
  10.     -1.0f, // position oeil Z  --> +  
  11.     272974.05f, // point regardé X  --> + déplace le point cible vers la droite et - déplace le point cible vers la gauche  
  12.     176628.75f, // point regardé Y --> + déplace le point cible vers le haut et - déplace le point cible vers le bas
  13.     0.0f, // point regardé Z -->
  14.     0.0f, // vecteur haut X -->
  15.     1.0f, // vecteur haut Y --> look down  
  16.     0.0f  // vecteur haut Z -->
  17.     );
  18.     // define a polygon
  19. glBegin(GL_POLYGON);
  20.    // define a polygon composed of 4 points with different colors  
  21.  glColor3f(1.0,0.0,0.0); glVertex2f(271913.4,177406.4);
  22.  glColor3f(1.0,1.0,0.0); glVertex2f(272010.1,177788.6);
  23.  glColor3f(1.0,0.0,1.0); glVertex2f(272573,177814.3);
  24.  glColor3f(0.0,1.0,0.0); glVertex2f(272652.8,177842.4);
  25.  glColor3f(1.0,0.0,0.0); glVertex2f(272592,178163.2);
  26.  glColor3f(1.0,0.0,0.0); glVertex2f(273653.3,178212.2);
  27.  glColor3f(1.0,0.0,0.0); glVertex2f(273673.5,178006.5);
  28.  glColor3f(1.0,0.0,0.0); glVertex2f(273833.7,177986.5);
  29.  glColor3f(1.0,0.0,0.0); glVertex2f(273793.7, 177801.4);
  30.  glColor3f(1.0,0.0,0.0); glVertex2f(273913.1, 177799);
  31.  glColor3f(1.0,0.0,0.0); glVertex2f(273974.6, 177426.5);
  32.  glColor3f(1.0,0.0,0.0); glVertex2f(274073.7, 177446.4);
  33.  glColor3f(1.0,0.0,0.0); glVertex2f(273933.4, 177125);
  34.  glColor3f(1.0,0.0,0.0); glVertex2f(274253.3, 177044.6);
  35.  glColor3f(1.0,0.0,0.0); glVertex2f(274294.1, 176706.3);
  36.  glColor3f(1.0,0.0,0.0); glVertex2f(274252.2, 176562.2);
  37.  glColor3f(1.0,0.0,0.0); glVertex2f(274513.8, 176466.3);
  38.  glColor3f(1.0,0.0,0.0); glVertex2f(274493.2, 176356.7);
  39.  glColor3f(1.0,0.0,0.0); glVertex2f(273893.5, 176379);
  40.  glColor3f(1.0,0.0,0.0); glVertex2f(273914, 176006.2);
  41.  glColor3f(1.0,0.0,0.0); glVertex2f(273813.7, 175946.2);
  42.  glColor3f(1.0,0.0,0.0); glVertex2f(273853.7, 175786.2);
  43.  glColor3f(1.0,0.0,0.0); glVertex2f(273313.6, 175546.1);
  44.  glColor3f(1.0,0.0,0.0); glVertex2f(273099, 175500.6);
  45.  glColor3f(1.0,0.0,0.0); glVertex2f(272881.2, 175279.1);
  46.  glColor3f(1.0,0.0,0.0); glVertex2f(272713.9, 175349.7);
  47.  glColor3f(1.0,0.0,0.0); glVertex2f(272633.1, 175219.6);
  48.  glColor3f(1.0,0.0,0.0); glVertex2f(272301.3, 175157.7);
  49.  glColor3f(1.0,0.0,0.0); glVertex2f(272285.4, 175045.3);
  50.  glColor3f(1.0,0.0,0.0); glVertex2f(271972.8, 175123.2);
  51.  glColor3f(1.0,0.0,0.0); glVertex2f(271873, 175087.2);
  52.  glColor3f(1.0,0.0,0.0); glVertex2f(271733.3, 175125.6);
  53.  glColor3f(1.0,0.0,0.0); glVertex2f(271673.3, 175066.1);
  54.  glColor3f(1.0,0.0,0.0); glVertex2f(271533.4, 175146);
  55.  glColor3f(1.0,0.0,0.0); glVertex2f(271593.4, 175286.1);
  56.  glColor3f(1.0,0.0,0.0); glVertex2f(271434.3, 175381);
  57.  glColor3f(1.0,0.0,0.0); glVertex2f(271657.2, 175783.2);
  58.  glColor3f(1.0,0.0,0.0); glVertex2f(271613.4, 175966.2);
  59.  glColor3f(1.0,0.0,0.0); glVertex2f(271632.2, 176028.1);
  60.  glColor3f(1.0,0.0,0.0); glVertex2f(271673.7, 176718.2);
  61.  glColor3f(1.0,0.0,0.0); glVertex2f(271878.2, 176942.2);
  62.  glColor3f(1.0,0.0,0.0); glVertex2f(271853.4, 177186.3);
  63.  glColor3f(1.0,0.0,0.0); glVertex2f(271933.4, 177366.3);
  64.     glEnd();
  65. // display the result
  66. glFlush();
  67. }
  68. // function to manage the keybord
  69. void clavier(unsigned char touche,int x,int y){
  70. switch (touche){
  71.  case 'p': /* affichage du carre plein */
  72.     glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  73.     break;
  74.  case 'f': /* affichage en mode fil de fer */
  75.     glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
  76.     break;
  77.  case 's' : /* Affichage en mode sommets seuls */
  78.     glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
  79.     break;
  80.  case 'q' : /*la touche 'q' pour quitter le programme */
  81.     exit(0);
  82. }
  83. // redisplay the object
  84. glutPostRedisplay();
  85. }
  86. // main function
  87. int main(int argc, char *argv[])
  88. {
  89.     // --------
  90.     //init GLUT
  91.     // --------
  92.     // take argument
  93.     glutInit(&argc,argv);
  94.     // Mode RGB and one buffer
  95.     glutInitDisplayMode(GLUT_RGB);
  96.     // uper left point of the openGl window
  97.     glutInitWindowPosition(200,200);
  98.     // size of the window (width,Heigh)
  99.     glutInitWindowSize(250,250);
  100.     // name of the windows
  101.     glutCreateWindow("Exemple 1" );
  102.     // define black screen
  103.     glClearColor(0.0,0.0,0.0,0.0);
  104.     // define point size
  105.     glPointSize(2.0);
  106.     // which function is used to display object
  107.     glutDisplayFunc(affichage);
  108.     // which function is used to manage keybord
  109.     glutKeyboardFunc(clavier);
  110.    
  111.     // -------------  
  112.     // start of glut
  113.     // -------------  
  114.     glutMainLoop();
  115. }


 
la fonction gluLookAt a comme paramètre le centroide de l'objet que je veux dessiner. et il regarde vers ce même centroide de façon verticale
 
quand je fais bouger le troisième paramètre (de -1 à 1 je ne vois qu'un gros truc rouge donc il m'affiche bien mon dessin). mais dés que je passe à -1.00000001 ou 1.000000001 il ne m'affiche plus rien.

mood
Publicité
Posté le 10-04-2008 à 13:15:12  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Divers

  [OpenGl] gluLookAt

 

Sujets relatifs
Opengl 3 : glColoropengl: intersection de segment en mode blend.
[OpenGL] Afficher un champ de vecteurs dynamiqueProfondeur en opengl
Textures et normales en openglGerer plusieurs fenêtres OpenGL.
C++ opengl lumières qui changent selon zoomC++ openGL problème couleur
[Opengl] Eclairage - spotCutoff[Opengl] Problème d'éclairage
Plus de sujets relatifs à : [OpenGl] gluLookAt


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR