3DS --> Vertex Normals

Hello.
I made a class to load *.3DS files and draw it using OpenGL. Last week, I went to GameDev.net to take a look on the tutorial 3DS and find how compute vertex normals. I understood that face normal have to be compute first and secondly the normal vertex.
Now, that’s well done. So after this, I decided to download some different 3DS files (3DCafes) to see the result. I found two meshs (StartTrek Ship and Gray Mushroom) that give me a problem. Their normals seem to be inverted or something else…

The normals seems to point towards the interior. Thus there is light inside the object but not outside. Logically on these objets the normals should be point outside.

What’s could be the problem ? Different file/mesh version ? Something I need to load in chunk that specified the normal direction ???

Short explanation on the code used.

int shared = 0;
for(i=0; i<nbvertices; i++)
{
for(j=0; j<nbfaces; j++)
{
if ( (faces[j].vertices[0] == i)| |
(faces [j].vertices[1] == i)| |
(faces[j].vertices [2] == i))
{
sum += faces[j].normal;
shared++;
}
}

//The problem here -(shared) or +(shared)
sum /= float(shared);
sum.normalize();

vertices[i].normal = sum.x;
vertices[i].normal[Y] = sum.y;
vertices[i].normal[Z] = sum.z;

shared = 0;
sum = m_Vector::ZERO;
}

Usualy, the Shared value have to be negative, but in this two mesh, this value have to be POSITIVE to get a correct lightning (Normals). This is my problem. Please help me, I’m out of idea…

A BIG Thanks.
Martin

[This message has been edited by Erakis (edited 08-22-2002).]

i’m guessing that on the models that are giving you trouble, the polygon winding order is opposite what you’d expect. for most of the models it’s counter-clockwise, but for the troublesome models it’s clock-wise (or vice versa). i’ve never worked with 3ds models, but surely they have an indicator somewhere as to what the polygon winding order is.