matrixelementogre

How to access individual elements of Matrix4 in OGRE


How can I access individual elements of Ogre::Matrix4? I saw the API of OGRE 1.9, but I couldn't find a way to access each matrix element individually. I want to access them using row, column numbers.

Ogre::Matrix4::operator[](size_t iRow) looked closest to what I need, but I couldn't make out what it meant to do or how to use it.

Also posted on OGRE::help forum.


Solution

  • Just access it as if it was an array (which internally it is).

    Ogre::Matrix4 mat;
    mat[0][0] = mat[3][3] = 1.5f;
    Ogre::Real r1 = mat[0][0]; // First element
    Ogre::Real r2 = mat[3][3]; // Last element