Building a world matrix

Posted by DeadMG on Stack Overflow See other posts from Stack Overflow or by DeadMG
Published on 2011-01-02T16:22:49Z Indexed on 2011/01/02 16:54 UTC
Read the original article Hit count: 219

Filed under:
|

When building a world projection matrix from scale, rotate, translate matrices, then the translation matrix must be the last in the process, right? Else you'll be scaling or rotating your translations. Do scale and rotate need to go in a specific order?

Right now I've got

std::for_each(objects.begin(), objects.end(), [&, this](D3D93DObject* ptr) {
    D3DXMATRIX WVP;
    D3DXMATRIX translation, rotationX, rotationY, rotationZ, scale;
    D3DXMatrixTranslation(&translation, ptr->position.x, ptr->position.y, ptr->position.z);
    D3DXMatrixRotationX(&rotationX, ptr->rotation.x);
    D3DXMatrixRotationY(&rotationY, ptr->rotation.y);
    D3DXMatrixRotationZ(&rotationZ, ptr->rotation.z);
    D3DXMatrixScaling(&translation, ptr->scale.x, ptr->scale.y, ptr->scale.z);
    WVP = rotationX * rotationY * rotationZ * scale * translation * ViewProjectionMatrix;
});

© Stack Overflow or respective owner

Related posts about matrix

Related posts about c++0x