Kinectoid - Wed, Nov 23, 2011
The first Kinect-based sample for Neat game engine is available at http://kinectoid.codeplex.com.
To be able to build this sample, first you have to install the official Kinect SDK Beta 2 and obtain the latest version of the Neat source code and build it with the KINECT directive.
Neat currently supports Kinect through a component class named KinectEngine. To begin using Kinect in your Neat based XNA games, you have to follow these simple steps:
Initialization
You have to add an instance of KinectEngine to you game’s Components. Write these in your LoadContent method to initialize KinectEngine:
Kinect = new KinectEngine(this);
Components.Add(Kinect);
Kinect.Initialize();
CalibrateScreen.Kinect = Kinect;
Kinect.OpenVideoStream();
Just remember to call Kinect.Uninitialize() when you are shutting down the game.
Calibration
You can monitor the stream from the RGB camera and see the elevation angle in a screen named CalibrationScreen. To use this screen, you simply have to add it to your game’s screens:
Screens["kinect"] = new CalibrateScreen(this);
k_tilt [int] command changes the elevation angle of the Kinect sensor from the console.
Convert positions to XNA Vectors
Use KinectEngine.ToVector2 and KinectEngine.ToVector3 methods to scale and convert the position of each joint to XNA vectors. Now you are ready to interact with your game using Kinect.
Draw Skeletons and the RGB Stream
If you want to draw a skeleton, all you have to do is to call KinectEngine.DrawSkeleton(…) and pass a SpriteBatch and LineBrush to it. The image from the RGB camera can be accessed from the “kinectrgb” texture:
SpriteBatch.Draw(
game.GetTexture("kinectrgb"),
new Rectangle(0, 0, 640, 480),
Color.White);