Hello there,
I’m currently writing a 3D Studio MAX exporter for models. Both, my models and my scenes use the same mesh system. What I first did was to transform the meshes in my exporter to have absolute coordinates in my engine. My engine then created the face and vertex normals itself to pass them through glNormal3f() for every vertex for lighting. That doesn’t work any longer because the transformation matrix for every mesh for my model changes. What I now do is to export the meshes in relative coordinates and to export the transformation matrices separately. The exported matrices work well with opengl, they’re converted correctly, all meshes are at the positions where they should be, but the problem: dynamic lighting doesn’t work any longer because of wrong face normals. I tried both for the normal creation: First, to create the normals for the relative meshes. Second: to transform all vertices temporarely and then create the normals. Both methods don’t work, the lighting is wrong, too dark (how can this be, I normalized the normals?!?), and from the wrong direction.
The commands in pseudo-code:
glLightfv(…) // positions and rgb values are correct
// for every mesh
glPushMatrix()
glMultMatrixf() // this command is new!
// for every polygon
glTexCoord2f(...)
glNormal3f(...)
glVertex3f(...)
glPopMatrix()
Any ideas?
thanks,
Meals