顯示具有 04162523_劉旆君 標籤的文章。 顯示所有文章
顯示具有 04162523_劉旆君 標籤的文章。 顯示所有文章

2017年6月6日 星期二

Week16 劉旆君的上課筆記

●用Excel 試內插公式
 
 
 
內插公式 : A2*(新)+(1-A2)*(舊)
 
●使用同學的範例來改程式
 
step1:
先用notepad++將地址改成自身電腦的加上下載freeglut才可開啟檔案
 
 
step2:
 
改寫程式部份
 
step3:
 
Run一次並用s儲存我們想要的動作
 
step4:
 
並發現資料夾裡產生一文字檔(file.txt),儲存完上步動作會發現產生了1KB
 
step5:
 
加入讀入資料的程式碼
 
step6:
 
開啟file檔可重複動作
 
step7:
 
依據上面所儲存動作點取R連後面亂碼也可更改成自己想輸入的字
 
 
 
 
 
 
 
 

2017年5月23日 星期二

Week14 劉旆君的上課筆記

 
●用同學範例
 
step1:
 
.cbp專案檔用Notepad++開
include目錄.lib目錄設對
working目錄.設"."(英文句點)
 
 
step2:
 
Build & Run
 
 
●Timer計時器
 
step1:
 
在main( )裡
glutDisplayFunc(display);
glutTimerFunc(2000,timer,0);
//2000為兩秒,以次類推
//timer是呼叫函式出來
//0為參數設為0
 
step2:
 
在上面要先標註
void timer(int t)
{
printf("blah blah blah,t是%d",t);
glutTimerFunc(100,timer,t+1);
printf("blah blah blah.....");
angle++;
glutPostRedisplay();
}
 

 
step3:
 
執行結果
 
 
 
●調整機器人的關節使其開始轉動
 
step1:
先縮減程式使其比較明顯
 
step2:
經常把程式暫註解讓畫面乾淨好判斷數字
ex↓
drawBody();
drawArm0();
 
在main函式上方先標註

下方就可以 輕鬆用Draw的方式來帶進主函式裡
 
step3:
 
執行程式
 
tip:先把上手臂搞定在把下手臂搞定
 
●讓機器人能夠設定擺pose
 
step1:
 
 
step2:
 
執行程式
 
完成後即可用滑鼠來操控機器人的手臂
 
 
 
 

2017年5月16日 星期二

Week13 劉旆君的上課筆記

 
●小考 T-R-T概念
 
 
glPushMatrix( );
                                                             glTranslatef( );//(3)手肘中移動掛到真的世界畫面裡;
                                    glRotatef( ); //(2)旋轉(要想右手定則);
                                            glTranslate( ); //(1)把手軸移到畫案中心點;
         drawhand( ); //(0)畫手;
glPopMatrix( );
 
●讀圖檔
 
step1:
 Google openCV2.1下載
記得小心設定PATH第三個
 
 
step2:
 
CodeBlock 新專案
右上角Console App 貝殼專案
設定專案 Build Options 設定
 
#include <openCV/highgui.h>
int main()
{
 IplImage * img = cvLoadImage("圖檔");
    cvShowImage("my2DImage",img);
    cvWaitKey(0);
}
 
 
 
●轉動地球
 
 
●把地球變成茶壺圖形
 


2017年5月9日 星期二

Week12 劉旆君上課筆記

 
●播MP3最簡單
 
step1:
 
#include "CMP3_MCI.h" //(1)檔案放同目錄
 CMP3_MCI  myMP3; //(2)宣告變數
 
int main(....) //(3)Load檔案
{                                       
        myMP3.Load("音樂mp3");
myMP3.Play( ); //(4)Play播放
 
//小心,要卡住;
                                                       }
 
 
step2:再新增一glut project
 
 
step3:置入step1的程式帶入音樂
 
 
●運鏡
 
step1:
 
data.zip   windows.zip   glut32.dll
 
step2:
 

 
step3:
 
 
step4:
 
glMatrixMode(GL_PROJECTION); //臨時切換成投影projection矩陣來調整
glLoadIdentity(  );
gluPerspective(60, 1,  0.001,  10000);
///fov :field of view視野的視角
glMatrixMode(GL_MODEVIEW);


2017年5月2日 星期二

Week11 劉旆君的上課筆記

 
●3D Exploration
 
 
step1:查詢3D Exploration後下載1.81免費試用版(4.5MB)安裝
 
 
step2: jsyeh/3dcg10/ 有data.zip解在桌面\data\ (有3D模型)
 
step3:用3D Exploration 去看模型
 
step4:匯出cpp(OpenGL)程式
 
step5:CodeBlocks 偷天換日 Remove移除 main.c
                                             Add新增  rosevase
 
      記得有2行錯誤刪掉Build&Run
 
 
 
 
●用3D Exploration來拆模型
 
 step1:
Save As:Wavefront OBJ檔
可調Visible區域才存
 
Dolphins.obj→Dolphins1.obj.mtl
                        Dolphins2.obj.mtl
                        Dolphins3.obj.mtl
 
 
