2019年4月25日 星期四

06160150_蔡宗芸 W10

電腦圖學 2019-04-25 Week10

(1).期中 考 : OpenGL必備10函式

(2).複習 : 移動 . 旋轉 . 縮放

(3).主題 : T-R-T 旋轉 (改變旋轉軸)

(4).主題 : glut



(一)開啟Texture.exe

先到http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/下載3個並且解壓縮




把data和glut32.dll丟到windows裡面





開啟Transformation.exe


自轉 v.s 公轉



(二)


#include <GL/glut.h>
float angle=0;
void display()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(0,0.5,0);
        glutSolidTeapot( 0.3 );
    glPopMatrix();

    glPushMatrix();
        //glutSolidSphere(0.3,30,30);
    glPopMatrix();

    glPushMatrix();
        glTranslatef(0.50,0.625,0);
        glRotatef(angle,0,0,1);
        glTranslatef(0.6,0,0);

        glRotatef(-90,0,1,0);
        glutSolidCone(0.2,0.6,30,30);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x,int y)
{
    angle = x;
    display();
}

int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("06160150-W10 TRT");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}


沒有留言:

張貼留言