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.
have you tried multiplying it on the left side?
ModelViewMat = CamMat * WhateverMat
-> CamMat^-1 * ModelViewMat = WhateverMat
Multiplying by the inverse of the camera matrix should work. Remember, the order is important.
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
// get inverse camera matrix
objectMatrix = gCamera.Matrix; // actually contains inverse camera matrix
// take the camera out of the matrix by
// multiplying inverse camera matrix by modelViewMatrix
// take the inverse of the object's
// take my cutplane matrix and multiply by object's matrix
drawPlaneMatrix = objectMatrix;
multiply points by drawPlaneMatrix
Thanks, I really appreciate any help I can get!
I just can’t seem to make this work…
objectMatrixOnly = myInverseCameraMatrix * modelViewMatrix;
Can someone please point me to a web page or tutorial on how to extract the object’s matrix from the current opengl matrix?
Well that seems correct, are you ordering your rows/columns correctly?
Opengl uses column major ordering:
|0 4 8 12|
|1 5 9 13|
|2 6 10 14|
|3 7 11 15|
It gave me some weird results in the beginning.
Yes, my matrix order is column major order just like opengl.