Hi!
I'm starting to use OpenGL and have already my little "engine running.
But now i want a little bit more "complex" modeln in my Engine so i found the MD2 Loader Tut on gametutorials.com.
It nearly works but i have strange problems with the Normal Vectors. i just see the inner side of my Model...
The first thing i dont understand is why the do FrontFaceCulling??? I use in my whole Engine backface culling so i want to stay there.
glEnable(GL_CULL_FACE); Turn culling on
glCullFace(GL_FRIONT); Quake2 uses front face culling apparently
Ok.. the next thing is in the drawing algorithm:
// Render lines or normal triangles mode, depending on the global variable
glBegin(GL_TRIANGLES);
// Go through all of the faces (polygons) of the object and draw them
for(int j = 0; j < pObject->numOfFaces; j++)
{
// Go through each corner of the triangle and draw it.
for(int whichVertex = 0; whichVertex < 3; whichVertex++)
{
// Get the index for each point in the face
int index = pObject->pFaces[j].vertIndex[whichVertex];
// Get the index for each texture coord in the face
int index2 = pObject->pFaces[j].coordIndex[whichVertex];
// Give OpenGL the normal for this vertex. Notice that we put a
// - sign in front. It appears that because of the ordering of Quake2's
// polygons, we need to invert the normal
glNormal3f( -pObject->pNormals[ index ].x, -pObject->pNormals[ index ].y, -pObject->pNormals[ index ].z);
// Make sure there was a UVW map applied to the object or else it won't have tex coords.
if(pObject->pTexVerts)
{
glTexCoord2f(pObject->pTexVerts[ index2 ].x, pObject->pTexVerts[ index2 ].y);
}
// Pass in the current vertex of the object (Corner of current face)
glVertex3f(pObject->pVerts[ index ].x, pObject->pVerts[ index ].y, pObject->pVerts[ index ].z);
}
}
glEnd();
He puts a - in front of all Normals, So i thought why not just removing all - signs and switch back to Bachface culling? Where is my fault??? it doesn't work??
Greets
MrM