jSTIN
2003.11.23, 04:46 PM
I want to set a matrix up to store rotations for all my objects. Since if you call glRotate three times for each matrix the result will depend on the order, etc.
So by default each objects rotation matrix is set to the identity matrix. So there should be no change when I multiply the current matrix with glMultMatrixf. But it messes it all up when I do that. Here is some code.
rotMatrix[0] = 1; rotMatrix[4] = 0; rotMatrix[8] = 0; rotMatrix[12] = 0;// Set rot matrix to identity matrix
rotMatrix[1] = 0; rotMatrix[5] = 1; rotMatrix[9] = 0; rotMatrix[13] = 0;
rotMatrix[2] = 0; rotMatrix[6] = 0; rotMatrix[10] = 1; rotMatrix[14] = 0;
rotMatrix[3] = 0; rotMatrix[7] = 0; rotMatrix[11] = 0; rotMatrix[15] = 1;
So each objects rotation is set to that, then the drawing code.
glPushMatrix();
glTranslatef(tempModel->xPos, tempModel->yPos, tempModel->zPos); // Translate To the models position
glMultMatrixf(tempModel->rotMatrix);
tempModel->Draw(); // draw the model
glPopMatrix();
If I comment out the glMultMatrixf it looks fine. Every thing is where it should be. But it should be the same since I multiply it with the identity matrix.
If there is another way to get the rotations I need, that would work too.
So by default each objects rotation matrix is set to the identity matrix. So there should be no change when I multiply the current matrix with glMultMatrixf. But it messes it all up when I do that. Here is some code.
rotMatrix[0] = 1; rotMatrix[4] = 0; rotMatrix[8] = 0; rotMatrix[12] = 0;// Set rot matrix to identity matrix
rotMatrix[1] = 0; rotMatrix[5] = 1; rotMatrix[9] = 0; rotMatrix[13] = 0;
rotMatrix[2] = 0; rotMatrix[6] = 0; rotMatrix[10] = 1; rotMatrix[14] = 0;
rotMatrix[3] = 0; rotMatrix[7] = 0; rotMatrix[11] = 0; rotMatrix[15] = 1;
So each objects rotation is set to that, then the drawing code.
glPushMatrix();
glTranslatef(tempModel->xPos, tempModel->yPos, tempModel->zPos); // Translate To the models position
glMultMatrixf(tempModel->rotMatrix);
tempModel->Draw(); // draw the model
glPopMatrix();
If I comment out the glMultMatrixf it looks fine. Every thing is where it should be. But it should be the same since I multiply it with the identity matrix.
If there is another way to get the rotations I need, that would work too.