Note that there are some explanatory texts on larger screens.

plurals
  1. POKinect Cursor Control with virtual XNA-Rectangle-'Touchpad' - Y-Axis inverted
    primarykey
    data
    text
    <p>I'm trying to implement a Real-Time Strategy control scheme for the MS Kinect. So far, I've got a cursor, which can be moved by moving your left Hand (or right, dependant on your handedness). I've got an Open-NI-based Kinect controller which sets up a skeleton for player-movements and delivers the wrist-, elbow-, shoulder- and body-center-coordinates to my application. To project these wrist-coordinates to the screen, I've set up a Rectangle, which is situated slightly left/right from the player's center and as long as the wrist moves inside the rectangle, the cursor moves on screen. My problem is, that the XNA-Rectangle has the upper left corner as point of origin, i.e. the X-axis points right, as it "should", but the Y-axis points down, while the Y-axis of the Kinect - coordinate system points up. This results in the cursor moving upwards on screen, when I move my hand down and vice versa. There's no way for me to change anything with the Kinect-coordinate system, so is it possible to 'flip' the 'coordinate system' of the rectangle, so that it's Y-axis points up,too? </p> <p>Here's the relevant code:</p> <p>(from Calibrate()-Method:)</p> <pre><code>List&lt;Vector3&gt; joints = UDPlistener.getInstance().ParseCalibCoordinates(data); //0 = Right Wrist 1 = Right Elbow 2 = Right Shoulder //3 = Left Wrist 4 = Left Elbow 5 = Left Shoulder //6 = Center height = 762; width = 1024; switch (hand) { case 0: cursorSpace = new Rectangle((int)(joints[6].X * 2) - 200, (int)(joints[6].Y * 2) + height, width, height); break; case 3: cursorSpace = new Rectangle((int)(joints[6].X * 2) - 1200, (int)(joints[6].Y * 2) + height, width, height); break; } public Point Cursor(String data) { List&lt;Vector3&gt; joints = UDPlistener.getInstance().ParsePlayCoordinates(data); //0 = Right Wrist 1 = Left Wrist 2 = Center double mhx = 0; //main hand x-coordinate double mhy = 0; // main hand y-coordinate switch (hand) { case 0: mhx = joints[hand].X; mhy = joints[hand].Y; break; case 3: mhx = joints[hand-2].X; mhy = joints[hand-2].Y; break; } int x; int y; if (Math.Abs(mhx - mhxOld) &lt; 1.0 || Math.Abs(mhy - mhyOld) &lt; 1.0) //To remove jittering of the cursor { x = (int) mhxOld * 2; y = (int) mhyOld * 2; } else { x = (int) mhx * 2; mhxOld = mhx; y = (int) mhy * 2; mhyOld = mhy; } Point cursor = new Point(0,0); if (cursorSpace.Contains(x,y)) { cursor = new Point(x - cursorSpace.X, y - CursorSpace.Y); lastCursorPos = cursor; return cursor; } </code></pre> <p>Sorry for the wall of text, I hope, I could make myself clear.</p> <p>Thanks in advance,</p> <p>KK</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload