Thursday, 2 February 2012

Tutorial 1: Adding Kinect To A Project

Right now it is time to really get stuck into it.  Hopefully by now you have installed Visual C# Express 2010, XNA 4.0 and the Kinect SDK 1.0.  If not head to Tutorial 0: Setting Up For Kinect first.

Getting Started
First open Visual C# Express and create a new Project.  We want Windows Game(4.0) project which can be found under the XNA Game Studio 4.0 template.  Enter "KinectForXna" as the name, you can use any name for your project but it may become confusing later when I refer to the project name.

Now we have our first XNA Game and if you Press F5 it will start the build in debug mode and you should see a cornflower blue background:

Not very exiting but for the purposes of this tutorial it shows your project will run.  
If we look at the code that has been opened in Visual Studio you can see that XNA has entered lots of nice comments describing what each of the 5 methods do, take a moment to read this if this is your first XNA project.  I will of course explain them in more detail when we get to using them.

Adding Kinect
Now it is time to import the Kinect library into our project.  In the top right of Visual Studio you will see the Solution Explorer, listed are two projects, KinectForXna and KinectForXnaContent. Right click on the project titled KinectForXna then select "Add Reference...".

 On the new window go to the .NET tab, order by the Component Name and find "Microsoft.Kinect", select it and click OK. 

We have now added the Kinect Library to our project and this should be visible under the References of our project in the solution explorer.
Wrapping Up
In this tutorial we have created a new XNA 4.0 Game and added a Reference to the Kinect Library, next up is moving the sensor.

No comments:

Post a Comment