What are the default transformation matrices set by ID3DXSprite::Begin?

125 Views Asked by At

Unless the D3DXSPRITE_OBJECTSPACE flag is set, the ID3DXSprite::Begin method sets the world, view and projection transformations on the device.

These default transformations do not work well if sprites are rotated out of the X-Y plane so I would like to modify them, which will be a lot easier if I know what they are.

What transformations does ID3DXSprite::Begin set?

1

There are 1 best solutions below

0
On BEST ANSWER

ID3DXSprite::Begin sets the world and view transformations to the identity.

The projection transformation is set to matProj:

// pdev is the IDirect3DDevice9 pointer
D3DVIEWPORT9 viewport;
pdev->GetViewport(&viewport);

// Short variable names to make the matrix readable
int w = viewport.Width; int h = viewport.Height;
int vx = viewport.X; int vy = viewport.Y;

// The scaling factors
float sx = 1.0f / w;
float sy = 1.0f / h;

// The projection matrix
D3DMATRIX matProj = {
                    sx * 2.0f,                  0.0f, 0.0f, 0.0f,
                         0.0f,            -sy * 2.0f, 0.0f, 0.0f,
                         0.0f,                  0.0f, 1.0f, 0.0f,
       -sx * (w + 2 * vx + 1), sy * (h + 2 * vy + 1), 0.0f, 1.0f
};