Why does my translation matrix needs to be transposed?

前端 未结 2 1546
闹比i
闹比i 2020-12-15 17:15

I\'m working on a small graphics engine using OpenGL and I\'m having some issues with my translation matrix. I\'m using OpenGL 3.3, GLSL and C++. The situation is this: I ha

2条回答
  •  没有蜡笔的小新
    2020-12-15 18:19

    You cannot swap matrices in a matrix multiplication, so A*B is different from B*A. You have to transpose B before swapping the matrices.

    A * B = t(B) * A
    

    try

    void DisplayObject::updateMatrices()
    {
        modelMatrix = identityMatrix();
        modelMatrix = translateMatrix( xPos, yPos, zPos ) * modelMatrix;
    
        /* update modelview-projection matrix */
        mvpMatrix = modelMatrix * (*projMatrix);
    }
    

提交回复
热议问题