顯示具有 10160845_黃莉筑 標籤的文章。 顯示所有文章
顯示具有 10160845_黃莉筑 標籤的文章。 顯示所有文章

2023年6月1日 星期四

KZNK Week16 總複習

Week16-1 點線面 色彩

clone整個github倉庫,開啟Final_Project.cbp
開啟新的GLUT專案,命名week16 all
輸入以下程式碼



















Week16-2 移動

繼續同一個專案,輸入以下程式碼,可用滑鼠移動茶壺

















Week16-3 旋轉

繼續同一個專案,輸入以下程式碼,可用滑鼠以正中心旋轉茶壺


















Week16-3 TRT旋轉

繼續同一個專案,輸入以下程式碼,移動茶壺中心











Week16-4 關節轉動

繼續同一個專案,輸入以下程式碼,以手柄為中心旋轉茶壺



2023年5月25日 星期四

KZNK Week15 攝影機與運鏡

 Week15-1 攝影機

https://jsyeh.org/3dcg10/下載Examples:[source][data]、[win32],並解壓縮
data加入windows資料夾,再開啟Projection.exe

























開啟新的GLUT專案,命名
week15-1 gluPerspective
更改135~142,151行程式碼如以下
...
float eyeX=0,eyeY=0;
void motion(int x, int y){
    eyeX=3*(x-320)/320.0;week15-1 gluPerspective
    eyeY=3*(240-y)/240.0;
    glLoadIdentity();
    gluLookAt(eyeX,eyeY,3,0,0,-6,0,1,0);
    glutPostRedisplay(); ///重畫畫面
}    
...
glutMotionFunc(motoin);
...




















2023年5月18日 星期四

KZNK Week14 計時器Timer、內插

Week14-1 Timer-1 自動

clone整個github倉庫,開啟Final_Project.cbp
開啟新的GLUT專案,命名week14-1 timer
輸入以下程式碼
獲得會自動逆時針旋轉的茶壺


















Week14-2 Timer-2 鍵盤

開啟新的GLUT專案,命名week14-2 timer_play
沿用week14-1修改為以下程式碼
獲得可用空白鍵控制旋轉的茶壺
因為每30千秒移動3角度所以可以滑順旋轉


















Week14-3 Timer-3 Alpha內插

開啟新的GLUT專案,命名week14-3 timer_alpha_interpolation
開啟excel建立以下表格
































修改程式碼為以下
獲得可用滑鼠旋轉的茶壺





















Week14-4 Final Project-1

開啟Final Project修改程式碼為以下
0 頭
1 身體
2 上手臂
3 下手臂



















Week14-5 Final Project-2

繼續修改Final Project程式碼為以下

2023年5月11日 星期四

KZNK Week13 綜合練習

Week13 綜合練習

clone整個github倉庫,開啟Final_Project.cbp
專案上按右鍵出現選單點最下面的Properties...
按右下角的Project's build options...
更改Compiler和Linker
讓freeglut變相對路徑




















































開啟MAYA,將老師給的模型分成
head body uparmR uparmL lowarmR lowarmLuplegR uplegLlowlegR lowlegL 
並存成OBJ檔






















在Final_Project資料夾新建一個model資料夾並將剛才存的OBJ檔都存在裡面



















修改成以下程式碼


2023年5月4日 星期四

KZNK Week12 檔案讀寫

Week12-1 檔案讀寫-1

開啟New File並取名為week12-1 printf_fprintf.cpp
輸入以下程式碼
小黑視窗會出現Hello Word,桌面上txt檔中的文字為Hello Word






















Week12-2 檔案讀寫-2

開啟New File並取名為week12-2 scanf_fscanf.cpp
輸入以下程式碼
小黑視窗會出現
從file.txt讀到了: Hello
從file.txt讀到了: World在檔案裡














Week12-3 檔案讀寫-3

開啟New File並取名為week12-3 fopen_fclose_fprintf_fscanf.cpp
輸入以下程式碼
小黑視窗會出現數字
















Week12-4 滑鼠/鍵盤控制
開啟新的GLUT專案,命名week12-4 keyboard_mouse
輸入以下程式碼
茶壺可隨滑鼠點擊移動


















修改程式碼為以下
用滑鼠點擊紀錄茶壺位置(scanf),再按空白鍵放回之前紀錄的位置

Week12-5 工作執行目錄
修改week12-4 keyboard_mouse
先save everything
更改工作目錄設定
專案上按右鍵出現選單點最下面的Properties...
接著點第二欄的Build targets
再來找到Execution working dir 工作執行目錄 將路徑改成" . "





















再save everything
將bin資料夾裡的freeglut.dll複製到week12-4 keyboard_mouse資料夾中


















處存專案後file4.txt檔會出現在week12-4 keyboard_mouse資料夾



















開啟小黑視窗後滑鼠移動茶壺再按空白鍵,茶壺會回去之前紀錄的位置 

2023年4月27日 星期四

KZNK Week11 鍵盤、滑鼠、音樂

 Week11-1 鍵盤  

OpenCV 3咒語
安裝 OpenCV, 要記得 Add PATH
1.加上 -Search Directiories  咒語: C:\OpenCV2.1\include
2.加上 -Search Directiories  咒語: C:\OpenCV2.1\lib
3.加上 -Linker Settings        咒語: cv210 cxcore210 highgui210
Settings-Compiler-

開啟新的GLUT專案,命名week11-1 keyboard
輸入以下程式碼
用鍵盤來操作程式,if(key==27)這個鍵是Esc鍵,按下後可離開程式




















Week11-2 音樂
  
開啟新的GLUT專案,命名week11-2 keyboard_PlaySound
老師傳送的音樂資料夾放在桌面上
輸入以下程式碼
#include <windows.h>
#include <GL/glut.h>
void display()
{
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y)
{
    if(key=='1') PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\do.wav",NULL,SND_ASYNC);
    if(key=='2') PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\re.wav",NULL,SND_ASYNC);
    if(key=='3') PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\mi.wav",NULL,SND_ASYNC);
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week11");

    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMainLoop();
}

輸入1 2 3發出DO RE MI的聲音

















Week11-3 音樂撥放
  
開啟New File並取名為week11-3 PlaySound.cpp
設定咒語 SettingsCompilerLinker Settings  winmm
輸入程式碼
#include <windows.h>
#include <GL/glut.h>
int main(int argc,char**argv)
{
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\do.wav",NULL,SND_ASYNC);
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\re.wav",NULL,SND_ASYNC);
    PlaySound("C:\\Users\\Administrator\\Desktop\\do-re-mi\\mi.wav",NULL,SND_ASYNC);
    printf("Hello World\n");
}
一樣可以撥放DO RE MI











絕對路徑與相對路徑












Week11-4 自動撥放音樂

開啟新的GLUT專案,命名week11-4 CMP3_MCI_Load_Play
從第137行開始更改程式碼如以下

#include "CMP3_MCI.h" 
CMP3_MCI myMP3; 
int main(int argc, char *argv[])
{
    char filename[]="C:/Users/Administrator/Desktop/do-re-mi/suzume.mp3";
    myMP3.Load(filename);
    myMP3.Play();

要將CMP3_MCI.h也放在同個專案資料夾裡
Ctrl C+V 放入week11-4 CMP3_MCI_Load_Play資料夾
執行會有音樂



















將freeglut裡bin中的freeglut.dll放入同個專案資料夾裡(week11-4)
專案上按右鍵出現選單點最下面的Properties...
接著點第二欄的Build targets
再來找到Execution working dir 工作執行目錄 將路徑改成" . "





















音樂就會自動撥放了