2023年5月24日 星期三

Week15ㄟ部分


老師說明Maya裁切模型
去老師的網址 https://jsyeh.org/3dcg10/
data、win32檔案接著解壓縮


將data拉進去window資料夾裡面

點選projection.exe,調整eye(從哪裡看)和center(看哪裡)的位置

成功開啟
center = 畫面中心
eye = 從眼睛看(第三人稱)
up = 手機拍照食指方向,旋轉後食指 指的方向

Week15-1
新增week15-1



1.將這行加入/// 
glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);
再補入glOrtho(-ar*3,ar*3,-1*3,1*3,-100,+100);

2.將這行加入///
glOrtho(-ar*3,ar*3,-1*3,1*3,-100,+100);
再補入gluPerspective(60,ar,0.01,1000);






fovy->field of view(y方向)視野的角度

aspect = aspect ratio長寬比
zNear = 最靠近從哪裡開始
zFar = 最遠位置到哪邊

Week15-2
#include <GL/glut.h>
#include <stdlib.h>
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
void reshape(int w,int h){
    glViewport(0,0,w,h);

    float ar=w/(float)h;

    glMatrixMode(GL_PROJECTION);///臨時切換Model view 矩陣
    glLoadIdentity();
    gluPerspective(60,ar,0.01,1000);

    glMatrixMode(GL_MODELVIEW);///切回Model矩陣

    glLoadIdentity();
    gluLookAt(0,0,1,  0,0,0,  0,1,0);

    glutPostRedisplay();
}
float eyeX=0,eyeY=0;
void motion(int x,int y){

    eyeX=(x-150.0)/150.0;
    eyeY=(150.0-y)/150.0;
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    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");

    glutDisplayFunc(display);
    glutReshapeFunc(reshape);

    glutMainLoop();
}






沒有留言:

張貼留言