2022年3月15日 星期二

shhhhhi : )

 WEEK04

主題:Rotate/Motion function

1.至https://jsyeh.org/3dcg10/下載win32 & data.zip



2.各種旋轉方向範例(註解如圖)

A.x軸

B.x軸&y軸


C.z軸


3.茶壺往Z軸轉90度

glPushMatrix();///備份矩陣
glRotatef(90,0,0,1);///旋轉軸Z軸,90度
glutSolidTeapot(0.3);
glPopMatrix();///還原矩陣


4. Montion function(
轉動會每次重新點位置轉動)

新增:
float angle=0;
void display裡: glRotatef(angle,0,0,1);
void motion(int x,int y)
{
    angle=x;
    display();
}
Main函式: glutMotionFunc(motion);


4-2.
(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);






沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

一.     一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam,                 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...