教材:jsyeh.org/3dcg10
點選window裡的Transformation

3.右鍵Swap translate/rotate 看有什麼差別


Q1.在右邊轉
Q2.開動車子在繞著鍋子中心

從begin開始
程式右下往上跑
改變大小 →改變位置 →改變旋轉
(移動到旁邊的車子 繞很大一圈旋轉)
像整個鍋子在旋轉
先改變大小→改變旋轉→改變位置
(旋轉完的車子做移動)
旋轉是沿著畫面中心做旋轉
課程作業二
用codeblock可讓茶壺旋轉

#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0, 1, 0);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion (int x, int y)
{
rotX=x;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Hello 3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
課程作業三
Q1.什麼是Buffer
A1:緩衝記憶體
Q2什麼是Double Buffer
A2: 兩倍的緩衝記憶體
課程作業四
用codeblock可讓茶壺上下旋轉並改大小

#include <GL/glut.h>
float rotX=0,rotY=0;
void display()
{
glClearColor(1,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 1, 0, 0);
glRotatef(rotX, 0, 1, 0);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion (int x, int y)
{
rotX=x ,rotY=y;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(600,600);
glutInitWindowSize(700,0);
glutCreateWindow("Hello 3D");
glutMotionFunc(motion);
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言