OpenGL: Reset Object

I have a car model with various parts of the car described in vertex groups.

+3
source share
3 answers

You know the current position of the bus, so you use the translation matrix built from the identification matrix and the negative position to translate it to the beginning:

1 0 0 -x
0 1 0 -y
0 0 1 -z
0 0 0  1

Then rotate and then apply forward conversion to return it:

1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
+8
source

, glPushMatrix() glPopMatrix(). glPushMatrix() //, (.. ). , . // , . , glPopMatrix(). . .

glPushMatrix();
// at this point you're working at the origin
// translate the tire here
// rotate the tire here
glPopMatrix();

, , .

+1

:

glTranslatef(x_translate_factor,y_translate_factor,z_translate_factor);
glRotatef(global_car_rotate,0,1,0) ;
glRotatef(global_tire_rotate,0,1,0);
glRotatef(tire_speed,1,0,0);

tire_speed - , global_tire_rotate - . Global_car_rotate - ( , ) z. * _translate_factor - * - . , , ;).

0
source

Source: https://habr.com/ru/post/1769240/


All Articles