2022年5月9日 星期一

week12

Step 1-1 

  1. 到jsyeh.org/3dcg10   下載window.zip  data.zip
```cpp  有個轉動的車子
glTranslatef(0.8,0,0);
glRotatef(angle,0,1,0);
```

```cpp  車子繞著中心轉
glRotatef(angle,0,1,0);
glTranslatef(0.8 , 0.0 , 0.0);

```

Step2-1

  1. GLUT專案week12_TRT
```c
#include <GL/glut.h>

float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f(1,1,1);///白色的
    glutSolidTeapot(0.3);///大茶壺
    glPushMatrix();
        glTranslatef( 0.3 , 0 , 0 );///把下面旋轉中的東西"掛在"某處
        glRotatef(angle,0,0,1);///旋轉
        glTranslatef( 0.2 , 0 , 0 );///往右下移動(把把手移到中心)
        glColor3f(1,0,0);///紅色的
        glutSolidTeapot(0.2);///茶壺
        glPushMatrix();
            glTranslatef( 0.3 , 0 , 0 );///把下面旋轉中的東西"掛在"某處
            glRotatef(angle,0,0,1);///旋轉
            glTranslatef( 0.2 , 0 , 0 );///往右下移動(把把手移到中心)
            glColor3f(1,0,0);///紅色的
            glutSolidTeapot(0.2);///茶壺
        glPopMatrix();
    glPopMatrix();
    glutSwapBuffers();
    angle+=0.05;
}
int main(int argc,char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH);///兩倍+3D
    glutCreateWindow("week12 TRT TRT");
    glutIdleFunc(display);
    glutDisplayFunc(display);
    glutMainLoop();
}
```

沒有留言:

張貼留言