顯示具有 05160965_林儒霈 標籤的文章。 顯示所有文章
顯示具有 05160965_林儒霈 標籤的文章。 顯示所有文章

2018年5月28日 星期一

(未更改)week14*小紅帽槓上大野狼

1.攝影機、投影矩陣
2.實作:gluLookAt()、glutReshapeFunc()

*下載
  -freeglut (記得載 freeglut . 更改libglut32.a)
  -http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/  (source/data/win32/glut32.dll)
  -抓取source.zip的程式碼 (glm.c(關鍵)/glm.c(關鍵)/transformation.c(範例)),放到上面所建立的Project中
  -更改glm.c -> glm.cpp / transformation.c -> transformation.cpp
  -Add two files in Project (glm.cpp / transformation.cpp)
  -在settings 的 compiler取消一個勾勾,然後把main.cpp清空(不能有兩個main())
  -build -> rebuild (ctrl-F11),檔案裡會跑出bin和obj,把data丟到freeglut的bin裡面
*測試鏡頭
  -
  -
  -
  -
  -
  -
*認識glutReshapeFunc(resize);
  -static void resize(int width, int height)
{
    const float ar = (float) width / (float) height;

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;
}
  -
  -這個透視影很怪,camera投影在中心(0 , 0 , 0),但是茶壺也在(0 , 0 , 0),所以看不到
  -gluperspective()也投影在(0 , 0 , 0)
  -
  -新增gluLookAt(0 , 0 , 2 ,   0 , 0 , 0 ,    0 , 1 , 0) ; ,在glMatrizMode() ; 之後
  -
  -try gluLookAt();
  -
  -
  -
*總結
  -
  -
  -
  -
  -
  -

2018年5月21日 星期一

(未更改)week*13小紅帽槓上大野狼

1.寫檔、讀檔
2.控制關節
3.動作內插

*上禮拜考試
  -
  -
*如何開啟檔案
  -//先開一個沒有專案的空白檔案
#include <stdio.h>///使用標準standard輸入輸出IO
int main()
{
    FILE * fout=fopen("output.txt","w+");
    ///FILE * 檔案指標 fout
    ///       檔案 file
    ///       open開啟
    ///       "要開啟的檔名","w+"表表示要寫/+檔案

    printf("Hello world\n");///大一上程式設計week-01
    fprintf(fout,"Hello world\n");///大一下教過,大二下正式用
}
  -
  -int n;
    scanf("%d",&n);///只是故意讓程式卡住,檔案就沒有正常關閉
    ///檔案長度就會是0
  -
  -    fclose(fout);///如果有關閉檔案
*輸出角度
  -fprintf(fout,"%0.3f %.3f %.3f\n",angle,angle2,angle3);
    ///要朽出許多的關節角度,就多的%.3f對應後面的變數
    ///前面有幾個%%%後面就有幾個變數,%.3f表示是float且小數點後3位
  -
  -
*
  -
  -

2018年5月14日 星期一

(未更改)week*12小紅帽槓上大野狼

小考:T-R-T觀念
PlaySound ,、MP3播放
計時器Timer
內插、線性內插、動畫


*老師小考講解
  -
  -
*把資料放在專案目錄裡面
  -把原本放在freeglut\bin目錄中的資料,放在CodeBlocks的專案中
  -把專案中的xxx.cbp,用notepad++更改working_dir,用小數點表示
  -
*wav檔
  -在 main 函式中加入 PlaySound( " xxx.wav " , NULL , SND_ASYNC );
  -宣告 #include <mmsystem.h>
  -
*mp3檔
  -
  -用上述方法無法打開mp3檔
  -需要在 moodle / 課堂作業 / 載 CMP3_MIC.h / 放入 codeblocks 專案中
  -
  -在 main 函式中輸入 myMP3.Load( "xxx.mp3");
                                      myMP3.Play();
  -宣告 #include "CMP3_MCI.h"
  -
*計時器Timer
  -在 mian 函式中,加入glutTimerFunc(    4000   ,   timer   ,    0   ); //now:使用計時器,第一個鬧鐘,4秒
                                                                      等多久 , 函式 , 參數
  -此函式要在 glutCreatWindow();之後      glutMainLoop();之前
  -
  -宣告一個 void timer ( int t ) //now:計時器的函式
{
    glutTimerFunc(2000, timer,0); // now:使用計時器,下一個鬧鐘,2秒
    PlaySound("xxx.wav",NULL,SND_ASYNC);// now:
}
*內插公式:交插相乘
  -
  -

*內插程式
  -
  -
  -
  -
  -
  -
  -
  -
  -
  -

2018年5月7日 星期一

(未更改)week*11小紅帽槓上大野狼

1.聲音/ 音效.音樂
2.實作:PlaySound(),CMP3_MCI.h
3.鍵盤鋼琴.射擊遊戲
4.複習貼圖+TRRT.下周小考

*音檔
  -上網載wav音檔,放入freeglut/bin中
  -
*code
  -新增 #include <mmsystem.h>
  -在int main()函式中新增,PlaySound("檔名.wav",NULL,SND_ASYNC);
  -SND_SYNC要等、SND_ASYNC不要等(不同步)
*音檔打不開
  -喇叭播放位置不正確
  -
  -檔案名稱不正確
  -取消-隱藏已知檔案類型的副檔名
  -
*貝殼專案
  -選C
  -
#include <stdio.h>
#include <windows.h>
#include <mmsystem.h>
順序很重要

int main()
{
    PlaySound("ambul.wav",NULL,SND_SYNC);
    printf("Hello world!\n");
    return 0;
}
  -Build option-Linker settings-新增winmm
  -
  -音檔要抓到專案裡
  -
*程式碼
  -void mouse(int button,int state,int x,int y)
   {
        if(state==GLUT_DOWN) PlaySound(檔名.wav",NULL,SND_ASUNC);
   }mouseu要按下去,才發出聲音,如果沒有,按下去跟放開都會有聲音
不同步
  -
  -
  -要記得按Activate project,才能彈鋼琴
  -