1. Transformation : 旋轉、移動
*屬性從下到上做變化(Ex : [s]縮放->移動->旋轉 ) ↓
[s]Swap translate/rotate :
以車子為中心點旋轉
以車子為中心點旋轉
[r]Reset Parameters :
繞著車子做旋轉
繞著車子做旋轉
2. mouse轉動
左右旋轉
3. 加上 上下旋轉 以及 run視窗大小和位置
#include<GL/glut.h>
float rotX=0, rotY=0;
void display()
{
glClearColor(1,1,0,0);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotY,1,0,0);//旋轉 角度rotY 軸(1,0,0)x軸
glRotatef(rotX,0,1,0);//旋轉 角度rotX 軸(1,0,0)y軸
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion (int x, int y)
{
rotX = x; rotY = y;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(600,600); //視窗大小
glutInitWindowPosition(700,0); //視窗位置
glutCreateWindow("hello 3D");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}




沒有留言:
張貼留言