電腦圖學 2015/5/13 week12
(1)作業回顧
(2)作業需求(小遊戲)
(3)3D Model模型 glm.c
(4)Maya轉OBJ檔
(5)介紹助教影片資源
今天做的第一個作業是六行程式(讀3D Model)
1.New Project-GLUT(投機的作法)
2.#include "glm.h"(把glm.c(glm.cpp)、glm.h放同目錄)
3.把c改cpp
4.把transformation.c裡的6行copy到程式
小黑框出現
把檔案拖進去freeglut內(因為是使用GLUT(投機取巧)所以檔案都會在freeglut內執行)
出現車車
程式碼:
#include "glm.h"
GLMmodel* pmodel = NULL;
void display()
{
glmDraw(pmodel,GLM_SMOOTH | GLM_MATERIAL);
glFlush();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutCreateWindow("02160136");
glutDisplayFunc(display);
pmodel = glmReadOBJ("porsche.obj");
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
glutMainLoop();
}
但是沒打光
打光之後
車車出現了~~~~
程式碼:
#include "glm.h"
GLMmodel* pmodel = NULL;
void display()
{
GLfloat pos[] = { 0.0, 0.0, -1.0, 0.0 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);///打光程式碼
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glmDraw(pmodel,GLM_SMOOTH | GLM_MATERIAL);
glFlush();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutCreateWindow("02160136");
glutDisplayFunc(display);
pmodel = glmReadOBJ("porsche.obj");
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
glutMainLoop();
}
(1)作業回顧
(2)作業需求(小遊戲)
(3)3D Model模型 glm.c
(4)Maya轉OBJ檔
(5)介紹助教影片資源
今天做的第一個作業是六行程式(讀3D Model)
1.New Project-GLUT(投機的作法)
2.#include "glm.h"(把glm.c(glm.cpp)、glm.h放同目錄)
3.把c改cpp
4.把transformation.c裡的6行copy到程式
小黑框出現
把檔案拖進去freeglut內(因為是使用GLUT(投機取巧)所以檔案都會在freeglut內執行)
出現車車
程式碼:
#include "glm.h"
GLMmodel* pmodel = NULL;
void display()
{
glmDraw(pmodel,GLM_SMOOTH | GLM_MATERIAL);
glFlush();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutCreateWindow("02160136");
glutDisplayFunc(display);
pmodel = glmReadOBJ("porsche.obj");
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
glutMainLoop();
}
但是沒打光
打光之後
車車出現了~~~~
程式碼:
#include "glm.h"
GLMmodel* pmodel = NULL;
void display()
{
GLfloat pos[] = { 0.0, 0.0, -1.0, 0.0 };glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);///打光程式碼
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glmDraw(pmodel,GLM_SMOOTH | GLM_MATERIAL);
glFlush();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutCreateWindow("02160136");
glutDisplayFunc(display);
pmodel = glmReadOBJ("porsche.obj");
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
glutMainLoop();
}
沒有留言:
張貼留言