WEEK04
主題:Rotate/Motion function
1.至https://jsyeh.org/3dcg10/下載win32 & data.zip
2.各種旋轉方向範例(註解如圖)
A.x軸
glPushMatrix();///備份矩陣
glRotatef(90,0,0,1);///旋轉軸Z軸,90度
glutSolidTeapot(0.3);
新增:
float angle=0;
void display裡: glRotatef(angle,0,0,1);
void motion(int x,int y)
{
angle=x;
display();
}
Main函式: glutMotionFunc(motion);
(4.1的解決方式-利用mouse 點擊紀錄位置修正:
p.s 利用原先的位置和後來移動的位置做修正 )
新增:
float oldx=0;
void motion更改:angle+=(x-oldx); oldx=x;
void mouse(int botton,int state,int x,int y)
{
oldx=x;///定錨
}
Main函式:glutMouseFunc(mouse);
沒有留言:
張貼留言