2022年6月14日 星期二

電腦圖學筆記

 總複習

最後一堂課了 !

1. 期末作品繳交方式

2. 期末作品評分方式

3. 網友問 push matrix 和 pop matrix 事件

4. 整學期總複習 & 示範期末作品怎麼做


## 怎把期末作業做出來

運鏡

#include <GL/glut.h>
void reshape(int w,int h)
{///不能用整數除,長寬比(寬/長)
    float ar = (float)w / (float)h;
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);///3D變2D
    glLoadIdentity();
    gluPerspective(60,ar,0.1,100);

    glMatrixMode(GL_MODELVIEW);///3D Model+View
    glLoadIdentity();
    gluLookAt(0,0,3, ///eye位置
              0,0,0, ///center看哪裡
              0,1,0);///up向量
}
void motion(int x,int y)
{
    glMatrixMode(GL_MODELVIEW);///3D Model+View
    glLoadIdentity();
    gluLookAt((x-150)/150.0,(y-150)/150.0,3, ///eye位置
              0,0,0, ///center看哪裡
              0,1,0);///up向量
    glutPostRedisplay();
}///根據滑鼠移動轉換視角
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidTeapot(1);
    glutSwapBuffers();
}
int main(int argc,char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("運鏡");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutReshapeFunc(reshape);///初始視角
    glutMainLoop();
}

沒有留言:

張貼留言

VERY BEAUTIFUL, VERY POWERFUL

一.     一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam,                 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...