課堂作業1:
到 http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/下載"data","win32","glut32.dll" 解壓縮到windlow檔案夾內
A:由下往上做,先調整車子的大小(變寬、變長、變扁),再轉換鏡頭攝影的方向,接著移動車子的位子
B:由下往上做,先調整車子的大小(變寬、變長、變扁),再移動車子的位子,接著轉換鏡頭攝影的方向
課堂作業2:
#include <Gl/glut.h>
float rotX=0;
void display()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix(); 備份Matrix(Matrix裡有translate,rotate,scale的量值)
glRotatef(rotX, 0,1,0);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPopMatrix();還原Matrix回到剛剛push的樣子
glutSwapBuffers();
}
void motion(int x,int y)
{
rotX=x;
display();glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);double buffers兩倍記憶體
glutCreateWindow("hello 3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
課堂作業3:
#include <Gl/glut.h>
float rotX=0, rotY=0;
void display()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();備份Matrix(Matrix裡有translate,rotate,scale的量值)
glRotatef(rotY, 1,0,0);Y的移動量,讓他對X軸轉
glRotatef(rotX, 0,1,0);X的移動量,讓他對Y軸轉
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPopMatrix();還原Matrix回到剛剛push的樣子
glutSwapBuffers();
}
void motion(int x,int y)
{
rotX=x; rotY=y;同時拿來用
display();glutPostRedisplay();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);double buffers兩倍記憶體
glutInitWindowSize(300,300);
glutInitWindowPosition(600,0);
glutCreateWindow("hello 3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}




沒有留言:
張貼留言