Friday, April 27, 2007

Seperating Axis Theorem "The Theory"

After much thought and much research on how a collision engine would work in "What If Mode" I finally pulled out my Calculus 3 book, Math & Physics in Game Programming, and many articles on Gamedev.net, and Gamesutra.com I have come across the solution. It is called the "Seperating Axis Theorem" the theorem states that for any objects lying ing a plane one can put a line between 2 convex shapes if and only if "iff" they're not intersecting. This seperating axis theorem can be applied for fast collision between 2 polygons where each face's normal is used as a seperating axis. For increased efficiency, parallel axes may be calculated as a single axis. -Wiki

How can this be applied to "What If Mode" Let's say that in our level the objects are constantly being formed, mis-shaped, and there constanly being changed this is called polymorphism in our game which isn't suppose to be confused with polymorphism in OOP. If we had polymorphic objects in a game not only would there have to be a fast collision detection, but the physics that simulated the collision of the polymorphic objects would have to concur with each other, and the collision detection must have some overlying rule that all objects obeyed. If this didn't happen then you would constantly have many algorithms asking which object is hitting which, and then have some type of sorting, or machine state based coding that asked after the algorithms told you which objects were about to collide or check for let's check for their collision. This could be many lines of code just to achieve a very simple concept.

Seperating Axis Theorem solves this problem by means of creating these axis on all the objects faces and check for intersection from there axis.

I'm going to create a demo of this seperating axis theorem simulation throw polygon shapes that form into other polygon shapes at random, and then work from their by means of applying actual images, and game objects. I shall continue this update through this blog, and will show all of my progressions and failing points while creating this demo.

No comments: