2022年3月29日 星期二

UCC的week06上課筆記~

week06 主題: 打光

step01.與重複上週步驟:

1-1至https://jsyeh.org/3dcg10(下載data.zip windows.zip )

1-2.windows.zip =解壓=> 下載\windows\Light Material.exe

    data.zip =解壓=>下載\windows\data\模型.org

(左上)左鍵drg可以旋轉  (左上)右鍵可以換模型 (左下)右鍵可以換Material




step02. 解釋光的性質 
glLightfv(GL_LIGHT,GL_POSITION,陣列)

LIGHT=>第幾個燈

POSITION=>設定燈的位置

gl=>使用opengl  ,   fv=> float vector(陣列)

GLflaot light_pos[]={-2.0,2.0,2.0,1.0};陣列


實作時間٩(๑❛ᴗ❛๑)۶

2-1-1.Moodle 下載 freeglut....zip

2-1-2.將桌面freeglut 中的 lib裡面有 libfreeglut.a複製貼在同一資料夾中,後將其檔案名稱改成libglut32.a

(是為了能在CodeBlocks中成功開啟檔案!

2-1-3.從GLUT偷程式碼(透過CRTL+F查找LIGHT函式)<=有陣列宣告和函示呼叫

step03.將偷來的程式碼帶入之前教的黃色茶壺  

目前進度程式碼:


             (秀出了帶有光澤的茶壺醬 ♫.(◕∠◕).♫)

step03-1. 將今日上課內容加入上週的旋轉放大移動效果

(最終可以得出一個3D的黃色茶壺兒)



step03-2 
               在float後面宣告一個angle,使得因為有角度兒可以旋轉




step04 .透過keyboard來控制要旋轉,移動還縮放
int oldX=0,oldY=0,now=0;///1移動2轉動3縮放
 void motion(int mouseX,int mouseY)
 {
     if (now==1)
     {
        x+=(mouseX-oldX); y+=(mouseY-oldY);
     }
     else if(now==2)
     {
         angle+=(mouseX-oldX);
     }
    else if(now==3)
    {
    if(mouseX-oldX>0) scale*=1.01;
    if(mouseX-oldX<0) scale*=0.99;
    }
    oldX=mouseX; oldY=mouseY;
    display();
 }
 void mouse(int button,int state,int mouseX,int mouseY)
 {
    oldX=mouseX; oldY=mouseY;
 }
 void keyboard( unsigned char key,int mouseX,int mouseY)
 {
    if(key=='1'||key=='w'||key=='W') now=1;
    if(key=='2'||key=='e'||key=='E') now=2;
    if(key=='3'||key=='r'||key=='R') now=3;
 }

(可以做三種事情的茶壺醬出現拉(撒花花)



沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

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