WEEK5 課堂der筆記筆記
課堂作業1~~~車車(觀察每項座標變化)
2.從網址http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/中下載[data]、[win32]、[glut32.dll]

3.先解壓縮[win32]壓縮檔至桌面
4.再開啟[win32]資料夾,把[glut32.dll]與解壓後的[data]複製進去
5.開啟資料夾中的Transformation.exe ,使用綠色座標軸觀察車子移動與變形

3.先解壓縮[win32]壓縮檔至桌面
4.再開啟[win32]資料夾,把[glut32.dll]與解壓後的[data]複製進去
5.開啟資料夾中的Transformation.exe ,使用綠色座標軸觀察車子移動與變形
課堂作業2~~~有一個小茶壺(與作業3連結)
1.使用CodeBlocks開啟一個GLUT專案,前幾週作業皆有詳做
2.更改程式碼如下:
#include <GL/glut.h>
void display()
{
glPushMatrix();
glTranslatef(0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main( int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("04160382 translate rotate scale");
glutDisplayFunc(display);
glutMainLoop();
}
3.執行程式碼
課堂作業3~~~這個小茶壺走ㄚ走ㄚ走(延續作業2)
1.更改程式碼如下:
#include <GL/glut.h>
float mouseX=0, mouseY=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(mouseX,mouseY,0); //位置
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX= (x-150)/150.0;
mouseY= -(y-150)/150.0;
glutPostRedisplay();
}
int main( int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("04160382 translate rotate scale");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
2.執行程式碼,滑鼠按住拖曳可移動小茶壺
課堂作業4~~~遇到那個小茶壺長的怪怪的(延續作業3)
1.更改程式碼如下:
#include <GL/glut.h>
float mouseX=0, mouseY=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glScalef(mouseX,mouseY,0); //大小
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX= (x-150)/150.0;
mouseY= -(y-150)/150.0;
glutPostRedisplay();
}
int main( int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("04160382 translate rotate scale");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
2.執行程式碼,滑鼠按住拖曳可使小茶壺放大縮小
課堂作業5~~~小茶壺覺得暈暈的(延續作業4)
1.更改程式碼如下:
#include <GL/glut.h>
float mouseX=0, mouseY=0, rotX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX,0,0,1); //旋轉
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x, int y)
{
mouseX= (x-150)/150.0;
mouseY= -(y-150)/150.0;
rotX= x;
glutPostRedisplay();
}
int main( int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("04160382 translate rotate scale");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
2.執行程式碼,滑鼠按住左右拖曳可使小茶壺旋轉







沒有留言:
張貼留言