2024年5月16日 星期四

week13

 #week13

##week13-1_glm_gundam_keyboardID_mouse_motion_angle

1. 先設定好環境


2. 安裝 freeglut 再把 lib\libfreeglut.a 複製成 libglut32.a


3. 安裝 opencv 2.1, 記得要 Add PATH, 不要設目錄


4. 關閉重開 CodeBlocks (才會把 PATH 設定設好 要記得存檔)


5. -Search directories 的 Compiler 對應 C:\OpenCV2.1\include


6. -Search directories 的 Linker 對應 C:\OpenCV2.1\lib


7. -Linker setting 要加 cv210 cxcore210 highgui210


8. 再把 GitHub 的程式下載, 再把 week12-3_glm_gundam_keyboardID_mouse_motion_angle拿來改
加上glutMouseFunc(mouse);,glutMotionFunc(motion);


##week13-2_FILE_fopen_fprintf_fscanf
1.把week13-1複製整個目錄
改目錄,改.cbp檔,Notepad++改名稱
2.要加File
FILE * fin = NULL;
FILE * fout = NULL;
3.在motion()裡,要加一段程式
```cpp
   void motion(int x,int y){
    angle[angleID]+=y-oldY;
    oldX=x;
    oldY=y;
    glutPostRedisplay();
    if(fout==NULL) fout=fopen("angle.txt","w+");
        for(int i=0;i<20;i++){
        printf("%.1f ",angle[i]);
        fprintf(fout,"%.1f ",angle[i]);
    }
    printf("\n");
    fprintf(fout,"\n");
}
執行程式時,用mouse motion 一邊改變角度,一邊大量產生角度值,小黑關掉後,可在目錄裡,看到angle.txt,裡面就是剛剛印的一堆數值
小心,angle.txt 裡面ˋ要有空格,不然就錯了。printf()及fprintf()要加"%.1f"
現在要讀
```cpp
void keyboard(unsigned char key ,int x,int y){
   if(key=='r'){
        if(fin==NULL) fin=fopen("angle.txt","r");
        for(int i=0;i<20;i++){
           fscanf(fin, "%f",& angle[i]);
        }
        glutPostRedisplay();
    }



新增body,body空指標 GLMmodel * body = NULL;
多加幾個關節



沒有留言:

張貼留言