#week13-1_glm_gundam__keyboard_angleID_mouse_motion_angle
先準備上課環境
0.freeglut 安裝
1.OpenCV 2.1 安裝
2.重開 CodeBlocks,設定 Compiler-Setting的3個設定
- C:\OpenCV2.1\include
- C:\OpenCV2.1\lib
-cv210 cxcore210 highgui210
再把上周的week12-3_glm_gundam__keyboard_angleID_mouse_motion_angle拿來用
0.改目錄名
1.把float angle=0;改成
#week13-2_FILE_fopen_fprintf_fscanf
1.把week13-1複製整個目錄,改目錄名,改.cbp名,Notepad++改裡面的Title
2.要加FILE指標
'''cpp
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裡面就是剛剛印的一堆數值
現在,要讀
'''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();
}
'''
可以動三個關節
沒有留言:
張貼留言