Bonjour,

je souhaiterais déplacer ma caméra vers l'arrière vers l'avant et sur les côtés mais je n'y arrive pas ?
Pouvez-vous me donner un petit coup de main ?

Voici mon programme :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
 
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
 
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
 
/* Variables et constantes globales             */
/* pour les angles et les couleurs utilises     */
 
#ifndef M_PI
#define M_PI 3.14159
#endif
 
 
/* Variables et constantes globales             */
/* pour les angles et les couleurs utilises     */
 
static float rx = 0.0F;
static float ry = 0.0F;
static float rz = 0.0F;
 
static const float noir[] = { 0.0F,0.0F,0.0F,1.0F };
static const float grisClair[] = { 0.7F,0.7F,0.7F,1.0F };
static const float grisFonce[] = { 0.3F,0.3F,0.3F,1.0F };
static const float blanc[] = { 1.0F,1.0F,1.0F,1.0F };
static const float jaune[] = { 1.0F,1.0F,0.0F,1.0F };
static const float rouge[] = { 1.0F,0.0F,0.0F,1.0F };
static const float vert[] = { 0.0F,1.0F,0.0F,1.0F };
static const float bleu[] = { 0.0F,0.0F,1.0F,1.0F };
static const float bleuatre[] = { 0.4F,0.4F,1.0F,1.0F };
static const float jaunatre[] = { 0.6F,0.6F,0.0F,1.0F };
static const float jauneClair[] = { 1.0F,1.0F,0.7F,1.0F };
 
static int n = 36;
static int m = 36;
 
//Gestion camera
static float ex = 0.0;
static float ey = 0.0;
static float ez = 20.0;
 
/* Fonction d'initialisation des parametres     */
/* OpenGL ne changeant pas au cours de la vie   */
/* du programme                                 */
 
void init(void) {
  const GLfloat shininess[] = { 50.0 };
  glMaterialfv(GL_FRONT,GL_SPECULAR,blanc);
  glMaterialfv(GL_FRONT,GL_SHININESS,shininess);
  glLightfv(GL_LIGHT0,GL_DIFFUSE,blanc);
 
 
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
 
  glDepthFunc(GL_LESS);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  glEnable(GL_AUTO_NORMAL);
}
 
/* Scene dessinee                               */
 
void mySolidCylinder(int n,int m) {
  glPushMatrix();
  for ( int j = 0 ; j < m ; j++ ) {
    float hi = 1.0F-j*2.0F/m;
    float hf = hi-2.0F/m;
    glBegin(GL_QUAD_STRIP);
    for( int i = 0 ; i <= n ; i++ ){
      float a = (2*M_PI*i)/n;
      float sn = -sin(a);
      float cs = cos(a);
      glNormal3f(cs,0.0F,sn);
      glVertex3f(cs,hi,sn);
      glVertex3f(cs,hf,sn); }
    glEnd(); }
  glPopMatrix();
}
 
void scene() {
	glPushMatrix();
 
	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,1);
	glMaterialfv(GL_FRONT,GL_AMBIENT,noir);
        glMaterialfv(GL_FRONT,GL_EMISSION,noir);
        glMaterialfv(GL_FRONT,GL_DIFFUSE,jaune);
        glMaterialfv(GL_FRONT,GL_SPECULAR,jauneClair);
        glMaterialf(GL_FRONT,GL_SHININESS,60.0F);
 
        glMaterialfv(GL_BACK,GL_AMBIENT,noir);
        glMaterialfv(GL_BACK,GL_EMISSION,noir);
        glMaterialfv(GL_BACK,GL_DIFFUSE,grisClair);
        glMaterialfv(GL_BACK,GL_SPECULAR,grisFonce);
        glMaterialf(GL_BACK,GL_SHININESS,110.0F);
 
	mySolidCylinder(n,m);
	glPopMatrix();
}
 
/* Fonction executee lors d'un rafraichissement */
/* de la fenetre de dessin                      */
 
