One. 組合出機器人
1. 下載安裝 3D exploration
2. 匯出OpenGL Sample App
File -> save as -> 選cpp OpenGL
3. 選Sample App
4.用codeblocks開啟
a. 新增OpenGL檔案
b.把專案main.cpp改成匯出的car.cpp
擷取後讀取檔案
program:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
angle++;
glPushMatrix();///第一個大括號
glRotatef(angle, 0,1,0);
if (!pmodel) {
pmodel = glmReadOBJ("data/dolphins1.obj");
if (!pmodel) exit(0);
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
}
if (!pmode2) {
pmode2 = glmReadOBJ("data/dolphins2.obj");
if (!pmode2) exit(0);
glmUnitize(pmode2);
glmFacetNormals(pmode2);
glmVertexNormals(pmode2, 90.0);
}
glPushMatrix();///start
glTranslatef(-0.5,0,0);
glScalef(0.4,0.4,0.4);
glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
glPopMatrix();///end
glPushMatrix();///start
glTranslatef(0.5,0,0);
glScalef(0.4,0.4,0.4);
glmDraw(pmode2, GLM_SMOOTH | GLM_MATERIAL);
glPopMatrix();///end
glPopMatrix();///結束大一個大括號
glutSwapBuffers();







沒有留言:
張貼留言