Jump to content
  • Advertisement
Sign in to follow this  
Aikavanak

Rotating a D3DXSprite before Scaling?

This topic is 5145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I'm using the updated D3DXSprite and D3DXMatrixTransform2D to draw the tiles of a 2D isometric map. I'd like these tiles to be in a 2:1 ratio (more specifically, 64x32 pixels), and I'm mapping square textures to to sprite. But, when I set up my matrix to rotate the tile by 45 degrees and scale the x axis by 2, I end up with a rotated rectange, as opposed to a stretched diamond, if you can visualize that. It's as if D3D is scaling the sprite before it's rotating it, and I want to rotate it before its scaled. Is it possible to do this with D3DXMatrixTransform2D, or do I have to set up my own matrices? Here's the code to draw a single tile: bool DrawTiles() { D3DXVECTOR2 vCenter((float)(TileWidth/2),(float)(TileHeight/2)); D3DXVECTOR2 vScale(2.0f,1.0f); float fRot=D3DXToRadian(45.0f); D3DXVECTOR2 vTrans(0.0f,0.0f); D3DXMATRIX matTransform; D3DXMatrixTransformation2D(&matTransform,&vCenter,NULL,&vScale,&vCenter, fRot,&vTrans); if(FAILED(m_pD3DXS->SetTransform(&matTransform))) return false; if(FAILED(m_pD3DXS->Begin(NULL))) return false; if(FAILED(m_pD3DXS->Draw(Texture.GetTexture(),NULL, NULL,NULL, D3DCOLOR_RGBA(255,255,255,255)))) return false; if(FAILED(m_pD3DXS->End())) return false; Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I believe you are looking for the ScalingRotation factor which you have set to NULL.

otherwise you can build your own matrix set (if you want more control):

MWorld = MRot * MScale * M(other transforms)

Also if that bugs you consider using a matrix-stack. ID3DXMatrixStack interface.

Share this post


Link to post
Share on other sites
dhanji,

You were right, after playing with the ScalingRotaion value a little (the documentation didn't help at all), I found that setting it to D3DXToRadian(-45.0f) gave the isometric shape I was looking for.

Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!