2016年5月17日 星期二

Week13 林聖倫

(1)上週作業
(2)機器人robot
(3)關節轉動trt
(4)期末作品
1.打開貝殼

2.不要relative

3.

4.

5.


6.

7

8.

9.
#include <GL/glut.h>
float rot1=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glutWireCube(0.3);
        glRotatef(rot1,0,0,1);
        glTranslatef(0.6,0,0);
        glRotatef(rot1*4,0,0,1);
        glutWireCube(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x,int y)
{
    rot1=x;
    glutPostRedisplay();
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("robot");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}


10.

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

    glPushMatrix();
        glTranslatef(0.2,0,0);
        glutWireCube(0.1);
        glTranslatef(0.1,0,0);
        glutWireCube(0.1);
        glTranslatef(0.1,0,0);
        glutWireCube(0.1);
        glPopMatrix();
    glutSwapBuffers();

}

12.

13

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

    glPushMatrix();
        //glTranslatef(0.2,0,0);
        glTranslatef(0.15,0.1,0);
        glRotatef(rot1,0,0,1);
        glTranslatef(0.05,0,0);
        glutWireCube(0.1);
        glTranslatef(0.1,0,0);
        glutWireCube(0.1);
        glTranslatef(0.1,0,0);
        glutWireCube(0.1);
        glPopMatrix();
    glutSwapBuffers();

}

沒有留言:

張貼留言