2019年4月25日 星期四

ˊ_>ˋ_week10

(1)期中考:OpenGL必背10函式
(2)複習:移動 旋轉 縮放





(3)主題:T-R-T旋轉  (改變旋轉軸)
先把中心從手肘移到肩手關節處(以肚臍為中心),再把整隻手移到肩手關節處。

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

    glPushMatrix();
        glTranslatef( 0.51, 0.63, 0 );  ///(3)希望把會動的手 移到茶壺中心
        glRotatef(angle, 0, 0, 1);   ///(1)這是手的旋轉
        glTranslatef(0.6,0,0); ///(2)這是把旋轉中心,移到畫面的中心

        glRotatef(-90, 0, 1, 0);   ///(1)這是手的旋轉
        glutWireCone(0.1, 0.6, 10, 10);
    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("week10 ");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}
(4)主題:glut




沒有留言:

張貼留言