顯示具有 05160523_朱紘希 標籤的文章。 顯示所有文章
顯示具有 05160523_朱紘希 標籤的文章。 顯示所有文章

2018年6月19日 星期二

week15嘻嘻嘻

課程回顧
Week01 : (1)WebGL  (2)跑OPENGL專案
Week02 : (1)建GLUT專案(搭配freeglut)  (2)將GLUT專案(六個圖)的177行程式碼縮減約20行
(3) 用10行寫出茶壺 ( glutSolidTeapot ( x ) )
Week03 : (跑Transformation.exe) 移動         旋轉    放大縮小 的觀念
                                                  Translatef   Rotatef    Scalef

           glutSolidTeapot(半徑)
           glutSolidSphere(半徑,切,切)
            glutSolidCone(...,....,...)    
 

Week04 : Rotate,矩陣(Matrix)
Week05 : T-R-T特定軸轉動
Week06 : glm 3D模型 
#include"glm.h"
 GLM * pmodel=NULL
       畫圖:if(pmodel==NULL)
{
       glmReadOBJ("....")
      縮放glmUnitize()
     法向量
}
glmDraw("pmodel");
*****舊的strdup()會不相容

Week07 : 
(1)CodeBlocks專案&setting->compiler要設對才可以運行glm.cpp compiler
(2)working_dir設成"."
(3)libfreeglut.dll 專案目錄copy

Week08 :(1)模型打光 (2)陣列
Week10 :貼圖:OpenCV (moodle上課所需的軟體)
                            (1)安裝OpenCV
                            (2)設目錄link
                            (3)秀圖
Week11 : (1)keyboard  搭配 PlaySound() 變鍵盤鋼琴
                   (2)mouse  配  PlaySound()變射擊遊戲
                   (3)只能播放MP4 ----> 搭配CMP3_MCI.h 可播 MP3

week11嘻嘻嘻

把聲音先放入桌面的freeglut/bin
在main程式前加
#include <mmsystem.h>///(0)呼叫Multimedia多媒體系統的外掛
main程式裡加
 PlaySound("madmoo.wav",NULL,SND_ASYNC);///(1)播放聲音,毒入wav檔
    ///PlaySound()其實就是PlaySoundA(),輸入的檔名,會是正常的ASCII字串
    ///三個參數 (檔名,NULL,SND_ASYNC)
    ///小心,要在 working_dir工作執行的目錄裡面找到他










week10嘻嘻嘻

至http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
下載  data.zip
          window.zip
          glut32.dll

(1)改glColor4f(...)
(2)改glVertex3f(...)
(3)改glTexCoord2f(...)
02.
TODO:最簡單的讀圖秀圖3行
#include <opencv/highgui.h> //(1)外掛
.
.
.
int main()
{
    IplImage * img =cvLoadImage("image.jpg")  ;
     cvShowImage("week10opencv",img)  ;  ///(3)秀圖
    cvWaitKey(0)  ;  ///等一下按鍵才能繼續
    cvNamedWindow(...)
}






2018年6月18日 星期一

week08嘻嘻嘻

jsyeh.org/3dcg10
windows.zip ----> 下載\windows\light Materials.exe
data.zip
glut32.dll
source.zip  --->   等一下要用glm.h
                                                glm.c ----> glm.cpp
                                 (再參考 LightMaterial.c)








week07嘻嘻嘻

TODO: Moodle下載3DExploration
                                       (探索/檔案總管)
(1)安裝 執行
TODO: 下載 jsyeh.org/3dcg10
(2)data.zip--->桌面/data/一堆3D模型
=> 用3D Explorer 開3D模型(看)
想自己讀入3D模型

TODO:
File-New-Project.GLUT
(freeglut放桌面)
                                                glm.h
桌面有Week07_glm資料夾   glm.c ---> 改glm.cpp                                          (source.zip有程式碼)
                                                transformation.c-----> 改transformation.cpp

Setting-Compiler把勾勾清掉






2018年5月21日 星期一

2018年3月26日 星期一

week05嘻嘻嘻

glTranslatef(........)                                         glRotate(............)

glRotate(.............)                                          glTranslatef(........)

在右邊自轉                                                  右邊車子繞畫面中心

左耳貼左肩 從下往上讀

2018年3月12日 星期一

week03嘻嘻嘻


#include <GL/glut.h>
void display()
{
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}

int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week03 Mouse操作");

    glutDisplayFunc(display);
    glutMainLoop();
}

#include <GL/glut.h>
void display()
{
    glClearColor(1,1,0,1);
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f(0,1,0);
    glutSolidTeapot(0.3);
    glutSwapBuffers();
}
#include <stdio.h>
void mouse(int button, int state,int x,int y)
{
    if(state==GLUT_DOWN) printf("glVertex2f(%f,%f);\n",(x-150)/150.0,-(y-150)/150.0);
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week03 Mouse操作");

    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMainLoop();
}
#include <GL/glut.h>
float teapotX=0, teapotY=0;
void display()
{
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(teapotX, teapotY, 0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
#include <stdio.h>
void mouse(int button, int state,int x,int y)
{
    if(state==GLUT_DOWN) printf("glVertex2f(%f,%f);\n",(x-150)/150.0,-(y-150)/150.0);
}
void motion(int x,int y)
{
    teapotX=(x-150)/150.0; teapotY=-(y-150)/150.0;
    printf("%d %d\n",x,y);
    glutPostRedisplay();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("Week03 Mouse操作");

    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutMainLoop();
}

2018年3月5日 星期一

week02嘻嘻嘻

01. 點線面,右鍵選擇圖形,左鍵調整數值

02. 畫三角形



03. 畫茶壺





04. 畫茶壺,改顏色