我正在使用glRotate和glTranslate函數來圍繞自身旋轉模型。當我運行程序時,模型正在圍繞它旁邊的一個點旋轉。這裏是我的模型定義:glTranslate和glRotate無法正常工作
private static final float[] mesh = {
-0.5f, 0.5f,-0f,
-0.5f, -0.5f, -0,
0.5f, -0.5f, 0f,
0.5f, 0.5f, 0f,
-0.5f, 0.5f,-1f,
-0.5f, -0.5f, -1f,
0.5f, -0.5f, -1f,
0.5f, 0.5f, -1f,
};
private static final byte[] indices = {
0, 2, 1,
0, 3, 2,
1,2,6,
6,5,1,
4,5,6,
6,7,4,
2,3,6,
6,3,7,
0,7,3,
0,4,7,
0,1,5,
0,5,4
};
,這裏是我的旋轉模式功能:
glRotatef(rotation.x,1,0,0);
glRotatef(rotation.y,0,1,0);
glRotatef(rotation.z,0,0,1);`
我使用LWJGL但我能讀懂C++就好了。
glTranslate在哪裏?操作順序很重要。 – Tim