Just a quick post on something I thought I'd share, for anyone out there who's developing games for Kinect using XNA. This is a fairly simple implementation full-body collision in 2D for Kinect, using Separated axis Theory to detect collisions. A particularly in-depth and intuitive paper about Separated Axis Theory by Johnny Huynh can be found here:
http://www.jkh.me/files/tutorials/Separating%20Axis%20Theorem%20for%20Oriented%20Bounding%20Boxes.pdf (Accessed 01/04/2013)
This paper also explains some ways to optimize the computations used within SAT and how to use it in three-dimensional space, so is well worth a read.
To summarize, SAT can be thought of as shining a 'light' on to any two convex shapes. These shapes produce shadows along their different axes, and if all of the axes of both shapes have intersecting shadows, then we can infer that the objects are colliding with one another. If you're not familiar with Vector Projection, you may want to go and have a read-up, since that's the main mathematical principle used in SAT. My collision model simply maps the different joints, and creates object-oriented bounding-boxes for each limb, rotating the box by the angle found between the center-point between two joints and the up vector. The implementation also stores information about the velocity of a given limb, by calculating how much and in which direction the center-point of the limb has moved between each frame. This feature is designed to help with collision response, and could be used to implement some simple 2D physics, for example. The collision detection algorithm uses a Collision Tree, a collision rectangle is drawn around the entire body, and if an entity collides with this, it can then be tested against each individual limb. This improves efficiency, as the program is not having to check for collisions against each limb every single frame for objects that are no where near the player's body.
Full source code and and an executable of the sample program can be found below. If anyone uses this in their project, I do not ask to be credited. But feel free to drop me a line so I can see what you're doing with it!
Downloads:
Source Code (VS2010)
Sample Program
http://www.jkh.me/files/tutorials/Separating%20Axis%20Theorem%20for%20Oriented%20Bounding%20Boxes.pdf (Accessed 01/04/2013)
This paper also explains some ways to optimize the computations used within SAT and how to use it in three-dimensional space, so is well worth a read.
To summarize, SAT can be thought of as shining a 'light' on to any two convex shapes. These shapes produce shadows along their different axes, and if all of the axes of both shapes have intersecting shadows, then we can infer that the objects are colliding with one another. If you're not familiar with Vector Projection, you may want to go and have a read-up, since that's the main mathematical principle used in SAT. My collision model simply maps the different joints, and creates object-oriented bounding-boxes for each limb, rotating the box by the angle found between the center-point between two joints and the up vector. The implementation also stores information about the velocity of a given limb, by calculating how much and in which direction the center-point of the limb has moved between each frame. This feature is designed to help with collision response, and could be used to implement some simple 2D physics, for example. The collision detection algorithm uses a Collision Tree, a collision rectangle is drawn around the entire body, and if an entity collides with this, it can then be tested against each individual limb. This improves efficiency, as the program is not having to check for collisions against each limb every single frame for objects that are no where near the player's body.
Full source code and and an executable of the sample program can be found below. If anyone uses this in their project, I do not ask to be credited. But feel free to drop me a line so I can see what you're doing with it!
Downloads:
Source Code (VS2010)
Sample Program
No comments:
Post a Comment