Jump to content
  • Advertisement
Sign in to follow this  
bobf

rotation inside a tiled enviroment

This topic is 4664 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 have a tiled collision system using rectangle shaped entities, does anyone know a simple way of rotating a given rectangle that will still conform to the tiled collision system? the width and height will differ, but this is just a 2x4 example purrty example: ..XX.. ..XX.. ..XX.. ..YX.. rotated 90' right .... YXXX XXXX .... rotated 45' right ..XX .XX. .XX. YX.. Any algorithms come to mind? I'm hoping for a speedy solution, but I may just have to give it up, this is for tiled based vehicles with rotations of 45'. I don't want to have to settle for square cars or changing the system entirely :< plx assist mathgods! (mods feel free to move if its not mathematical enough for this section.)

Share this post


Link to post
Share on other sites
Advertisement
So the vehicles can only be oriented at multiples of 45 degrees? I can't think of an easier general solution than SAT (separating axis theorem). You could probably special-case the code nicely given the restrictions on the environment, though. However, once you get the system in place, arbitrary orientations will be just about as easy as mults of 45 degrees. Unless it's sprite based of course, in which case you may have a good reason for restricting the rotations.

Remember that changing direction may bring a vehicle into penetration with an obstacle. So whenever the direction changes you should probably disallow the change if this happens. Otherwise (assuming you're using collision resolution based on penetration depth) the vehicle might 'push away from' the wall in an unnatural manner.

Well, I don't know if that helps at all, but let us know if you need more specific advice...

Share this post


Link to post
Share on other sites
Well, the 3D vehicles are models and go through 360 degrees, but the collision system is in tiles. So it may as well be 45' degrees.. maybe I should just hardcode it, just wondered if anyone had a generic formula.

Thanks for your help

Share this post


Link to post
Share on other sites
This is actually something of a rasterization problem, but instead of rendering to the screen you're "rendering" to the collision space. Store all your data and do all the transformations is real numbers, then once you're ready for them to be collided rasterize them into your collision space using standard algorithms (such as Bresenham for lines, etc.).

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!