第一節課:LookAt
先到https://jsyeh.org/3dcg10下載檔案,把data拉到window裡。
開啟Projection.exe,試著調整eye看看。
小葉老師透過攝影機解釋center跟up了解轉動的概念,接著試著調整center跟up,觀察模型的轉動。
接著去雲端下載github檔案,新增glut專案:week15-1_gluLookAt
開啟後按+-號觀察執行檔
回到剛剛的Projection.exe修改投影,有glOrtho、glFrustum跟gluPerspective,gluPerspective有4個參數,foxy(視野張開的角度(y))、aspect(長寬比)、ZNear跟ZFar。
第三節課
week15-3_gluPerspective_gluLookAt
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
void motion(int x,int y)
{
glLoadIdentity();
float eyeX=(x-150)/150.0,eyeY=(150-y)/150.0;
gluLookAt(eyeX,eyeY,1,0,0,0,0,1,0);
glutPostRedisplay();
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week15");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言