1.先去http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/下載需要的三個檔案
windows,data,glut32然後解壓縮後放進windows資料夾,打開projection可以看到一個彪形大漢
講解程式碼個個函釋的用途,並加上註解
介紹glutLookAt( ),glutReshapeFunc( )兩個函式公用,試著把他加入程式碼裡面
gluLookAt(eye x,eye y,eye z,center x,center y,center z,up x,up y,up z)
可以更改攝影機的位置
舉例:gluLookAt(0.3,10,0.3 ,0,0,-6 ,0,1,0);
接著嘗試讓攝影機移動
加入程式碼
#include <math.h>void motion(int x, int y)///等一下要移動到main附近
{
///偷偷把mouse motion的值 來算出camera位置
float angle=x*3.1415926/180.0;
float cameraY=(y-300)/100.0;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(5*cos(angle),cameraY,5*sin(angle)-6, 0,0,-6, 0,1,0);
glutPostRedisplay();
}
以及164行的 glutMotionFunc(motion);
即可讓攝影機開始移動




沒有留言:
張貼留言