week13
## week13-1_gundam_keyboard_angleID_mouse_motion_angle
先準備上課環境
freeglut
openCV
Setting-Compiler 要加入 OpenCV 相關的3個設定
-compiler 的 incldue 要加入 C:\OpenCV2.1\include
-linker 的lib 要加入 C:\OpenCV2.1\lib
-linker 設定 要加入 cv210 cxcore210 highgui210
拿上週的week12-3_glm_gundam_keyboard_angleID_mouse_motion_angle
1. 把 week13-1複製整個目錄
改目錄名
要加FIEL指標
```cpp
#include <stdio.h>
FILE * fin = NULL;
FILE * fout = NULL;
```
在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])
}
print("\n");
fprintf(fout, "\n");
}
```
執行程式時, 用 mouse motion 一邊改變角度, 一邊大量產生角度直
小黑關掉後, 可在目錄你, 看到 angle.txt 裡面就是剛剛印的一堆數值
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();
}
}
沒有留言:
張貼留言