Hi all,
I am trying to use glLoadMatrix to load the matrix which would do the same job as a glTranslate*() and glRotate*(). So I created 3 4x4 matrices. One for translation, one for rotation, and one for the product of the first two. Once implemented, and with the angle being incremented a little each frame, I have a triangle that spins, just as it does using glTranslate*() and glRotate*(). However, with the glTranslate*() and glRotate*() code, the triangle gets darker as it turns away from the front gradually. With my own matrix doing the translation and rotation, the darkening and lightening of the triangle appears to be wrong. It doesn’t seem to change for much of the rotation, then suddenly it changes a lot.
Here is a snippet:
glLoadMatrixf(*rotation);
glNormal3f(0.0, 0.0, 1.0);
glLoadMatrixf(*transformation);
glColor3f (1.0f, 0.85f, 0.35f);
glBegin(GL_TRIANGLES);
{
glVertex3f( 0.0, 0.6, 0.0f);
glVertex3f( -0.2, -0.3, 0.0f);
glVertex3f( 0.2, -0.3, 0.0f);
}
And it looks much the same, if I have ‘glNormal3f(0.0, 0.0, 1.0);’ inside the glBegin() call and don’t load the rotation matrix by itself.
Is it that to transform normals, you use the inverse transpose of the matrix? The inverse of a 4x4 matrix looks a bit complicated.
Or is there another simple answer as to why the normals aren’t behaving correctly?
Thanks,
Ian.