(1) 作業四(擺pose存檔)
(2) 主題 : 攝影機、投影矩陣
(3) 實作 : gluLookAt()、glutReshapeFunc()
(4) 期末作品

(1) 到連結網站下載window、 data、glut32.dll 三個檔案
(2) 將data、glut32.dll檔案放入window中,就能開啟Projection.exe檔案
(3) gluLookAt(eyeX,eyeY,eyeZ, //在哪裡看
centerX,centerY,centerZ, //中心點(藍色線條)
upX,upY,upZ);
(4) 當調整gluPerspective程式中的zNear的數值時,
會移動到前面藍色方塊(右圖箭頭處),移動後的改變參照右圖
(5) 當調整gluPerspective程式中的zFar的數值時,
會移動到後方灰色方塊(右圖箭頭處),移動後的改變參照右圖
(6) 調整gluPerspective程式中的fovy的數值時,
則會影響拍攝角度的大小,兩張圖為60度及40度的差別
(7) 當視窗被拉長,人物比例不對稱時,
可利用調整gluPerspective程式中的aspect的數值,
來讓人物比例恢復正常
(1) 在codeblock開啟一個新的GLUT project,加入程式碼可以以不同角度看圖形
程式碼 :
gluLookAt(0.3,10,0.3 ,0,0,-6 ,0,1,0);
(2) 加入程式碼能利用滑鼠調整要看的角度
程式碼 :
#include <math.h>
void motion(int x,int y)
{
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), 0,0,-6, 0,1,0);
glutPostRedisplay();
}
glutMotionFunc(motion);








沒有留言:
張貼留言