About Modelview

Hi,

After doing


GLfloat * matrixModel = new GLfloat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, matrixModel);

Here’s the matrix I obtain in the array painted in this function:


void Joint::paintMatrix(GLfloat *m)
{
    qDebug()<<m[0]<<" "<<m[1]<<" "<<m[2]<<" "<<m[3]<<endl
            <<m[4]<<" "<<m[5]<<" "<<m[6]<<" "<<m[7]<<endl
            <<m[8]<<" "<<m[9]<<" "<<m[10]<<" "<<m[11]<<endl
            <<m[12]<<" "<<m[13]<<" "<<m[14]<<" "<<m[15];
}

Matrix:
-0.707107, -0.5, 0.5, 0
0.707107, -0.5, 0.5, 0
0,0.707107,0.707107, 0
0, 0, -1000, 1

It doesn’t look like what I expect.
The real matrix isn’t this?
-0.707107, -0.5, 0.5, 0
0.707107, -0.5, 0.5, 0
0,0.707107,0.707107,-1000
0, 0, 0, 1
Or what I get is the transposed?

Or what I get is the transposed?

No, you’re transposing it in your printing function. Matrices in OpenGL are column-major. The first 4 elements are the first column, the next 4 are the next column, etc.

So, with this function, everything comes back to normal positions in matrix:


GLfloat * Joint::doTranspose(GLfloat *m)
{
    GLfloat * aux = new GLfloat[16];

    aux[0] = m[0];aux[1] = m[4];aux[2] = m[8];aux[3] = m[12];
    aux[4] = m[1];aux[5] = m[5];aux[6] = m[9];aux[7] = m[13];
    aux[8] = m[2];aux[9] = m[6];aux[10] = m[10];aux[11] = m[14];
    aux[12] = m[3];aux[13] = m[7];aux[14] = m[11];aux[15] = m[15];

    return aux;
}

It would be easier to just change your printing function. By doing what you’re doing, you’re transposing the matrix by doing this. Though that may be what you want, if your matrix conventions are row-major and you want to use this matrix in your code.