I want to get an object’s matrix when I am about to draw it, but I don’t want the camera transform in it. I only want the object’s matrix. I thought multiplying by the camera inverse matrix would give me just the object’s matrix. I guess not because that didn’t work.
Can you please tell me if this is the correct way? What I am trying to do is cancel out the object part of the transformation so that when opengl’s modelview matrix is applied I just get the camera transform and plane transform. (I have to do it this way because I am auto generating texture coordinates and opengl wants the real transform of the object when it receives the vertices. But the plane that I am drawing the texture on is not part of the object.)
// get the modelview matrix
BMatrix modelViewMatrix;
glGetFloatv(GL_MODELVIEW_MATRIX, modelViewMatrix.Mtx);
// get inverse camera matrix
BMatrix objectMatrix;
objectMatrix = gCamera.Matrix; // actually contains inverse camera matrix
// take the camera out of the matrix by
// multiplying inverse camera matrix by modelViewMatrix
objectMatrix.Mul(modelViewMatrix);
// take the inverse of the object's
objectMatrix.Inverse();
// take my cutplane matrix and multiply by object's matrix
drawPlaneMatrix = objectMatrix;
drawPlaneMatrix.Mul(gCutPlane.m_Matrix);