• Create Account

Banner advertising on our site currently available from just \$5!

### #ActualL. Spiro

Posted 22 April 2014 - 05:46 PM

The first row is the object’s X vector, which points to the right of the object.
The second row is the object’s up vector.  In a primitive FPS game this will always be [0,1,0] for a player as the player is always standing upright.
The third row is the object’s Z vector, which points forward in front of the object.  It is the direction the object is facing.
The fourth row is the object’s position.

The first row is also scaled by the object’s X scale, and the second and third are scaled by the object’s Y and Z scales respectively.

Code to create a matrix from scratch (the easiest way to understand each component) is as follows:
    /** Creates a matrix from our data. */
void COrientation::CreateMatrix( CMatrix4x4 &_mRet ) const {
_mRet._11 = m_vRight.x * m_vScale.x;
_mRet._12 = m_vRight.y * m_vScale.x;
_mRet._13 = m_vRight.z * m_vScale.x;
_mRet._14 = 0.0f;

_mRet._21 = m_vUp.x * m_vScale.y;
_mRet._22 = m_vUp.y * m_vScale.y;
_mRet._23 = m_vUp.z * m_vScale.y;
_mRet._24 = 0.0f;

_mRet._31 = m_vForward.x * m_vScale.z;
_mRet._32 = m_vForward.y * m_vScale.z;
_mRet._33 = m_vForward.z * m_vScale.z;
_mRet._34 = 0.0f;

_mRet._41 = m_vPos.x;
_mRet._42 = m_vPos.y;
_mRet._43 = m_vPos.z;
_mRet._44 = 1.0f;
}
These are Direct3D matrices.

L. Spiro

### #1L. Spiro

Posted 22 April 2014 - 05:45 PM

The first row is the object’s X vector, which points to the right of the object.
The second row is the object’s up vector.  In a primitive FPS game this will always be [0,1,0] for a player as the player is always standing upright.
The third row is the object’s Z vector, which points forward in front of the object.  It is the direction the object is facing.
The fourth row is the object’s position.

The first row is also scaled by the object’s X scale, and the second and third are scaled by the object’s Y and Z scales respectively.

Code to create a matrix from scratch (the easiest way to understand each component) is as follows:
 /** Creates a matrix from our data. */
void COrientation::CreateMatrix( CMatrix4x4 &_mRet ) const {
_mRet._11 = m_vRight.x * m_vScale.x;
_mRet._12 = m_vRight.y * m_vScale.x;
_mRet._13 = m_vRight.z * m_vScale.x;
_mRet._14 = 0.0f;

_mRet._21 = m_vUp.x * m_vScale.y;
_mRet._22 = m_vUp.y * m_vScale.y;
_mRet._23 = m_vUp.z * m_vScale.y;
_mRet._24 = 0.0f;

_mRet._31 = m_vForward.x * m_vScale.z;
_mRet._32 = m_vForward.y * m_vScale.z;
_mRet._33 = m_vForward.z * m_vScale.z;
_mRet._34 = 0.0f;

_mRet._41 = m_vPos.x;
_mRet._42 = m_vPos.y;
_mRet._43 = m_vPos.z;
_mRet._44 = 1.0f;
}
These are Direct3D matrices.

L. Spiro

PARTNERS