Why does my translation matrix needs to be transposed?

我的未来我决定 提交于 2019-11-29 01:09:05

For OpenGL

1, 0, 0, 0
0, 1, 0, 0
0, 0, 1, 0
x, y, z, 1

Is the correct Translation Matrix. Why? Opengl Uses column-major matrix ordering. Which is the Transpose of the Matrix you initially presented, which is in row-major ordering. Row major is used in most math text-books and also DirectX, so it is a common point of confusion for those new to OpenGL.

See: http://www.mindcontrol.org/~hplus/graphics/matrix-layout.html

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);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!