Rotating a sprite?

Started by
9 comments, last by MTclip 18 years ago
I'm using the ID3DXSprite interface to control my sprites. Is there any tutorials, advice etc. on how to rotate such sprites?
Advertisement
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.
ID3DXSprite is not DirectDraw.

I believe it also supports attaching a transformation matrix

http://www.google.com/search?q=rotate+ID3DXSprite
Oops, I completely misread that :P Sorry.
I guess it's the transformation matrix that is confusing me.
There should be something in there that creates a rotation matrix. Then you can apply that matrix to the sprite.
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;

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.
Thanks for the thoughts, I'll look into that.
Wikipedia has a couple articles about transformation matrices. I found them quite helpful, but they might be too generic for what you're doing.

This topic is closed to new replies.

Advertisement