2016年3月22日 星期二

Week 05 林佑安

課堂作業一:
主題:旋轉&移動

1.教材:jsyeh.org/3dcg10

(A) 
移動 glTranslatef
旋轉 glRotatef
縮放 glScalef
glBegin();glEnd()
(以車子先旋轉再移動)


(B) 
旋轉 glRotatef
移動 glTranslatef
縮放 glScalef
glBegin();glEnd()
(以畫面中心先移動在旋轉)


課堂作業二:
mouse轉動

1.

#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);
    ///glutMouseFunc(mouse);

    glutMainLoop();

}



2.
(向左轉)


課堂作業三:


1.什麼是Buffer?


2.什麼是Double Buffer?


課堂作業四:
階層式旋轉

1.

#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);
    glutInitWindowSize(600,600);
    glutInitWindowPosition(700,0);
    glutCreateWindow("hello3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);
    ///glutMouseFunc(mouse);

    glutMainLoop();

}




沒有留言:

張貼留言