OpenGL - 导入3ds对象并使其稳定?

时间:2013-06-19 18:01:53

标签: object opengl 3ds

基本上,我要做的是,导入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");
}

1 个答案:

答案 0 :(得分:1)

如果您想要实体填充,请删除glPolygonMode()来电。

对于照明,请确保提供一些适当的顶点/面法线。