2023年5月25日 星期四

小凱week15

第一節課:LookAt

先到https://jsyeh.org/3dcg10下載檔案,把data拉到window裡。


開啟Projection.exe,試著調整eye看看。

小葉老師透過攝影機解釋center跟up了解轉動的概念,接著試著調整center跟up,觀察模型的轉動。


接著去雲端下載github檔案,新增glut專案:week15-1_gluLookAt

開啟後按+-號觀察執行檔

加上motion跟LookAt程式碼,可以用滑鼠托移來轉動模型,觀察執行檔。

第二節課

回到剛剛的Projection.exe修改投影,有glOrtho、glFrustum跟gluPerspective,gluPerspective有4個參數,foxy(視野張開的角度(y))、aspect(長寬比)、ZNear跟ZFar。


開新的檔案:week15-2_gluPerspective,觀察glFrustum跟glOrtho的差別。


接著修改Perspective

備份程式

第三節課

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();
}

加上reshape程式碼






沒有留言:

張貼留言