Sign in to follow this  
ChainChief

Rotated sprite collision detection

Recommended Posts

I am using directx to program a 2d sprite engine. I have a class which represents an image on the screen called jSprite. This class contains the d3d texture and float values of all the possible transformations. My collision detection function accepts 2 jSprite objects and should return true if any overlap exists between the sprites. So far, I have been using simple bounding rectangles, which work alright with non-rotated sprites. The problem with my current algorithm is that it does not account for the rotation, center of rotation, or scaling factors. I found this article: http://www.gamedev.net/reference/articles/article2604.asp , which would probably work for what I need, but it does not explain how to find the verticies of the rotated rectangles. I was thinking I could find the new points given a transformation matrix and the initial points, but I do not know how to do this. Another thing I was thinking of doing is using bounding circles for all my images, but I would still need a way to account for the rotation around a point other than the center of the sprite. Any help with this would be greatly appreciated.

Share this post


Link to post
Share on other sites
google rotation matrices and you'll see how to rotate a point in space. The rotation happens about the centre (0,0). If you want to rotate about a different point in space then you first move your point so that the centre of rotation is at 0,0 then rotate and then move everything back to where it was.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this