opengl glrotatef won't rotate properly
假设我在点
在下面的图形的基础上,我想将绿色圆圈旋转到右侧,背面和左侧。 我的实现是
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 | glRotatef(90, 50, 0, 0); would not work. Table dimension int xL = 25; int xR = 75; int yT = 60; int yB = 55; int zF = 25; int zB = -25; static float tableTop[8][3] = { { xL, yT, zF }, { xR, yT, zF }, { xR, yT, zB }, { xL, yT, zB }, //bottom { xL, yB, zF }, { xR, yB, zF }, { xR, yB, zB }, { xL, yB, zB }, }; |
您需要将对象平移到原点,而不是做您正在做的事情...
考虑一下(注意这些事情发生的顺序):
1 2 3 | glTranslatef ( 50.0f, 0.0f, 0.0f); // 3. Move back glRotatef (plate_rotate, 1.0f, 0.0f, 0.0f); // 2. Rotate around X-axis glTranslatef (-50.0f, 0.0f, 0.0f); // 1. Move X=50 to origin |