2023年3月9日 星期四

4binggreen

 week04

到https://jsyeh.org/3dcg10/

下data,windows 


先將window解壓縮 data拉進window裡

開啟transformation.exe


y 軸 右手比個讚


x軸 向下

z軸 右邊向上
xy軸都設為1 人會向右下轉


week04-1 



week04-1_rotate_light

複製126-134行和156-172行
有打光且會旋轉的茶壺





translatef轉動整個世界
rotatef轉動物品角度
scalef改變物品大小



week04-1_rotate_translate



再增加一個茶壺



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

    glPushMatrix();
        glRotatef(angle,0,1,0);
        glTranslatef(0.5,0,0);
        glColor3f(1,1,0);
        glTranslatef(0,0.5,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
    angle++;
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);

    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("week04");
    glutDisplayFunc(display);
    glutIdleFunc(display);

    glutMainLoop();
}

沒有留言:

張貼留言