2016年3月22日 星期二

Week05 林明萱


課堂作業1:
             網址 jsyeh.org/3dcg10
             下載老師給的檔案 Data Win32 GLUT32
              解壓縮之後將資料夾放一起
              執行Transformation
              點右鍵可選擇 去做交換Swap


















利用移動(Translate)、旋轉(Rotate)、縮放(Scale)
調整位置、角度、大小


課堂作業2:

開啟GLUT檔
#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("hellow3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();

}

所做出來的程式 可以讓茶壺自由旋轉

















課堂作業3:
#include <GL/glut.h>
float rotX=0,rotY=0;

void display()
{


    glClearColor(1,1,0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotatef(rotX, 1, 0, 0);
         glRotatef(rotX, 0, 1, 0);
        glColor3f(0,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(300,300);
    glutInitWindowSize(500,0);
    glutCreateWindow("Hello 3D");


    glutMotionFunc(motion);
    glutDisplayFunc(display);

    glutMainLoop();


}

讓水壺繞x.y軸旋轉





















沒有留言:

張貼留言