step2: myGLMsample範例拿來用
安裝freeglut在:C:\users\user\Desktop\freeglut\lib
                                                                                   \include
                                                                            \bin
 
 
step3:重疊三隻海豚
 
step4:調整海豚的位置
 
step5:可下載3D模型來試用以上內容,配合Maya課程來做搭配學習
ex:Turbosquid、AssetStore


2017年4月25日 星期二

Week10 劉旆君的上課筆記

●  Maya匯出OBJ模型
 
jsyeh.org/3dcg10 下載
 
Part1
 
source.zip →下載\windows\ glm.c  glm.h  transformation.c
windows.zip →下載\windows\ transformation.exe
data.zip →下載\windows\data\ soccerball.obj  soccerball.mtl
gult32.dll →下載\windows\glt32.dll
 
Part2
 
用右鍵Notepad++開啟  soccerball.obj
                                        soccerball.mtl
 
Part3
 
myGLMsample.zip解壓縮
開啟04160011_hw1.cbp
 
*要記得裝freeglut在桌面才能改變模型圖案. \freeglut
 
 
 起初開啟圖案↓
 
將文字改為"rose+vase",注意要匯入圖形有的圖案才能夠填入顯現↓
 
改變後的樣貌↓
 
●射擊遊戲
 
先在Google: NeHe Lesson32
 
射擊遊戲 Lesson32.zip解壓
執行Lesson32.exe應用程式
 
 
●WAV音效 MP3音樂
 
開頭加上#include <mmsystem.h>表頭檔

          再找尋音效
     "檔名.WAV"NULL,SND_ASYNC
 

 

2017年3月28日 星期二

Week06 劉旆君的上課筆記

●練習期中考題
glPushMatrix( ); //備份矩陣
glRotatef(angle , x , y , z); //旋轉
glTranslate(x , y , z); //移動
glScalef(x , y , z); //縮放
glBegin(GL_POLYGON); //開始畫
glNormal3f(nx, ny, nz); //打光的法向量
glTexCoord2f(tx, ty); //貼圖座標
glColor3f(r,  g , b); //顏色
glVertex3f(x,y,z); //頂點
glEnd( ); //結束畫
glPopMatrix( ); //還原矩陣
●理解旋轉
先將   

windows.zip      data.zip   glut32.dll

下載後會看到此圖即可觀察理解旋轉狀況

glTranslatef( )在前 glRotatef( ) 在後
會呈現一個車子自轉的效果,不論是移動到哪個位置,車子仍舊在移動到的地方自轉著
glRotatef( ) 在前 glTanslatef( ) 在後
會呈現一個車子公轉的效果,先旋轉後跟著跟個中心點 直繞著移動的感覺
●茶壺模擬機器手臂
step1
將兩個茶壺浮貼在一起
step2
加上滑鼠mouseX可以使用滑鼠來移動使茶壺旋轉但是會發現第一個茶壺的旋轉點在於另一個茶壺的中心點,但這並不是我們想要的效果點
step3


2017年3月14日 星期二

Week04 劉旆君的筆記

 
●互評班上同學上次功課最佳作品3名上傳moodle
 
●畫正圓形
 
 
#include <GL/glut.h>
#include <math.h>
void display(void)
{
    glBegin(GL_POLYGON);
    for(float angle=0; angle <= 3.1415926 *2; angle += 0.01)
    {
        glVertex2f(cos(angle),sin(angle));
    }
    glEnd();
    glutSwapBuffers();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);
    glutMainLoop();
    return EXIT_SUCCESS;
}
 
●點擊圓球變色,加上Mouse函數
 

 
圓球經過點擊之後會改變顏色,從珊瑚橘改成粉紅色
 
 Mouse 函數↓
 
void mouse(int button,int state, int x,int y)
{
    printf("%d %d %d %d\n",button,state,x,y);
    glColor3f(1,x/300.0,y/300.0);
}
 
●拖曳圓形改變顏色-加Motion函式

 
滑鼠拖曳到圓形不同位子時就會改變顏色
 
 
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
void display()
{
    glBegin(GL_POLYGON);
    for(float angle=0; angle <= 3.1415926 *2; angle += 0.01)
    {
        glVertex2f(cos(angle),sin(angle));
    }
    glEnd();
    glutSwapBuffers();
}
void motion (int x,int y)
{
    glColor3f(1,x/300.0,y/300.0);
    glutPostRedisplay();
}

int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
    return EXIT_SUCCESS;
}

●小精靈
 
 
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
float mouth=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glBegin(GL_TRIANGLE_FAN);
    glVertex2f(0, 0);
    for(float angle=0 + mouth; angle <= 3.1415926 *2 - mouth; angle +=3.1415926/100)
    {
        glVertex2f(cos(angle),sin(angle));
    }
    glEnd();
    glutSwapBuffers();
}
void motion (int x,int y)
{
    mouth=x/300.0;
    glColor3f(1,x/300.0,y/300.0);
    glutPostRedisplay();
}
int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("GLUT Shapes");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
    return EXIT_SUCCESS;
}