2016年5月10日 星期二

Week12

Class Work 1

Step 1 到 jsych.org/3dcg10

Step 2 下載"windows, data, glut32, source"
Step 3 用notepad++看"glm.h, glm.c, transformation.c"




Class Work 2

Step 1 開新專案 
Step 2 windows 資料夾裡的data, glm.c, transformation.c檔案放進專案資料夾
Step 3 "Alt"工具-->資料夾選項-->檢視-->隱藏已知類型附檔名打勾拿掉
Step 4 glm.c, transformation.c檔案 改成 glm.cpp, transformation.cpp
Step 5 Add  glm.cpp, transformation.cpp 到專案裡
Step 6 main.cpp移除
Step 7 設定咒語

Step 8 執行檔案


Class Work 3

Step 1 開新檔案 "Mymodel.cpp"
Step 2 從"Transfprmation.c "複製 "drawmodel"的code 貼到"display",執行

Step 3 將車子改成3D模型

Code:
#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("Ya!");

    glutDisplayFunc(display);

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

    glutMainLoop();

}

沒有留言:

張貼留言