1.Glut開啟專案week03_mouse放上10行程式碼,加上新的程式碼
#include <stdio.h>
void mouse(int button, int state,int x, int y){
printf("Hello Mouse!\n");
}
glutMouseFunc(mouse);
button 左鍵=0、中鍵=1、右鍵=2,state按下=0、鬆開=1,(x,y)=座標
3.把printf("%d %d %d %d\n",button,state,x,y)去掉,加上if(state==GLUT_DOWN)
5.glTranslatef(x,y,z)按住要調整的上下移動
printf("glVertex2f((%d-150)/150.0,-(%d-150)/150.0);\n",x,y);4.到https://jsyeh.org/3dcg10下載data,win32,windows.zip解壓縮把data丟進windows開啟Transformation.exe
5.glTranslatef(x,y,z)按住要調整的上下移動
6.新增專案week03_mouse_glTranslatef,要讓茶壺跟著mouse走,新增程式碼7.glRotatef(角度,x,y,z)可以用右手比讚來判斷,轉動軸為大拇指,轉動方向為其他手指,y軸轉就比個讚y為轉動軸,-y是倒讚,以此類推8.新增專案week03_mouse_glRotatef,拿week03_mouse_glTranslatef的程式碼改9.新增專案week03_mouse_translatef_rotatef,拿week03_mouse_glRotatef的程式碼改
沒有留言:
張貼留言