I have partially solved this problem, I was overwriting the mModelView matrix instead of “appending” to it. I havn’t had time to code the solution yet as I have a test I have been studying for.
I’m using some of the math from the superbible, here is the multiply function from that:
void Matrix::Multiply(Matrix44f &product, const Matrix44f a, const Matrix44f b )
{
#define A(row,col) a[(col<<2)+row]
#define B(row,col) b[(col<<2)+row]
#define P(row,col) product[(col<<2)+row]
for (int i = 0; i < 4; i++) {
float ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0);
P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1);
P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2);
P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3);
}
}
I currently do not have a working pop/push, but the idea is to use a memcopy call such as:
void Matrix::Push() {
memcpy(saveMatrix, mModelView, sizeof(Matrix44f));
}
void Matrix::Pop() {
memcpy(mModelView, saveMatrix, sizeof(Matrix44f));
}
I haven’t looked up if this will have any speed consequences yet using this method.