Is Matrix4 (the float version) column major?
I think less efficiently when I am tired. I think I see my mistake now.
Can you check my order here?
In row major, modelViewProjection = projection * modelView? (not modelView * projection)
Is this right?
ModelView * Projection if memory serves right. There's a whole chapter dedicated to matrix operation at http://www.glprogramming.com/red/chapter03.html
in OpenTK.Math matrices are concatenated like this
C = A * B; // results in C containing matrix A transformed by B
// should be the same operation as:
GL.Matrixmode( ModelViewMatrix );
GL.LoadTransposedMatrix( A );
GL.MultTransposedMatrix( B );
GL.GetFloat( TransposedModelViewMatrix, out C.row0.X );
Yeah, I'm not using immediate mode though. I'm sending it to the shader as a uniform.
I wasn't confused until I started using the OpenTK math libraries with OpenGL via shaders. I just have to get it all sorted out in my head.
Thanks for the link. Its been a while since I've played with matrix ordering, so I am trying to get it straight in my head again.
I use this "mind model" when thinking of matrix ordering:
newVec = matrix1*matrix2*...*matrixN*oldVec
.. so matrix1 is applied 'last' and matrixN 'first', on the oldVec-vector.
Objarni, your "mind model" is row major, correct?
My mind model comes from linear algebra.
To me multiplication between matrices is mathematically defined something like:
R(r,c) = (A*B)(r,c) = A(r,:)*B(:,c) // for relevant r, c
The definition could be read aloud something like "the element on row r column c of the result matrix equals the scalar product of row vector r of A and column vector c of B".
Multiplying a row and a column vector means:
|a1 a2 a3| * |b2| = a1b1 + a2b2 + a3b3 // similar to scalar-product of two vectors
I'm not entirely sure what you mean by row-major; does it have anything to do with the ordering of the elements in a computer representation of a matrix using an array?
I think thats row-major notation.
There is information on row-major vs column-major matrices at the following link.
Site design by Stefanos A. Icons courtesy of gnome-colors.