• Advertisement
Sign in to follow this  

lib3ds normals help

This topic is 2601 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm using this algorithm to load my model


void render(const char * p)
{

Lib3dsFile * model = lib3ds_file_open(p);
if(!model)
{
cout<<"Failed"<<endl;
cout<<p<<endl;

}
else
{
index=glGenLists(1);
glNewList(index,GL_COMPILE);

for(int i =0;i<sizeof(model->meshes)/sizeof(int);++i)
{
float (*normalL)[3] = (float(*)[3])malloc(3 * 3 * sizeof(float) * model->meshes->nfaces);

lib3ds_mesh_calculate_vertex_normals(model->meshes, normalL);
for(int j =0;j<model->meshes->nfaces;++j)
{
float colorBlue[] = { 0.0f, 0.0f, 1.0f, 1.0f };
glBegin(GL_TRIANGLES);
for(int z=0;z<3;++z)
{


glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, colorBlue);
colorBlue[z]+=1.0f;
glNormal3fv(normalL[3*j+z]);
glVertex3fv(model->meshes->vertices[model->meshes->faces[j].index[z]]);


}
glEnd();


}
}

glEndList();
}

}



But It seems completely wrong.

http://www.glowfoto.com/static_image/10-022629L/2124/jpg/12/2010/img5/glowfoto
http://www.glowfoto.com/static_image/10-022725L/6905/jpg/12/2010/img5/glowfoto
http://www.glowfoto.com/static_image/10-022755L/3608/jpg/12/2010/img5/glowfoto


As far as I can see the problem isn't connected with color changing.

Am I using the wrong algorithm?

[Edited by - General_Lee on December 10, 2010 5:22:41 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement