2024年3月7日 星期四

0307

 


1.桌面安裝freeglut , 把lib的libfreeglut.a複製成libglut32.a

2.File-New-Project , GLUT專案

   week03_mouse 記得目錄(桌面),

GLUT目錄(桌面/freeglut)

3.貼上10行程式碼

4.加3行mouse

#include <GL/glut.h>///18行留下來

#include <stdio.h>

void mouse(int button,int state, int x,int y)

{

    printf("Hello Mouse!\n");

}

void display ()

{

    glutSolidTeapot(0.3);

    glutSwapBuffers();

}

int main(int argc, char *argv[])///138行

{

    glutInit(&argc, argv);  ///140行

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);///143行

    glutCreateWindow("2024電腦圖學第01周");///145行

    glutDisplayFunc(display); ///148行

    glutMouseFunc(mouse);

    glutMainLoop();///174行

}

        

                                                                                印參數

滑鼠寫程式

到http;//jsyeh.org/3dcg10
下載課本範例 data win32兩個檔案
window.zip=> 下載\window\data\一堆模型檔
試課本的Transformation.exe


File-New-Project, GLUT專案 week03_mouse_glTranslatef
偷GLUT專案範例的程式碼: 46行 ,49行 ,54行
把week03_mouse 的程式拿來用
修改以下程式碼: 增加teapotX teapotY 變數(茶壺


可以利用右手比讚來理解
轉動軸,就是比讚的那個拇指
轉動方向,就是其他手指的轉動方向
對y軸轉,簡單比個讚,完成
對x軸轉,要把拇指向右,也可以轉
對-y軸轉,就是比個倒讚,也可以理解
最難的是z軸,向著哪裡呢? 那個拇指向著你的鼻子


File-New-Project, GLUT專案 week03_mouse_glRotatef
把week03_mouse_glTranslatef 的程式拿來用







沒有留言:

張貼留言