(1)先到 jsyeh.org/3dcg10 Download--win32,data,source,glut32.dll
(2)
win32.zip->桌面/2016CG/exe檔
data.zip->桌面/2016CG/data/*.obj,*.mtl
glut32.dll->桌面/2016CG/glut32.dll
source.zip->桌面/2016CG/glm.c,glm.h,transformation.c
課堂作業二:GLUT基礎元件
(1)新增貝殼專案。
(2)Remove file from project移除原本的檔案。
(3)在資料夾選項->將"隱藏已知檔案的副檔名"取消掉。
(4)將glm和transformation的副檔名改成.cpp。
(5)右鍵->Add files。
(6)將glm.cpp & glm.h & transformation.cpp & data 資料夾 複製進去。
(7)右鍵->Build Option ->Search directories -> Compiler
->輸入 "C:\Users\USER\Desktop\freeglut\include"
(8)右鍵->Build Option ->Search directories -> Compiler
->輸入 "C:\Users\USER\Desktop\freeglut\lib"
(9)右鍵->Build Option ->Linker Settings
->輸入 "freeglut , opengl32 ,glu32 ,gdi32, winmm"
(10)缺少freeglut 檔。
(11)freeglut 檔案複製進去。
(12)開啟檔案。
課堂作業三:Maya 匯出3D模型 使用glm讀OBJ(Read,Draw)
(1)移除檔案 新增Empty(myModel)
(2)輸入程式碼
-->
#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();
}
(3)跑程式


















沒有留言:
張貼留言