8:30 – 5:00 FP
- Working on how to chain matrices.
- Old-school:
-
glRotatef(eyeOrient[0], 1, 0, 0); glRotatef(eyeOrient[2], 0, 1, 0); glTranslatef(eyePos[0], eyePos[1], eyePos[2]); // global world transformations glTranslatef(worldPos[0], worldPos[1], worldPos[2]); glRotatef(worldOrient[0], 1, 0, 0); glRotatef(worldOrient[1], 0, 1, 0);
- And How it’s done now:
-
m3dLoadIdentity44(workingMatrix); m3dLoadIdentity44(worldMat); m3dLoadIdentity44(eyeMat); m3dLoadIdentity44(tmat); m3dLoadIdentity44(rmat1); m3dLoadIdentity44(rmat2); // handle eyepoint transformations m3dRotationMatrix44(rmat1, eyeOrient[0], 1, 0, 0); m3dRotationMatrix44(rmat2, eyeOrient[2], 0, 1, 0); m3dTranslationMatrix44(tmat, eyePos[0], eyePos[1], eyePos[2]); m3dMatrixMultiply44(eyeMat, rmat2, eyeMat); m3dMatrixMultiply44(eyeMat, rmat1, eyeMat); m3dMatrixMultiply44(eyeMat, tmat, eyeMat); // handle global world transformations m3dTranslationMatrix44(tmat, worldPos[0], worldPos[1], worldPos[2]); m3dRotationMatrix44(rmat1, worldOrient[0], 1, 0, 0); m3dRotationMatrix44(rmat2, worldOrient[1], 0, 1, 0); m3dMatrixMultiply44(worldMat, rmat1, rmat2); m3dMatrixMultiply44(worldMat, tmat, worldMat); // combine the eye and eorld xforms m3dMatrixMultiply44(workingMatrix, eyeMat, worldMat);
- Isn’t that better?
- Ok, cleaned things up a bit, and now I’ve got something I can live with:
-
// global eye transformations modelViewMatrix.Rotate(eyeOrient[0], 1, 0, 0); modelViewMatrix.Rotate(eyeOrient[2], 0, 1, 0); modelViewMatrix.Translate(eyePos[0], eyePos[1], eyePos[2]); // global world transformations modelViewMatrix.Translate(worldPos[0], worldPos[1], worldPos[2]); modelViewMatrix.Rotate(worldOrient[0], 1, 0, 0); modelViewMatrix.Rotate(worldOrient[1], 0, 1, 0);
- Putting the stage and other bits in
