Creating a XNA Kinect Component
- Posted: Nov 04, 2011 at 6:00 AM
- 6,239 Views
- 2 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Today's project provides a cool reusable Kinect XNA component. Being reusable makes adding Kinect features to your XNA based games almost plug-n-play simple...
So, I have been playing about with the Kinect Beta, having finally got a power supply for my Kinect sensor (I got a Slim XBox). I am not doing a great deal with this post, just thought if you have a sensor you might want to start playing with it in XNA, so I have created a component you can use to get the video, depth and skeletal data back from the device.
Forgive the state of my living room, but this shows the video and depth data being retrieved from the device, notice the FPS is at 30, the project will run at 60, but the sensor runs at 30, so it gets a bit jittery if you are running at 60 FPS, so I have restricted it to 30.
So here is the simple component you can use to get data back from the device.
Project Information URL: http://xna-uk.net/blogs/randomchaos/archive/2011/10/19/xna-a-kinect-component.aspx
Project Source URL: http://xna-uk.net/blogs/randomchaos/archive/2011/10/19/xna-a-kinect-component.aspx
kinect = new KinectXNAComponent(this);
spriteBatch.Begin(SpriteSortMode.Immediate,BlendState.Opaque);
if (kinect.depthMap != null)
{
spriteBatch.Draw(kinect.depthMap, new Rectangle(GraphicsDevice.Viewport.Width / 2, 0, GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2), Color.White);
}
if (kinect.colorMap != null)
{
GraphicsDevice.VertexSamplerStates[0] = SamplerState.LinearClamp;
spriteBatch.Draw(kinect.colorMap, new Rectangle(0, 0, GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2), Color.White);
}
if (kinect.renderJoints != null)
{
int sc = kinect.renderJoints.Count;
for (int s = 0; s < sc; s++)
{
spriteBatch.Draw(jointImage, new Rectangle(kinect.renderJoints[s].X, kinect.renderJoints[s].Y, 8, 8), Color.Gold);
}
}
spriteBatch.End();
Contact Information:
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
good
Hi!
This kinect that you are defining as a KinectXNAComponent is a Runtime, right?
Thanks and sorry about the english, i'm brazillian and i'm just learning how to write in english. I want to create things with kinect, but in brazillian sites it's almost impossible to see references.
Remove this comment
Remove this thread
close