Jump to content
  • Advertisement
Sign in to follow this  
nullsmind

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.

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

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
ID3DXSprite is not DirectDraw.

I believe it also supports attaching a transformation matrix

http://www.google.com/search?q=rotate+ID3DXSprite

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

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!