This is a piece of code i wrote.
The aim is to apply difft rotation matrices to the modelview matrix for the normals and the points.
glMatrixMode(GL_MODELVIEW);
glMultMatrixf(TranslationMatrix);
glMultMatrix(ScalingMatrix);
glBegin()
for(i=1;i<=NumberofTriangles;i++)
{
glPushMatrix();
glMultMatrixf(TransposeRotationMatrix);
//Set the normal
glPopMatrix();
glMultMatrixf(RotationMatrix);
//plot the verices
}
glEnd();
Error: If i gave the glMultMatrix outside the glBegin() End() loop then using only one rotation matrix iam able to get it to work, but if i give it as such inside with two difft matrices for normals and rotation i can only get the object to translate and scale but iam not able to get it to rotate at all.
Any comments to fix this, or another alternative method would be greatly appreciated.
I’m not quite sure what you are trying to accomplish, but there is no way to use those gl calls that affect the matrix between glBegin and glEnd.
If you are trying to use scaling and don’t want the normals affected, just use glEnable(GL_NORMALIZE).
Not quite sure what the glMultMatrixf(TransposeRotationMatrix) is supposed to be for either. Normals get multiplied by the inverse model-view matrix.
If you really need to have a different rotation for normals than the vertices, the only way I can really think of is to do all your own matrix math on each normal before passing them to glNormal.