Remember that in C/C++ if you have a matrix[y][x], x is columns and y is rows.
I would recommend the following structure (similar to D3DXMATRIX):
Code:
struct Matrix4x4
{
float _11, float _12, float _13, float _14;
float _21, float _22, float _23, float _24;
float _31, float _32, float _33, float _34;
float _41, float _42, float _43, float _44;
...
};
I would also overload operators where it makes sense relative to Matrix4x4 to make operations much simpler.
What has been shown is a simple translation matrix for OGL. Here is the Direct3D version:
[1][0][0][0]
[0][1][0][0]
[0][0][1][0]
[x][y][z][1]
If you were wanting to know how to transform a vector by this matrix here is the math:
Code:
Vector3 resultVector;
Vector3 srcVector;
Matrix4x4 mat;
resultVector.x = srcVector.x * mat._11 + srcVector.y * mat._21 + src.Vector.z * mat._31 + mat._41;
resultVector.y = srcVector.x * mat._12 + srcVector.y * mat._22 + src.Vector.z * mat._32 + mat._42;
resultVector.z = srcVector.x * mat._13 + srcVector.y * mat._23 + src.Vector.z * mat._33 + mat._43;