2023年3月2日 星期四

Week03 好累喔

WEEK03

 STEP01-1 下載課本的範例

    https://jsyeh.org/3dcg10/ 下載windows.zip ( 主角 )和data.zip ( 小心目錄 ) 解壓縮 

     把data.zip的資料夾丟到window資料夾裡面

    glTranslatef ( x,y,z )





 STEP01-2 FILE-NEW-PROJECT 

    


STEP02-1 複製上週第一個程式碼後面10行 多加2行程式碼 讓茶壺秀出來 


程式碼
#include <GL/glut.h>
void display(){
    glutSolidTeapot( 0.3 );
    glutSwapBuffers();
}

STEP02-1 想要貼出更漂亮的程式碼 可以用github gist的功能 新增一段程式 

     


    <script src="https://gist.github.com/Claudia0729/716a0e9c706f5fa582c75c609c93ae39.js"></script>

    
    移動茶壺

    glPushMatrix();///備份矩陣
        glTranslated( 0.5 , 0.5 , 0 );///它會改變你的矩陣
        glutSolidTeapot( 0.3 );
    glPopMatrix();///還原矩陣

    glutSwapBuffers();


    

STEP03-1    讓茶壺加上滑鼠移動功能 

    
float X=0, Y=0, Z=0;///使用global變數 大寫XYZ
glTranslatef( X , Y , Z );///照著X Y Z去移動
void mouse( int button, int state, int x , int y )///mouse()函數
{       ///左中右鍵   按下/放開    小x     小y
    X = (x-150)/150.0;///減一半 除一半
    Y =-(y-150)/150.0;///減一半 除一半 y變負的
}
glutMouseFunc(mouse);///設定好mouse函數



STEP03-2  讓第二周的作業更好看

                            用MOUSE畫圖 把這些頂點複製 






     

沒有留言:

張貼留言