W|EEK05
1. 主題: 移動、旋轉、縮放、矩陣
https://jsyeh.org/3dcg10/下載
data/zip =>下載\windows.zip =>下載\windows\data\一堆3D模型 下面區域,可以交換兩行程式碼(移動、轉動)會有自轉公轉的效果
windows.zip=>下載\windows\transformation.exe
2022電腦圖學 Computer Graphics 授課教師: 葉正聖 銘傳大學資訊傳播工程系 每週主題: 程式環境、點線面顏色、移動/旋轉/縮放與矩陣(Matrix)、階層性關節轉動(T-R-T)、做出機器人、打光、貼圖、glu/glut函式、鍵盤、滑鼠、計時器(timer)、讀入3D模型、粒子系統、聲音、特效、投影矩陣、攝影機與運鏡、機器人2.0、期末作品
W|EEK05
1. 主題: 移動、旋轉、縮放、矩陣
https://jsyeh.org/3dcg10/下載
data/zip =>下載\windows.zip =>下載\windows\data\一堆3D模型 下面區域,可以交換兩行程式碼(移動、轉動)會有自轉公轉的效果
windows.zip=>下載\windows\transformation.exe
week05
1.做出按下鍵盤按鍵印出滑鼠所在的座標
#include <GL/glut.h>
#include <stdio.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
void keyboard(unsigned char key, int x, int y)
{
printf("你按下了 %c 在 %d %d 座標\n", key, x, y);
}
int main(int argc, char**argv)
{
glutInit( &argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week05 keyboard");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMainLoop();
}
2.點擊移動
void motion(int mouseX,int mouseY)
{
if( mouseX-oldX >0) scale*= 1.01;
if( mouseX-oldX <0) scale*= 0.99;
///x+=(mouseX-oldX); y+=(mouseY-oldY);
oldX =mouseX; oldY= mouseY;
display();
}
本週課程內容:keyboard,點擊移動,點擊放大
主題:移動/旋轉/縮放/矩陣/鍵盤+滑鼠 模仿Maya,Unity的操作畫面
>>>>Rotate在Translate之前:公轉(像是繞著某點在轉)
>>>>Translate在Rotate之前:自轉
##1.按鍵盤同時顯示滑鼠座標
#include <GL/glut.h>
#include <stdio.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y){ unsigned:沒有符號 char:字母
printf("你按下了 %c 在 %d %d 座標\n",key,x,y);
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week05 keyboard");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);///鍵盤控制
glutMainLoop();
}
主題:移動/旋轉/縮放/矩陣/鍵盤+滑鼠
今天一開始老師像我們介紹電腦圖學之父Ivan Sutherland
然後一樣去https://jsyeh.org/3dcg10/網頁裡下載data和win32
打開transformation.exe後試著調整glScalef的數值
一. 一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam, 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...