Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have created a game using Kinect + XNA and the game runs on full screen mode.. However when i try to touch or reach a certain area on the screen using hand.. I cant reach it.. I will already be outside the range of the sensor trying to touch the object on the game screen..

Is there anyway I can scale the skeletal values so that the users can easily touch objects on the screen without having to stretch or bend too much?

Game screen showing the problematic areas to reach in red

share|improve this question

1 Answer 1

You can get a position relative to the screen resolution, then it's just a matter of tweaking the values to find what works.

From http://kinectxna.blogspot.ie/2012/02/tutorial-5-skeletal-tracking.html :

foreach (Joint joint in skeleton.Joints)
{
     Vector2 position = new Vector2((((0.5f * joint.Position.X) + 0.5f) * (resolution.X)), (((-0.5f * joint.Position.Y) + 0.5f) * (resolution.Y)));
     spriteBatch.Draw(img, new Rectangle(Convert.ToInt32(position.X), Convert.ToInt32(position.Y), 10, 10), Color.White);
}

Instead of drawing to this position you could use it in your update logic. The values aren't perfect but they should get you on the right track.

Edit:

If in fullscreen you'll want to find the current resolution of the user's monitor. You can find it using:

GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height

Just put this in place of resolution in the above code and you should be good to go.

If this doesn't work try:

graphics.PreferredBackBufferWidth

graphics.PreferredBackBufferHeight

Where graphics is the GraphicsDeviceManager (declared in the game's constructor when creating a new XNA game). Depending on the scaling of the game one or the other of these should work.

share|improve this answer
    
I am using that formula and it doesnt help –  Sweta Dwivedi Dec 15 '12 at 15:04
    
The only thing I can think of in this case is that either resolution in the equation isn't correct or that it's stretching strangely for widescreen. I've only tried it out with 640x480 (to display on top of the color frame). Do you get different positions or is it all in the top left corner as in the screenshot? –  kiliki Dec 15 '12 at 22:41
    
In xna .. I'm doing toggle full screen mode!! and use graphic viewport to get the maxwidth and maxheight to use in place of resolution.X and resolution.Y –  Sweta Dwivedi Dec 16 '12 at 12:23
    
Forgot about the fullscreen. Edited answer to include a fix. I can't remember exactly how scaling works and there are a few different ways, but it should either be the preferred dimensions of your GraphicsDeviceManager or the current resolution of the user's monitor. –  kiliki Dec 16 '12 at 19:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.