So I am learning OpenGL with as the main resource having the “Red book”. I am reading about matrix algebra, rotation/scaling/transform matrices and everything is great, but I just don’t get one simple thing. Let’s say the function glLoadIdentity(). It sets the default matrix of 4×4. So it sets 3 vertices and 1 point: (1,0,0) (0,1,0) (0,0,1) vertices, (0,0,0) point. But my question is, what do those correspond? Generally speaking, what does a matrix correspond in OpenGL? I got an idea that these are the directions of axies. But the axies of what? The camera?
Share
OpenGL matrices only correspond to a transformation, moving objects, vectors and points defined in one coordinate space to another. If you have a matrix M (m11 – m44 as shown below) and a vector V (v1 – v4) in one coordinate space then multiplying by M will convert your V vector (which could describe a movement vector, object location or an object vertex) to W (w1-w4) in a different coordinate space:
Where:
So if we think of v1 – v3 as the old x, y and z coordinates and set v4 to 1, then we can think of w1 – w3 as the new x, y and z coordinates there are a few things we can see:
m11 is a multiplier from the old x coordinate to the new one so it’s used in scale transformations (and similarly for m22 and m33)
m14 multiplied by 1 and added to the new x coordinate so it is used for translations (and similarly for m24 and m34)
Rotations are a little harder to conceptualise but they are done by setting the other matrix values to appropriate values. You can read more here: http://gpwiki.org/index.php/Matrix_math