(1)旋轉 移動
(2)mouse 旋轉
(3)階層式旋轉
(4)階層式移動
網址輸入jsyeh.org/3dcg10
下載 glut.dll和windows.zip和data.zip
translate(移動)
可以試試看如果位置調換有什麼不一樣:
rotate(旋轉)
rotate(旋轉)
translate(移動)
旋轉在移動之前,會因為汽車寬度越大,而影響旋轉的半徑會越大;寬度越小,而影響的半徑會越小
translate(移動)
rotate(旋轉)
移動在旋轉前,汽車是在原地旋轉
移動在旋轉前,汽車是在原地旋轉
#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0,1,0);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
rotX=x;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}


沒有留言:
張貼留言