一樣到教材 jsyeh.org/3dcg10
下載3個檔案>Transformation
去做交換Swap,寫下差別!

右鍵Swap練習不同的旋轉!
(A)移動 glTranslatef (B)旋轉 glRotatef
旋轉 glRotatef 移動 glTranslatef
縮放 glScalef 縮放 glScalef
*差別:

Swap↓↓↓

課堂作業2:
茶壺旋轉了~


#include <gl/glut.h>
float rotX=0;
void display()
{
glClearColor(0,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0,1,0);
glColor3f(1,1,1);
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("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
///glutMouseFunc(mouse);
glutMainLoop();
}
課堂作業3:
Q1什麼是Buffer?
Q2什麼是Double?

*Google>Image圖片

課堂作業4:
Q1什麼是Push Pop?
Q2什麼是Matrix?

#include <gl/glut.h>
float rotX=0, rotY=0;
void display()
{
glClearColor(0,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotY, 1,0,0);///旋轉 角度rotY, 軸(1,0,0)X軸
glRotatef(rotX, 0,1,0);///旋轉 角度rotX, 軸(0,1,0)Y軸
glColor3f(1,1,1);
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);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
///glutMouseFunc(mouse);
glutMainLoop();
}
*Google>Image圖片
*視窗變大
#include <gl/glut.h>
float rotX=0, rotY=0;
void display()
{
glClearColor(0,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotY, 1,0,0);///旋轉 角度rotY, 軸(1,0,0)X軸
glRotatef(rotX, 0,1,0);///旋轉 角度rotX, 軸(0,1,0)Y軸
glColor3f(1,1,1);
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);
glutInitWindowPosition(700,0);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
///glutMouseFunc(mouse);
glutMainLoop();
}

沒有留言:
張貼留言