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 == i)| |
(faces [j].vertices == i)| |
(faces[j].vertices  == i))
sum += faces[j].normal;
//The problem here -(shared) or +(shared)
sum /= float(shared);
vertices[i].normal[X] = 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.
[This message has been edited by Erakis (edited 08-22-2002).]