2016年5月10日 星期二

week12 江美霖

<課堂作業一>
1.到 jsyeh.org/3dcg10 這個網站
   下載window.zip  data.zip  source.zip  glut32.dll這四個


2.設定一個資料夾
window.zip裡面的檔案拉到資料夾裡面


3.將 glut32.dll 檔案直接拉到資料夾裡


3.將 data.zip 打開 裡面的data拉到資料夾裡


4.將source.zip打開  將glm.h  glm.c  transformation.c三個檔案拉到資料夾裡


5.glm.h  glm.c  transformation.c 這三個用Notepad++觀看


<課堂作業二>

1.開啟貝殼專案


2.將原本main的執行檔刪掉


3.將 glm.c  transformation.c 的復黨名改為cpp


4.將 glm.h  glm.cpp  transformation.cpp 這三個檔案拉到專案資料夾

5.將freeglut拉至桌面


6.增加新的專案


7.將 glm.cpp  transformation.cpp開啟


8.將freeglut.dll複製到專案資料夾中


9.將data資料夾複製到專案資料夾



10.加咒語






11.成功


<課堂作業三>
1.刪除transformation.cpp檔案


2.新增一個專案


3.打出以下程式碼

#include "glm.h"
GLMmodel * pmodel=NULL;
void display()
{
    if(!pmodel){
    pmodel=glmReadOBJ("data/porsche.obj");
    if(!pmodel) exit(0);
    glmUnitize(pmodel);
    glmFacetNormals(pmodel);
    glmVertexNormals(pmodel, 90.0);
    }
    glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
    glutSwapBuffers();
}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("3D Model ready YA!");

    glutDisplayFunc(display);

    glutMainLoop();
}

成功


以下程式碼

#include "glm.h"
GLMmodel * pmodel=NULL;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    if(!pmodel){
        pmodel=glmReadOBJ("data/porsche.obj");
        if(!pmodel) exit(0);
        glmUnitize(pmodel);
        glmFacetNormals(pmodel);
        glmVertexNormals(pmodel, 90.0);
    }
    glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);

    glutSwapBuffers();
}
GLfloat pos[]={0.0,0.0,-1.0,0.0};
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("3D Model ready YA!");

    glutDisplayFunc(display);

    glLightfv(GL_LIGHT0, GL_POSITION,pos);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);

    glutMainLoop();
}




沒有留言:

張貼留言