Week05
1.登入http://irs.zuvio.com.tw/student/clickers/37585回答上周的問題
2.下載http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
data.zip-------桌面\windows\data\模型
windows.zip-----桌面\windows\Transformation.exe
glut32.dll------------桌面\windows\glut32.dll
3.茶壺 Translate Rotate Scale
#include <GL/glut.h>
void display()
{
glPushMatrix(); ///備份起來
glTranslatef(0, 0, 0);
glutSolidTeapot(0.3);
glPopMatrix(); ///還原回去
glutSwapBuffers(); ///交換繪圖的 memory buffer,才能畫出來
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("04160453 translate rotate scale");
glutDisplayFunc(display);
glutMainLoop();
}
移動
輸入float mouseX=0, mouseY=0;
輸入mouseX, mouseY
輸入
void motion(int x,int y)
{
mouseX = (x-150)/150.0;
mouseY =-(y-150)/150.0;
glutPostRedisplay(); 貼一張3M Post便利貼,告訴電腦的Glut要重畫畫面的Re display
}
輸入glutMotionFunc(motion);
程式執行會像小畫家的橡皮擦
加入glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 清掉舊畫面
縮放
輸入 glScalef(mouseX, mouseY, 0); 縮放目標大小
旋轉
輸入 rotX=0 glRotatef(rotX, 0,0,1); rotX = x;
















沒有留言:
張貼留言