Tuesday, 2 April 2013

Kinect Full Body Collision Model

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






Friday, 11 January 2013

Theme Park Scene Complete

I have just returned to University after the christmas break, and I am now finishing up last semester's projects. The theme park scene is now complete, and a full demo video has been created, and can be viewed below.


I am happy with how the scene has come together, although there are a lot of more advanced graphics programming concepts I now wish to explore much further. The most prominent of which is tessellation of surfaces in order to achieve better lighting effects. However, from here I wish to move away from the now deprecated fixed function pipeline and begin to explore more modern OpenGL, now that I have a grasp of some basic 3D programming techniques.

Monday, 10 December 2012

Theme Park Scene - Ferris Wheel

I have now finished most of the modelling I wish to implement into my theme park scene, the final model being the ferris wheel. The following are some images of the ferris wheel.



The carts themselves are their own model, included in the ferris wheel is an array of cart models. These are then given a position at initialization in their constructor using circle approximation.

In the following few days I will begin to add more interaction to the scene, here are the planned features:

  • Improve Camera movement with pitch rotation.
  • Add extra pre-defined viewing points
  • Add Night lighting mode
  • Add buttons (in the scene) to make both carousel and ferris wheel rotate.
  • Add Wii Remote functionality using the WiiYourself library.

Thursday, 6 December 2012

Christmas Mode!

I have added a christmas mode to the Theme Park scene, now featuring a christmas tree and snowman. These models disappear when christmas mode is turned off. The tree is made of a cylinder for it's trunk, and several cylinders used to represent it's leaves, being scaled down as they go up. I would also like to add some present models to go around the tree.


Wednesday, 5 December 2012

Theme Park Scene V2.0

Since my last update, I have done quite a major rewrite of the Theme Park scene's code and class structure in order to improve it's efficiency. Originally, when creating a primitive within a model, all that would be defined within the constructor would be the type of primitive and it's color or texture. This meant that at runtime, the program rotated, translated and scaled all of these objects into place for each model, and then again to place the models in the scene. This is a very inefficient way of generating the scene on each frame, and so I thought it would be more efficient to define primitive scale and position within a model within the constructor. This means that at runtime, all that needs to be transformed are the models themselves, greatly improving efficiency.

Whilst reworking the code, I was also able to rewrite all of my models, and in doing so add more detail to them. Below are some screenshots of the new version of my Theme Park scene.
An overview of what's completed in the new scene.

The benches are now modelled using cylinders to a more realistic effect.

The carousel has been given much more detail than the original.

An addition to the scene, this will soon be a ferris wheel.

   
Another addition to the scene is flower beds.

The fountain has been given extra detail.

 The Go Kart Track is another new addition. It uses rings to make up the track and barrier, and also the tyres around the centre. These are placed using the same circle approximation algorithm used to generate discs and rings.

An image of the tyres around the centre of the Go Kart Track.

 The river has now been dropped into the ground itself. This takes out the need for a river wall, and instead fences can be used. The fence model itself is now made to be of variable size, and the number of sections required and the length of each section can be passed into it's constructor. This creates a more realistic effect than before. The bridge has yet to be remodelled, and so is omitted in this image.


Sunday, 2 December 2012

Theme Park Scene 6

I have added a fountain model to the theme park, along with an additional version of the cube primitive with no top surface. I have also added a light model that will be used several times throughout the park, and will have lights attached to them to use when night time lighting is enabled.




Below is a video of the fountain's water. It creates a slightly more realistic effect than the river,as the subdivisions are less stretched, and the surface is a square as opposed to rectangular.

Below is an overview of the main section of the theme park. With each update I will take a screenshot from the same position in the scene, to get a picture of how it is developing.

Thursday, 29 November 2012

Theme Park Scene 5

Since my last update, I have made some alterations to the disc primitive that give it a centre point. From here, I was able to create a cone primitive to be used as the roof of the carousel. I have also improve efficiency by removing the normal calculations from the disc, and simply looped through all of the vertices and assigned them to Y 1. This prevents a considerable amount of unnecessary computation taking place. I have also created a 'ring' and 'hoop' primitive. The ring is flat, the same as a disc, however has a hole of customizable size in the centre. The hoop is a 3D implementation of the ring, using two ring primitives for the top and bottom surfaces. However, my normal calculations algorithm does not yet work properly for rings or cones, and this is what I will be working on next.

The normals for the cone primitive on the roof make it appear black.

The centre point of the disc primitive can be seen in wireframe mode.