/** Initialise the coordinates for the default body poses (used when we cannot see a user). */ private UserData setUpPose(float[] x, float[] y) { UserData pose = new UserData(-1); for (int i = 0; i < x.length; i++) { float cx = (float) (x[i] * MyWorld.SCALE); float cy = (float) (y[i] * MyWorld.SCALE); pose.setJoint(i, new Joint(i, 1.0f, null, new Point3D(cx, cy, 0.0f))); } return pose; }
public void act() { UserData user = ((MyWorld) getWorld()).getUser(0); if ((user != null) && user.isTracking()) { trackUser(user); } else { // no user visible trackUser(defaultPose); } checkHands(); }
public String handCheck() { if (user.getHighestJoint() == Joint.LEFT_HAND) { highJoint = "Left"; return highJoint; } return "boooooom"; }
/** Check whether a hand (of any user) touches the radio. Play radio if it does. */ public void checkHands() { MyWorld world = (MyWorld) getWorld(); UserData[] users = world.getTrackedUsers(); for (UserData user : users) { Joint rightHand = user.getJoint(Joint.RIGHT_HAND); Radio radio = getRadio(rightHand.getX(), rightHand.getY()); if (radio != null) { // yes, there was a radio radio.play(1); } else { Joint leftHand = user.getJoint(Joint.LEFT_HAND); radio = getRadio(leftHand.getX(), leftHand.getY()); if (radio != null) { radio.play(2); } } } }
/** Display a tracked user on screen */ private void trackUser(UserData user) { for (int i = 0; i < Joint.NUM_JOINTS; i++) { Joint joint = user.getJoint(i); dot[i].set(joint.getX(), joint.getY()); } }