Salut à tous,

J'ai un soucis avec mon code :

Lorsque je fais la rotation+translation du monde virtuel pour une visualisation controlée par souris + clavier, la translation ne se fait pas sur le repere qui a subi une rotation mais sur le repere d'origine... Comme si la vue tournait bien mais que le repere ne bougeait pas

Je voulais savoir si quelqu'un pouvait essayer de voir dans le code qui suit si il y a un truc qui cloche svp ?
Merci d'avance !

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
 
#include "opengl.h"
 
GLfloat rquadx,rquady;
char presse;
float posx, posy, posz;
int anglex,angley,x,y,xold,yold;
 
void InitGL(void)
{
	rquadx = 0;
	rquady = 0;
	posx = 0;
	posy = -3;
	posz = 0;
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);		// This Will Clear The Background Color To Black
	glClearDepth(1.0);							// Enables Clearing Of The Depth Buffer
	glDepthFunc(GL_LESS);						// The Type Of Depth Test To Do
	glEnable(GL_DEPTH_TEST);					// Enables Depth Testing
	glShadeModel(GL_SMOOTH);					// Enables Smooth Color Shading
 
  	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();							// Reset The Projection Matrix
	gluPerspective(70.0f,(GLfloat)kWindowWidth/(GLfloat)kWindowHeight,0.1f,100.0f);	// Calculate The Aspect Ratio Of The Window
	glMatrixMode(GL_MODELVIEW);
}
 
void ReSizeGLScene(int Width, int Height)
{
 
}
 
void idle(void)
 
}
 
void clavier(int key, int x, int y)
{
switch(key)
	{
	case GLUT_KEY_UP:
		posz++;
		break;
	case GLUT_KEY_DOWN:
		posz--;
		break;
	case GLUT_KEY_RIGHT:
		posx++;
		break;
	case GLUT_KEY_LEFT:
		posx--;
		break;
 
	}
		glutPostRedisplay();
}
 
void DrawGLScene(void)
	{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
	glLoadIdentity();
 
	//glRotated(rquadx,1.0,0.0,0.0);	
	glRotatef(rquady,0.0,1.0,0.0);	
	glTranslatef(posx,-3,posz);
 
glPushMatrix();
	glBegin(GL_LINES);
		//X
		glColor3ub(254, 0, 0);						
		glVertex3f(0.0, 0.0, -2.0);					
		glVertex3f(1.0, 0.0, -2.0);
		//Y	
		glColor3ub(0, 254, 0);						
		glVertex3f(0.0, 0.0, -2.0);					
		glVertex3f(0.0, 1.0, -2.0);
		//Z
		glColor3ub(0, 0, 254);						
		glVertex3f(0.0, 0.0, -2.0);					
		glVertex3f(0.0, 0.0, -3.0);
	glEnd();
glPopMatrix();
glPushMatrix();
	for(float i = -500; i <= 500; i += 5)
		{
		glBegin(GL_LINES);
			glColor3ub(150, 190, 150);						
			glVertex3f(-500.0, 0.0, i);					
			glVertex3f(500.0, 0.0, i);
			glVertex3f(i, 0.0,-500.0);							
			glVertex3f(i, 0.0, 500.0);
		glEnd();
		}
glPopMatrix();
    glutSwapBuffers();
    glFlush();
	}
 
 
void mouse(int button, int state,int x,int y)
	{
	if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) 
		{
		presse = 1;
		xold = x; 
		yold = y;
		}
	if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) 
		presse=0;
	}
 
void mousemotion(int x,int y)
	{
    if (presse) 
		{	
		rquady+=x-xold;
		if (rquady>=360)
			rquady-=360;
 
		rquadx+=y-yold;
		if (rquadx>=360)
			rquadx-=360;
 
		glutPostRedisplay(); 
		}
	xold = x;
    yold = y;
	}