1.期中考:OpenGl必備10函式(其實是11行)
2.複習:移動、旋轉、縮放
3.主題:T-R-T旋轉(改變旋轉軸)
4.主題:glut
●Transformation.exe 自轉 V.S. 公轉
glTranslatef(....) glRotatef(...)
glRotatef(...) glTranslatef(....)
可移動的三角形:
#include <GL/glut.h>
float angle=0;
void display(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0,0.5,0);
glutSolidTeapot(0.3);
glPopMatrix();
glPushMatrix();
//glutSolidSphere(0.3,30,30);
glPopMatrix();
glPushMatrix();
glTranslatef(0.50,0.625,0);
glRotatef(angle,0,0,1);
glTranslatef(0.6,0,0);
glRotatef(-90,0,1,0);
glutSolidCone(0.2,0.6,30,30);
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 TRT");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
茶壺旁的3角形可旋轉
沒有留言:
張貼留言