- 旋轉
Transformation
- 至https://jsyeh.org/3dcg10 下載data , win32
- windows.zip解壓縮 >> windows / transformation.exe
- data.zip解壓縮 >> windows / data / 模型obj
- 把data檔案放進windows >> 執行transformation.exe
右手大拇指決定旋轉方向
=========================================================================
moodle下載freeglut.zip >> 解壓縮至桌面 >> freeglut資料夾 >> lib >> 將libfreeglut.a複製貼上 >> 重新命名libglut32.a (此步驟才能讓codeblocks跑)
codeblocks 17.12 >> file >> new >> project >>選GLUT >> 存桌面 >> next >> 設定GULT目錄(如圖) >> 跑程式
將程式碼都刪掉 >>
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(90,0,0,1);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc,char** argv){
glutInit( &argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("第4週的程式");
glutDisplayFunc(display);
glutMainLoop();
}
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///備份矩陣
glRotatef(angle,0,0,1);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();///還原矩陣
glutSwapBuffers();
}
void motion(int x,int y)
{
angle = x;
display();///重畫畫面
}
int main(int argc,char** argv){
glutInit( &argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("第4週的程式");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
#include <GL/glut.h>
float angle=0,oldX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///備份矩陣
glRotatef(angle,0,0,1);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();///還原矩陣
glutSwapBuffers();
}
void motion(int x,int y)
{
angle += (x-oldX);
oldX=x;
display();///重畫畫面
}
void mouse(int button,int state,int x,int y)
{
oldX = x;
}
int main(int argc,char** argv){
glutInit( &argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("第4週的程式");
glutDisplayFunc(display);
glutMotionFunc(motion);///mouse motiom動
glutMouseFunc(mouse);///mouse按下去 放開來
glutMainLoop();
}
沒有留言:
張貼留言