Hi,
I am designing a 2D game engine using DirectX 9.0c.
Currently I am working on graphics core.
My question now is the following:
"D3DXMatrixTransformation2D" rotation function perimeter does not seem to be in degrees?
How do I change it into degrees? (0'-360')
(see source code below)
Thanks!
JeZ+Lee
Here is the source:
//-------------------------------------------------------------------------------------------------------------------------------
void render( void )
{
float x = 400; // Test value
float y = 240; // Test value
DXDevice->BeginScene();
DXDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 );
Sprite->Begin(D3DXSPRITE_ALPHABLEND);
D3DSURFACE_DESC textureInfo;
SpriteTexture->GetLevelDesc(0, &textureInfo);
float spriteWidth = (float)textureInfo.Width;
float spriteHeight = (float)textureInfo.Height;
RECT spriteRect;
spriteRect.top = 0;
spriteRect.left = 0;
spriteRect.bottom = textureInfo.Height;
spriteRect.right = textureInfo.Width;
D3DXVECTOR3 spritePosition;
spritePosition.x = 0.0f - (spriteWidth/2);
spritePosition.y = 0.0f - (spriteHeight/2);
spritePosition.z = 0.0f;
D3DXMATRIX matrixSpriteTransform;
// D3DXVECTOR2 spriteCentre = D3DXVECTOR2(spriteWidth/2, spriteHeight/2);
D3DXVECTOR2 screenPostion = D3DXVECTOR2(x, y);
float rotation = 0.0f; //<--- How to change to degrees ???
D3DXVECTOR2 scaling(1.0f, 1.0f);
D3DXMatrixTransformation2D(&matrixSpriteTransform, NULL, 0.0, &scaling, /*&spriteCentre*/NULL, rotation, &screenPostion);
Sprite->SetTransform(&matrixSpriteTransform);
Sprite->Draw( SpriteTexture, &spriteRect, NULL, &spritePosition, D3DCOLOR_RGBA(255,255,255,255) );
Sprite->End();
DXDevice->EndScene();
DXDevice->Present( NULL, NULL, NULL, NULL );
}
//-------------------------------------------------------------------------------------------------------------------------------