2023年3月16日 星期四

祝我全勝輸一場也沒差week05

 week05

期中考網址:https://jsyeh.org/gl/opengl_10_func.html


step01-1
進入此https://jsyeh.org/3dcg10/,下載data和window,把data丟進window之後點選Transformation.exe

複習上週做的旋轉位移位移選轉差別

step01-2
複製上週程式加入移動來區分TR和RT
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glColor3f(1,0,0);
    glPushMatrix();
        glRotatef(angle,0,0,1);
        glTranslated(0.8,0,0);
        glutSolidTeapot(0.3);
    glPopMatrix();

    glColor3f(0,1,0);
    glPushMatrix();
        glTranslated(0.8,0,0);
        glRotatef(angle*1.5,0,0,1);
        glutSolidTeapot(0.3);
    glPopMatrix();


    glutSwapBuffers();
    angle++;
}
int main(int argc, char *argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week05");

    glutDisplayFunc(display);
    glutIdleFunc(display);
 glutMainLoop();
}
step02-1
利用老師的opengl_TRT_demo互動程式
step03-1
#include <GL/glut.h>
float angle=0;
void myCube()
{
    glPushMatrix();
        glScaled(0.5,0.2,0.2);
        glutSolidCube(1);
    glPopMatrix();
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glColor3f(1,1,1);
    glutSolidCube(1);


    glPushMatrix();
        glTranslatef(0.5,0.5,0);
        glRotated(angle,0,0,1);
        glTranslatef(0.25,0,0);
        glColor3f(0,1,0);
        myCube();
    glPopMatrix();

    glPushMatrix();
        glTranslatef(-0.5,0.5,0);
        glRotated(angle,0,0,1);
        glTranslatef(0.25,0,0);
        glColor3f(0,1,0);
        myCube();
    glPopMatrix();



    glutSwapBuffers();
    angle++;
}
int main(int argc, char *argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week05");

    glutDisplayFunc(display);
    glutIdleFunc(display);
 glutMainLoop();
}

step03-2
看影片,上傳github



沒有留言:

張貼留言