1.今天複習上次的,一樣先到http://jsyeh.org/3dcg10 下載
windows.zip data.zip glut32.dll 這三檔案 並解壓縮,再把glut32.dll和data
丟到windows資料夾裡,然後執行transformation.exe

2.口訣,開始畫一個車子>放大縮小(一個車子)>旋轉(一個放大縮小的車子)>移動(整個)

上課實作2
1.打開codeblock 開一個新專案
重新打一個新的程式碼,改變圓球的位置
glPushMatrix();
///glTranslated(-2.4,1.2,-6);
///glRotated(60,1,0,0);
///glRotated(a,0,0,1);
glTranslated(0,0,-6);///先把樓上註解,移動Z:-6
glutSolidSphere(1,slices,stacks);
glPopMatrix();
讓這顆球到中心

2. 現在要把其他圖形都變白色,然後轉動紅色的球
///把其他的都變白色
glColor3f(1,1,1);
glPushMatrix();
glRotated(a,0,0,1);///轉動囉!
glTranslated(-2.4,1.2,-6);///把下面轉動的球,整個移動左上角
glutSolidSphere(1,slices,stacks);
glPopMatrix();

上課實作3
1.今天學讓茶壺柄旋轉倒茶
先貼上茶壺程式碼
#include <GL/glut.h>
float angle=0;///Now: 讓茶壼自動轉動的角度
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///Now:備份矩陣
glRotatef(angle, 0,0,1);///Now:轉動
glutSolidTeapot(0.3);
glPopMatrix();///Now:還原矩陣
glutSwapBuffers();
}
void motion(int x, int y)
{
angle=x;///Now: 改變角度
glutPostRedisplay();///Now: 請 重畫畫面
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Week05 TRT");
float angle=0;///Now: 讓茶壼自動轉動的角度
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///Now:備份矩陣
glRotatef(angle, 0,0,1);///Now:轉動
glutSolidTeapot(0.3);
glPopMatrix();///Now:還原矩陣
glutSwapBuffers();
}
void motion(int x, int y)
{
angle=x;///Now: 改變角度
glutPostRedisplay();///Now: 請 重畫畫面
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Week05 TRT");
glutDisplayFunc(display);
glutMotionFunc(motion);///Now:
glutMainLoop();
}
glutMotionFunc(motion);///Now:
glutMainLoop();
}

沒有留言:
張貼留言