2022年3月8日 星期二

A

 WEEK03

1.範例 https://jsyeh.org/3dcg10/


1.1 下載 data, win32

windows.zip => 下載\windows\Transformation.exe

data.zip => 下載\windows\data\模型.obj

1.2.執行 Transformation.exe

(右上角) 右鍵:換模型

(下方)拖曳綠色的數值:











用滑鼠來移動茶壺
1.void mouse() ///函式
2. glutMouseFunc(mouse); ///呼叫函式
3.myTeapot((mouseX-150)/150.0,-(mouseY-150)/150.0);///滑鼠和畫面的換算方式
#include <GL/glut.h>



void display()

{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix(); ///備份舊矩陣位置,因為會修改矩陣,所以移動會累積

    glTranslatef(0.5,0.5,0);///往右上角跑

    glColor3d(1,0,1);///色彩



    glutSolidTeapot(0.6);

    glPopMatrix(); ///還原舊矩陣

    glutSwapBuffers();

}



int main(int argc, char *argv[])

{

    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);



    glutCreateWindow("week03 移動茶壺");



    glutDisplayFunc(display);



    glutMainLoop();


}












沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

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