2022電腦圖學 Computer Graphics 授課教師: 葉正聖 銘傳大學資訊傳播工程系 每週主題: 程式環境、點線面顏色、移動/旋轉/縮放與矩陣(Matrix)、階層性關節轉動(T-R-T)、做出機器人、打光、貼圖、glu/glut函式、鍵盤、滑鼠、計時器(timer)、讀入3D模型、粒子系統、聲音、特效、投影矩陣、攝影機與運鏡、機器人2.0、期末作品
2022年5月4日 星期三
2022年4月19日 星期二
2022年4月12日 星期二
2022年3月22日 星期二
筆記week05
week05
keyboard
1、moodle下載freeglut
2、CodeBlocks開新的GLUT專案
3、打程式碼
#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();
}
#include <GL/glut.h>
#include <stdio.h>
float x=150,y=150,z=0,scale=1.0;
int oldX=0,oldY=0;
void display()
{
glClearColor(0.5,0.5,0.5,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef((x-150)/150.0,-(y-150)/150.0,z);
glScalef(scale,scale,scale);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void keyboard(unsigned char key,int mouseX,int mouseY)
{
}
void mouse(int button,int state,int mouseX,int mouseY)
{
oldX=mouseX;oldY=mouseY;
}
void motion(int mouseX,int mouseY)
{
if(mouseX-oldX>0)scale*=1.01;
if(mouseX-oldX<0)scale*=0.99;
oldX=mouseX; oldY=mouseY;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week05 keyboard");
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutMotionFunc(motion);
glutMainLoop();
}
2022年3月15日 星期二
筆記week04
week04
旋轉Rotate
1、到https://jsyeh.org/3dcg10/
2、下載data.zip、window.zip
3、解壓縮 把data放到windows裡面
4、選AI Capone
5、嘗試旋轉角度
week04-2
1、下載moodle-freeglut mingw檔案,libfreeglut改libglut32.a
2、codeblocks開new project-GLUT project
3、打程式碼
#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);
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("Week04 Rotate");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
2022年3月8日 星期二
筆記week03
week03
1、範例https://jsyeh.org/3dcg10/
2、下載 data,win32
windows.zip---下載\windows\Transformation.exe
data.zip---下載\windows\data\模型.obj
3、執行Transformation.exe
茶壺
1、開freeglut\lib\libfreeglut.a改成libglut32.a
2、開CodeBlocks\New Project\GLUT Project
3、打程式碼
2022年3月1日 星期二
筆記week02
week02
跑別人的範例
2022年2月22日 星期二
筆記week01
week01
0、Codeblocks 17.12 mingw裝好
1、Flie-New Project,選OPENGL專案
2、在目錄選桌面,打week01
3、Build&Run,完成
第一個GLUT專案
1、Moodle下載 freeglut 壓縮檔
2、解壓縮 桌面 freeglut目錄
3、桌面 freeglut 的 lib 裡面的 libfreeglut.a 改成 libglut32.a
4、CodeBlocks:Flie-New Project,選GLUT專案
5、取名 week01_GLUT
6、設定 GLUT 目錄 C:\Users\?????\Desktop\freeglut
7、Build&Run,完成
VERY BEAUTIFUL, VERY POWERFUL
一. 一樣先安裝且設定好freeglut,OpecCV, 開啟CodeBlocks建立新專案 week11_gundam, 把 MyGundam.zip下載解壓縮後的data資料夾放到freeglut/bin裡面 把week09_openc...
-
第一個OPENGL程式 0.Codeblocks 17.12 mingw裝好 1.File-New-Project ,選OPENGL專案 2.在[...]的目錄中,選[桌面] Projectsje nir 01_OPENGL 3.下一步,完成後Build&Run 4.可...
-
第一個OpenGL程式 1.安裝好 CodeBlocks 17.12 2. File-New-Project, 選OpenGL專案 2.在[點點點]的目錄中, 選「桌面」,Projectsje nir 01_OPENGL 3.下一步下一步,完成後,Build&Run 4...
-
今天一開始我們先學播聲音 因為沒有音檔,所以一開始應該會播錯誤訊息的音效 然而可能程式會錯誤無法播放 就必須在compilier>linker裡設定winmm 然後是MP3檔 要先去moodle下載CMP3_MCI.h 才能播放 #include <stdio.h...