1.桌面安裝freeglut
2.file-new-project glut方案week03_mouse
3.貼上10行程式碼
4.加3行mouse
程式碼:
#include <GL/glut.h>
#include <stdlib.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[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week03 mouse");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMainLoop();
}
加上一行程式依序顯示button,state,x,y
用滑鼠去做定位
去老師的網站下載
data win32兩個檔案
https://jsyeh.org/3dcg10/
windows 解壓縮到windows
再把data丟進windows 並開啟Transformation.exe
新增一個專案 mouse_glut
程式碼複製mouse專案的再加上原來的46 49 54 行和自己寫的一行glTranslatef(teapotX,teapotY,0);
可以靠滑鼠點擊移動茶壺的位置
xyz軸怎麼轉
安培右手定則
用右手比讚來理解
讚的大拇指等於轉動軸
其他拇指等於轉動的方向
對y軸>>>正常的讚
對x軸>>>大拇指向右
對-y軸>>>正常的倒讚
最難的是z軸>>>大拇指指向自己的鼻子
旋轉茶壺
旋轉跟移動茶壺







沒有留言:
張貼留言