youtobe 影片連結:https://www.youtube.com/watch?v=9XTst_1Ijk0
會跳舞的機器人
2017電腦圖學 Computer Graphics 授課教師: 葉正聖 銘傳大學資訊傳播工程系 每週主題: 程式環境、點線面顏色、移動/旋轉/縮放與矩陣(Matrix)、階層性關節轉動(T-R-T)、做出機器人、打光、貼圖、glu/glut函式、鍵盤、滑鼠、計時器(timer)、讀入3D模型、粒子系統、聲音、特效、投影矩陣、攝影機與運鏡、機器人2.0、期末作品
2017年7月1日 星期六
2017年6月12日 星期一
David_Sprite note
1介紹今天內容 直播
2示範 myEarth.zip變 背景貼圖
freeglut裝桌面\freeglut\include
\lib
\bin
openCV2.1裝C:\OpenCV2.1\include
\lib
\bin
把display裡 註解掉(///) 畫地球
glBegin(GL_POLYGON)
glTexCoord2f(0,0);glVertex3f(-1,+1,0);
glTexCoord2f(1,0);glVertex3f(+1,+1,0);
glTexCoord2f(1,1);glVertex3f(+1,-1,0);
glTexCoord2f(0,1);glVertex3f(-1,-1,0);
glEnd();
解說整學期 Zuvio
講解 期末作品 背景貼圖 打光
2示範 myEarth.zip變 背景貼圖
freeglut裝桌面\freeglut\include
\lib
\bin
openCV2.1裝C:\OpenCV2.1\include
\lib
\bin
把display裡 註解掉(///) 畫地球
glBegin(GL_POLYGON)
glTexCoord2f(0,0);glVertex3f(-1,+1,0);
glTexCoord2f(1,0);glVertex3f(+1,+1,0);
glTexCoord2f(1,1);glVertex3f(+1,-1,0);
glTexCoord2f(0,1);glVertex3f(-1,-1,0);
glEnd();
講解 期末作品 背景貼圖 打光
2017年6月5日 星期一
David-Sprite note
用Excel做內差公式
1.內差公式 函式加入
2.Timer函式 準備好
X*新+(1-X)*舊
1.內差公式 函式加入
3.讓機器人跟著計時器轉動
複習:
寫檔案
#include <stdio.h>
FILE*fout=NULL;//檔案指標
...在keyboard()中
if(key=='s'||key=='s')
{
if(fout==NULL) fout=fopen("file.txt","wt");
fprintf(fout,"%3f %3f %3f %3f %3f\n",angle[0]....);
}
2017年5月22日 星期一
David-Sprite note
做出手隨著身體旋轉
用一個
glPushMatrix();
glPopMatrix();
將整個括號起來 再寫glRotatef(angle,0,1,0);
外面設 float angle; void裡 angle+=1;
計時器 在main()裡面
寫入glutTimerFunc( 0 , time , 0);
等多久,叫誰,參數
{
glutTimerFunc(100, timer, t+1);///先撥下一個鬧鐘
angle++;///做了要做的事
printf("現在時間是 %d, 我起床了, 等一下鬧鐘會再叫一下哦 ", t);
glutPostRedisplay();///提醒電腦,有空要畫一下畫面哦
printf("... 然後我就又睡了....\n");
}///再度沈睡
用一個
glPushMatrix();
glPopMatrix();
將整個括號起來 再寫glRotatef(angle,0,1,0);
外面設 float angle; void裡 angle+=1;
計時器 在main()裡面
寫入glutTimerFunc( 0 , time , 0);
等多久,叫誰,參數
#include <stdio.h>
void timer(int t)///計時器叫的時候, 要做什麼呢?{
glutTimerFunc(100, timer, t+1);///先撥下一個鬧鐘
angle++;///做了要做的事
printf("現在時間是 %d, 我起床了, 等一下鬧鐘會再叫一下哦 ", t);
glutPostRedisplay();///提醒電腦,有空要畫一下畫面哦
printf("... 然後我就又睡了....\n");
}///再度沈睡
2017年5月15日 星期一
David-Sprite notes
老師小考試範
glPushMatrix();
glTranslatef();再移動會旋轉的軸掛上///3
glRotatef();做旋轉angle角度 逆時針為正 順時針為負///2
glTranslatef();把旋轉中心 放在畫面中間///1
drawArm();畫畫
glPopMatrix();
用opencv 開圖片
1.安裝opencv-2.1.0-vs2008.exe
2.確認 C;\opencv2.1\include\opencv\很多.h檔
3.新增貝殼專案 File-New-Project
用程式秀出自己的圖片
2017年5月8日 星期一
David-Sprite notes
jsyeh.org/3dcg10 下載
data.zip 桌面\windows\data\模型.obj
windows.zip 桌面\windows\projection.exe
glut32.dll 桌面\windows\glut32.dll
gluLookAt ( eyeX,eyeY,eyeZ) 改~
centreX,centerY,centerZ
upX,upY,upZ
用CodeBlocks開起 GLUT 將程式碼改寫以下
可旋轉的運鏡
2017年5月1日 星期一
David-Sprite notes
去google下載: 3D Exporation (3D的檔案總管)
3D Exporation1.81(橘色免費試用版) 別在家裡安裝!!
匯出OpenGL Sample APP
File-save as 選cpp OpenGL....(在某目錄存下來勾 匯出 ExopratDialog出現框框)
選Sample APP.
去 jsyeh/3dcg10/ 下載 data.zip
用3D Exporation開啟 data 模型
用CodeBlock的 OPenGL 開啟Soccerball.cpp
開啟myGLMsample.zip 的.cpp檔
匯出海豚 存在User/myGLMsample/data裡面
2017年4月24日 星期一
David_Sprite notes
玩遊戲射擊 google: NeHe Lesson 32
下載 Lesson32 最下面有visual c++ 範例
解壓縮 \Lesson32\lesson32.exe
ESC 退出遊戲
加入聲音:
GLUT 程式寫入
#include <mmsystem.h>
void mouse(int button,int state,int x,int y)
{
PlaySound("C;\\Users\\user\\Desktop\\Lesson32\\data/shot.way",NULL,SND_ASYNC);
}
int main()裡面 加入 glutMouseFunc(mouse);
加入 keybroad(小鋼琴)
int keyboard(unsigned char key,int x,int y)
{
if(key=='1')PlaySound("DO.WAV",NULL,SND_ASYNC);
if(key=='2')PlaySound("RE.WAV",NULL,SND_ASYNC);
if(key=='3')PlaySound("MI.WAV",NULL,SND_ASYNC);
if(key=='4')PlaySound("FA.WAV",NULL,SND_ASYNC);
if(key=='5')PlaySound("SO.WAV",NULL,SND_ASYNC);
}
int main() 加入
myMP3.Load("C:\\Users\\user\\Desktop\\music\\XXXXXX.mp3"); \\\路徑
myMP3.Play(); \\\開啟後 直接撥放
2017年4月17日 星期一
David-Sprite notes
到老師網頁 jsyeh.org/3dcg10 下載
source.zip(glm.h,glm.cpp)
{
windows.zip 桌面\windows\Transformation.exe
data.zip 桌面\windows\data\soccerball.obj
glut32.dll 桌面\windows\glut32.dll
}
1.切換模型
2.開啟soccerball.obj v開頭 vertex vt開頭 vertex texture coordinate
.mtl vn開頭 vertex normal f開頭 face
(Notepad++ 按右鍵開啟)
source.zip(glm.h,glm.cpp)
{
windows.zip 桌面\windows\Transformation.exe
data.zip 桌面\windows\data\soccerball.obj
glut32.dll 桌面\windows\glut32.dll
}
1.切換模型
2.開啟soccerball.obj v開頭 vertex vt開頭 vertex texture coordinate
.mtl vn開頭 vertex normal f開頭 face
(Notepad++ 按右鍵開啟)
滑鼠右鍵 可以換圖片
用maya匯出OBj檔
老師的myGLMsample.zip解開 freeglut.zip 桌面\freeglut\include
\lib
\bin
研究老師的程式介紹
2017年4月10日 星期一
David_Sprite note
1.期中模擬考 必背10行
glPushMatrix();///備份矩陣
glRotatef(angle,x,y,z);///旋轉
glTranslatef(x,y,z);///移動
glScalef(x,y,z);///縮放
glBegin(GL_POLYGON);///開始畫
glColor3f(r,g,b);///顏色
glVertex3f(x,y,z);///頂點
glNormal3f(nx,ny,nz);///打光的法向量
glTexCoord2f(tx,ty);///貼圖的座標
glEnd();///結束畫
glPopMatrix();///還原矩陣
2.畫出 有陰影的茶壺
#include <GL/glut.h>
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_position[] = { 2.0f, 5.0f, -5.0f, 0.0f };
const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f };
const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f };
const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat high_shininess[] = { 100.0f };
/* Program entry point */
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glClearColor(1,1,1,1);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess);
glutMainLoop();
return EXIT_SUCCESS;
}
3.讓茶壺 可以旋轉
用glPushMatrix(); glPopMatrix();包住程式 int main()裡頭寫上glutIdleFunc(display);
4.練習 其他形狀 Cone Cube Sphere...
2017年3月27日 星期一
David-Sprits note
1.將data資料夾 丟到windows裡面,glut32.dll也是 之後開啟 Transformatio
可以拉動XYZ軸改變車子的方向
可以拉動XYZ軸改變車子的方向
2.介紹期中考考題
3.旋轉 、 移動旋轉
口訣: 左耳碰左肩 從下往上讀 畫圈圈
2017年3月20日 星期一
David_Sprite note
1.到老師網址 jsyeh.3dcg10 下載 win32 data glut32.dll
將win32解壓縮 把data內的資料夾 和 glit32.dll放入win32裡面
win32裡面 打開Transformation
將win32解壓縮 把data內的資料夾 和 glit32.dll放入win32裡面
win32裡面 打開Transformation
2.用code打開freeglut 將程式碼改寫成
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.5,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("04160435 Translate Rotate Scale");
glutDisplayFunc(display);
///glutMouseFunc(mouse);
///glutMotionFunc(motion);
glutMainLoop();
}
3.讓滑鼠可以拖曳茶壺
加入float mouseX=0, mouseY=0;宣告
改寫glTranslatef(mouseX,mouseY,0);
寫入函式
void motion(int x,int y)
{
mouseX = (x-150)/150.0;
mouseY = -(y-150)/150.0;
glutPostRedisplay();
}
int main 加入glutMotionFunc(motion);
4.改寫glTranslatef(mouseX,mouseY,0); 為glScalef(mouseX,mouseY,0);
讓滑鼠可將茶壺變形
訂閱:
文章 (Atom)
















































