WEEK04
1.:主題: Rotate旋轉
https://jsyeh.org/3dcg10/下載
data.zip=>下載\windows.zip=>下載\windows\data\一堆3D模型
windows.zip=>下載\windows\transformation.exe
2.測試角度glRotate(角度)(x.y.z)
安培右手定則
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPopMatrix();
glRotated(90,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 Rotate");
glutDisplayFunc(display);
glutMainLoop();
}
#include <gl/GLUT.H>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPopMatrix();
glRotated(90,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 Rotate");
glutDisplayFunc(display);
glutMainLoop();
}
MOTION
float angle=0,oldX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPopMatrix();
glRotated(90,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
angle += (x-oldX);
oldX= x;
display();
}
void mouse(int button,int state, int x, int y)
{
oldX= x;
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 Rotate");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
沒有留言:
張貼留言