Jump to content
  • Advertisement
Sign in to follow this  
beatdown_master

Rotating Sprites using Direct3D 9

This topic is 3780 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, I've been creating textures and creating a LPD3DXSPRITE object to render them to the screen. However the Sprite->Draw() method does not allow me to render a rotated image. Is there anyway to do this, preferably still using the sprite object? I would also like to know how to handle 2D collision detection with rotated images. A rotated rectangular bounding box would be fairly odd and using a non-rotated bounding box is out of the question. How would one approach this problem? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by beatdown_master
Hello, I've been creating textures and creating a LPD3DXSPRITE object to render them to the screen. However the Sprite->Draw() method does not allow me to render a rotated image. Is there anyway to do this, preferably still using the sprite object?
Yes. The first result, Here has a solution as the last post.

Quote:
Original post by beatdown_master
I would also like to know how to handle 2D collision detection with rotated images. A rotated rectangular bounding box would be fairly odd and using a non-rotated bounding box is out of the question. How would one approach this problem?
A rotated bounding box makes most sense, assuming your collision system can handle it. Apart from that, you could use a bounding circle instead (Although it'll be less accurate). Those are really your only choices.

Share this post


Link to post
Share on other sites
At the highest level, use circle-circle collision detection, then, depending on the objects, ABB/OBB/Capsule/Convex Hull.

If both objects are not rotated, use AABB. If either or both are rotated, use OBB. If the objects in question have irregular tops/bottoms, try doing capsule collision detection instead of OBB, it may fit tighter for your particular case and it's slightly easier than OBB. A capsule is a line segment with a hull formed by plotting points with en equal distance from the line segment, that distance would be the capsule's radius (they are pill-shaped).

Then there is also the convex hull method which works similar to OBB but is much more expensive (because there are more axes on which to test, and more points which to test). Convex hull is a convex polygon around your sprite, that you create to try to fit in all the pixels as tight as possible. Maybe even generate it at runtime.

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!