void display(void) {
  glClearColor(0.5F,0.5F,1.0F,1.0F) ;
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  const GLfloat light0_position[] = { 1.0,1.0,1.0,0.0 };
  glLightfv(GL_LIGHT0,GL_POSITION,light0_position);
 
  glPushMatrix();
  glRotatef(rx,1.0F,0.0F,0.0F);
  glRotatef(ry,0.0F,1.0F,0.0F);
  glRotatef(rz,0.0F,0.0F,1.0F);
  scene();
  glPopMatrix();
  glFlush();
  glutSwapBuffers();
}
 
/* Fonction executee lorsqu'aucun evenement     */
/* n'est en file d'attente                      */
 
void idle(void) {
	rx += 0.04129F;
	ry += 0.04129F;
	rz += 0.04129F;
	glutPostRedisplay() ;
}
 
/* Fonction executee lors d'un changement       */
/* de la taille de la fenetre OpenGL            */
 
void reshape(int x,int y) {
  glViewport(0,0,x,y); 
  glMatrixMode(GL_PROJECTION) ;
  glLoadIdentity() ;
  gluPerspective(18.0F,(float) x/y,1.0,500.0) ;
  glMatrixMode(GL_MODELVIEW) ;
  glLoadIdentity() ;
  gluLookAt(ex,ey,ez,0.0,0.0,0.0,0.0,1.0,0.0);
}
 
/* Fonction executee lors de l'appui            */
/* d'une touche alphanumerique du clavier       */
 
void keyboard(unsigned char key,int x,int y) {
  switch (key) {
    case 0x20 :
      {
        static int anim = 1;
        anim = !anim;
        glutIdleFunc(( anim ) ? idle : NULL);
      }
      break;
    case 'z' :
      { 
      	n++;
      	m++;
      	glutPostRedisplay();
      }
      break;
    case 'e' :
      { 
      	n--;
      	m--;
      	glutPostRedisplay();
      }
      break;    
    case 'a' :
      { static int face = 1;
        face = !face;
        glPolygonMode(GL_FRONT_AND_BACK,( face ) ? GL_FILL : GL_LINE); }
      glutPostRedisplay();
      break;
    case 0x1B :
      exit(0);
      break; }
}
 
void GestionSpecial(int key, int x, int y)
{ 	
 
	switch (key)
	{ 	
		case GLUT_KEY_LEFT :
			printf("GAUCHE");
			ey = ey - 0.014159;
			gluLookAt(ex,ey,ez,0.0,0.0,0.0,0.0,1.0,0.0);
			glutPostRedisplay();
		break;
		case GLUT_KEY_UP :
			printf("AVANCE");
			ez = ez - 0.014159;
			gluLookAt(ex,ey,ez,0.0,0.0,0.0,0.0,1.0,0.0);
			glutPostRedisplay();
		break;
		case GLUT_KEY_RIGHT :
			printf("DROITE");
			ey = ey + 0.014159;
			gluLookAt(ex,ey,ez,0.0,0.0,0.0,0.0,1.0,0.0);
			glutPostRedisplay();
		break;
		case GLUT_KEY_DOWN :
			printf("RECULE");
			ez += 0.014159;
			gluLookAt(ex,ey,ez,0.0,0.0,0.0,0.0,1.0,0.0);
			glutPostRedisplay();
		break;
	}
} 	
 
/* Fonction principale                          */
 
int main(int argc,char **argv) {
  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE);
  glutInitWindowSize(800,500); 
  glutInitWindowPosition(50,50); 
  glutCreateWindow("gestion des lumieres et materiaux"); 
  init();
  glutKeyboardFunc(keyboard);
  glutSpecialFunc(GestionSpecial);
  glutReshapeFunc(reshape);
  glutIdleFunc(idle);
  glutDisplayFunc(display);
  glutMainLoop();
  return(0);
}
merci d'avance bonne journée