2016年5月10日 星期二

Week 12 張歆

課堂作業1
jsyeh.org/3dcg10
下載data.zip、windows.zipglut32.dllsource.zip檔

data.zip、windows.zipglut32.dll放置桌面資料夾



source --- glm.h、glm.c、transformation

用Notepad++看


課堂作業2
將glm.c、transformation.c檔名改成glm.cpp、transformation.cpp

開啟貝殼專案:File - New - Project 選右上貝殼shell

刪除Main.cpp


將glm.h、glm.cpp、transformation.cpp、freeglut放進專案資料夾內


開啟檔案glm.cpp、transformation.cpp


Build Uptions加目錄、咒語

目錄include

目錄lib

咒語freeglut
        opengl32
        glu32
        gdi32
        winmm

data放入資料夾



課堂作業3
舊檔案(有目錄、咒語)
Remove刪除transformation.cpp

再File - New - Empty File 存myModel.cpp



#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_DEPTH | GLUT_DOUBLE);
    glutCreateWindow("my Model");
    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};///this is light position for light
int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("my Model");
    glutDisplayFunc(display);

    glLightfv(GL_LIGHT0, GL_POSITION, pos);///this is light position
    glEnable(GL_LIGHT0);///this is light zero not light O
    glEnable(GL_LIGHTING);///this is light-ing 名詞
    glEnable(GL_DEPTH_TEST);///3D depth test, and you will have correct 3D depth Z information

    glutMainLoop();
}

沒有留言:

張貼留言