Platform SDK: DirectX

What Is a Matrix Stack?

The Direct3DX utility library provides the ID3DXMatrixStack interface. It supplies a mechanism to allow matrices to be pushed onto and popped off of a matrix stack. Implementing a matrix stack is an efficient way to keep track of matrices while traversing a transform hierarchy.

The Direct3DX utility library uses a matrix stack to store transformations as matrices. The various methods of the ID3DXMatrixStack interface deal with the current matrix, or the matrix located on top of the stack. You can clear the current matrix with the ID3DXMatrixStack::LoadIdentity method. If you need to explicitly specify a certain matrix to be loaded as the current transformation matrix, use the ID3DXMatrixStack::LoadMatrix method. Then, you can call either the ID3DXMatrixStack::MultMatrix method or the ID3DXMatrixStack::MultMatrixLocal method to multiply the current matrix by the specified matrix.

The ID3DXMatrixStack::Pop method allows you to return to the previous transformation matrix and the ID3DXMatrixStack::Push method adds a transformation matrix to the stack.

The individual matrices on the matrix stack are represented as 4×4 homogenous matrices, defined by the Direct3DX utility library D3DXMATRIX structure.