2016年3月22日 星期二

Week 05 03163084_陳旻宏

作業1

1.旋轉+移動
2.教材jsyeh.org/3dcg10


調整角度glRotatef(  0.0,  0.00,  1.00,  0.00)
第一個是角度調整 之後 x軸 y軸 z軸 調整 右手定則


作業2

畫茶壺 左右旋轉


程式碼如下 :
#include <GL/glut.h>
float rotX=0;
void display()
{
    glClearColor(0,0,1,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotatef(rotX,0,1,0);
        glColor3f(1,1,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x, int y)
{
    rotX=x;
    display();
}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("hello3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();
}


作業3


上下左右旋轉


程式碼如下

#include <GL/glut.h>
float rotX=0, rotY=0;
void display()
{
    glClearColor(0,0,1,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotatef(rotY,1,0,0);
        glRotatef(rotX,0,1,0);
        glColor3f(1,1,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x, int y)
{
    rotX=x; rotY=y;
    display();
}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("hello3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();
}


作業4


視窗放大


程式碼差別如下

 在   glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH); 下方加入
    glutInitWindowSize(600,600);
    glutInitWindowPosition(700,0);



沒有留言:

張貼留言