2016年5月9日 星期一

Week12

Blog內容複習
GLUT基礎元件
Maya匯出OBJ擋
並將OBJ擋Load/Draw

課堂作業
(1)http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/
下載win32.zip data.zip glut32.dll source.zip
解壓縮
把data glut 放入Win32資料夾

執行所有exe檔

(2)GLUT基礎元件
開新檔

改路徑加密語




開檔案



執行

課堂(3)
原檔案改名附檔名
glm.c改glm.cpp
transformation.c改myOBJ.cpp
把原本的檔案刪掉


















myOBJ.cpp打程式碼
#include <GL/glut.h>
#include "glm.h"
GLMmodel * pmodel=NULL;
void display()
{
    glClearColor(1,0.5,0,0);
    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();
}
int main(int argc,char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("GLM model is great!");
    glutDisplayFunc(display);
    glutMainLoop();
}
執行

課堂(4)加燈
#include <GL/glut.h>
#include "glm.h"
GLMmodel * pmodel=NULL;
void display()
{
    glClearColor(1,0.5,0,0);
    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);
    }
    glRotatef(90,0,1,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("GLM model is great!");
    glutDisplayFunc(display);
    glLightfv(GL_LIGHT0, GL_POSITION, pos);///燈
    glEnable(GL_LIGHT0);///燈
    glEnable(GL_LIGHTING);///燈
    glEnable(GL_DEPTH_TEST);///燈
    glutMainLoop();
}
執行


沒有留言:

張貼留言