Results 1 to 7 of 7

Thread: matrix and collada

  1. #1

    matrix and collada

    Hy.
    I'm a problem with collada and opengl : i savet with opencollada plugin for 3ds a scene and i would set the local trasformation matrix(i'm use backed matrix option in the options form) , how i convert a 16 characters matric from collada file to opengl matrix?
    I read about colmajor and rowmajor , what is the correct format for translate collada matrix to opengl matrix?
    Thanks.

  2. #2
    Junior Member
    Join Date
    Mar 2010
    Posts
    4

    Re: matrix and collada

    Hi,

    Collada uses the row-major format and OpenGL the col-major format.
    e.g.:
    Code :
    1   2   3   4
    5   6   7   8
    9   10  11  12
    13  14  15  16
     
    Collada: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
    OpenGL: 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16

    I didn't try it, but it should be correct.

    [admin: your statement is incorrect. COLLADA is column-major also.]

  3. #3

    Re: matrix and collada

    I do this function:
    for collada importer:
    [source]
    void CColladaReaderTriangles::GetMatrixComponent(domNod e* dn ,Transformation* trans)
    {
    domMatrix_Array pMatrix = dn->getMatrix_array();
    const unsigned int nMxCount = (unsigned int)pMatrix.getCount();
    float* pfVect = new float[16];
    for(unsigned int iMx = 0; iMx< nMxCount; iMx ++)
    {

    domFloat4x4* pV = &pMatrix.get(iMx)->getValue();

    pfVect[0]=((float)pV->get(0));
    pfVect[1]=((float)pV->get(1));
    pfVect[2]=((float)pV->get(2));
    pfVect[3]=((float)pV->get(3));

    pfVect[4]=((float)pV->get(4));
    pfVect[5]=((float)pV->get(5));
    pfVect[6]=((float)pV->get(6));
    pfVect[7]=((float)pV->get(7));

    pfVect[8]=((float)pV->get();
    pfVect[9]=((float)pV->get(9));
    pfVect[10]=((float)pV->get(10));
    pfVect[11]=((float)pV->get(11));

    pfVect[12]=((float)pV->get(12));
    pfVect[13]=((float)pV->get(13));
    pfVect[14]=((float)pV->get(14));
    pfVect[15]=((float)pV->get(15));

    }

    //create 3x3 column major
    Matrix3f matrixRot(pfVect[0], pfVect[4], pfVect[8], pfVect[1], pfVect[5], pfVect[9], pfVect[2], pfVect[6], pfVect[10]);
    Vector3f translation(pfVect[3], pfVect[7], pfVect[11]);

    .
    .
    .ecc...
    }
    [/source]


    the translation work fine, but the rotation is flipped,may be that is relative to collada exporter 3dsmax that export in Z_UP or Y_UP?or there are other errors?
    thanks

  4. #4
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: matrix and collada

    Correction to earlier poster: COLLADA matrices are column-major (written row-by-row for human readability).

    Example:
    Code :
    <matrix> 
      1.0 0.0 0.0  X 
      0.0 1.0 0.0  Y 
      0.0 0.0 1.0  Z 
      0.0 0.0 0.0 1.0
    </matrix>

  5. #5

    Re: matrix and collada

    thanks ,
    so this matrix :
    <matrix>Collada: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16</matrix>
    how become in opengl 3x3 rotation matrix?

    Sorry but i'm a little confused.
    by

  6. #6
    Senior Member
    Join Date
    Aug 2004
    Location
    California
    Posts
    771

    Re: matrix and collada

    Code :
    <matrix>
       1  2  3  4
       5  6  7  8
       9 10 11 12
      13 14 15 16
    </matrix>
    becomes:
    Code :
    / 1  2  3 \
    | 5  6  7 |
    \ 9 10 11 /
    ... with the appropriate rotation math ...

    See http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml

  7. #7
    Junior Member
    Join Date
    Mar 2010
    Posts
    4

    Re: matrix and collada

    oh, maybe i misunderstood the specification text:
    "These matrices are written in rowmajor order to aid the human reader."
    (COLLADA Core Elements Reference 5-77)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •