# Rotating a sprite?

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

## Recommended Posts

I'm using the ID3DXSprite interface to control my sprites. Is there any tutorials, advice etc. on how to rotate such sprites?

##### Share on other sites
You can actually use Direct3D or OpenGL for 2d. Not only is this a lot faster, but you also get rotation, scaling, blending, alpha, etc for free. I don't see any strong reasons to continue using DirectDraw.

##### Share on other sites
ID3DXSprite is not DirectDraw.

I believe it also supports attaching a transformation matrix

##### Share on other sites
Oops, I completely misread that :P Sorry.

##### Share on other sites
I guess it's the transformation matrix that is confusing me.

##### Share on other sites
There should be something in there that creates a rotation matrix. Then you can apply that matrix to the sprite.

##### Share on other sites
Ah, ID3DXSprite::SetTransform() is what I'm looking for.

HRESULT SetTransform(
CONST D3DXMATRIX * pTransform
);

Describing the matrix is confusing, though. What do these variables mean?

typedef struct D3DXMATRIX {
FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );
} D3DXMATRIX;

##### Share on other sites
That's just a 4x4 matrix of floats. The names of the variables ( _11, _23, etc ) are just indications of the positions - _11 means location 1,1 _23 means location 2,3 - or, row 2, column 3.

I'm pretty sure there's a function in D3DX that creates a rotation matrix for you, given the angle.

##### Share on other sites
Thanks for the thoughts, I'll look into that.

##### Share on other sites
Wikipedia has a couple articles about transformation matrices. I found them quite helpful, but they might be too generic for what you're doing.

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 22
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002218
×