0
基本上,我想要做的是,導入3DS對象(完成),使它看起來「實」,使我能將雷電它OpenGL - 導入3ds對象並使其穩定?
這是我得到了什麼部分:
這是我加載的對象,並把它放在屏幕
void render()
{
int l_index;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW); // Modeling transformation
glLoadIdentity();
glTranslatef(0.0,0.0,-500.0);
glColor3d(1,1,0);
glBegin(GL_TRIANGLES);
for (l_index=0;l_index<object.polygons_qty;l_index++)
{
glVertex3f(object.vertex[ object.polygon[l_index].a ].x,
object.vertex[ object.polygon[l_index].a ].y,
object.vertex[ object.polygon[l_index].a ].z);
glVertex3f(object.vertex[ object.polygon[l_index].b ].x,
object.vertex[ object.polygon[l_index].b ].y,
object.vertex[ object.polygon[l_index].b ].z);
glVertex3f(object.vertex[ object.polygon[l_index].c ].x,
object.vertex[ object.polygon[l_index].c ].y,
object.vertex[ object.polygon[l_index].c ].z);
}
glEnd();
glutSwapBuffers();
}
初始化
void init(){
angle=30;
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
// Projection transformation
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100.0f,100.0f,-100.0f,100.0f,100.0f,-100.0f);
gluPerspective(30.0f,(GLfloat)screen_width/(GLfloat)screen_height,10.0f,10000.0f);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST); // We enable the depth test (also called z buffer)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
CThreeMaxLoader::Load3DS(&object,"chesspawn.3ds");
}