public void onStartPose(String pose, int userId) {
    println("onStartdPose - userId: " + userId + ", pose: " + pose);
    println(" stop pose detection");

    context.stopPoseDetection(userId);
    context.requestCalibrationSkeleton(userId, true);
  }
  public void onEndCalibration(int userId, boolean successfull) {
    println("onEndCalibration - userId: " + userId + ", successfull: " + successfull);

    if (successfull) {
      println("  User calibrated !!!");
      context.startTrackingSkeleton(userId);
    } else {
      println("  Failed to calibrate user !!!");
      println("  Start pose detection");
      context.startPoseDetection("Psi", userId);
    }
  }
  public void setupContext() {
    // setup onenNI context
    context = new SimpleOpenNI(this);
    // enable depthMap generation
    context.enableDepth();
    // enable camera image generation
    context.enableRGB();
    context.setMirror(true);

    // enable skeleton generation for all joints
    context.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL);
    stroke(255, 255, 255);
    smooth();
  }
  public void draw() {
    background(200, 0, 0);
    // update the cam
    context.update();

    // update nite
    context.update(sessionManager);

    // draw depthImageMap
    image(context.depthImage(), 0, 0);

    // draw the list
    pointDrawer.draw();

    text(frameRate, 10, 10);
  }
  public void setup() {
    context = new SimpleOpenNI(this);

    // mirror is by default enabled
    context.setMirror(true);

    // enable depthMap generation
    context.enableDepth();

    // enable the hands + gesture
    context.enableGesture();
    context.enableHands();

    // setup NITE
    sessionManager = context.createSessionManager("Click,Wave", "RaiseHand");

    pointDrawer = new PointDrawer();
    flowRouter = new XnVFlowRouter();
    flowRouter.SetActive(pointDrawer);

    sessionManager.AddListener(flowRouter);

    size(context.depthWidth(), context.depthHeight());
    smooth();
  }
  public void draw() {
    background(0);
    fill(0, 255, 0);
    stroke(255);
    // get kinect color image
    context.update();
    // scale to an arbitrary size and position (e.g. scale down 75%, and align to bottom / center)
    skeleton.updateSkeleton();

    if (onePlayer) {
      paddles[0].update(skeleton.getScreenCoords(1, paddleSelector1).y);
      paddles[1].update(skeleton.getScreenCoords(1, paddleSelector2).y);
    } else {
      paddles[0].update(skeleton.getScreenCoords(1, paddleSelector1).y);
      try {
        paddles[1].update(skeleton.getScreenCoords(2, paddleSelector2).y);
      } catch (Exception e) {
      }
    }

    for (int i = 0; i < paddles.length; i++) {

      paddles[i].drawPaddle();
    }
    ball.update();
    ball.checkCollision(paddles);
    ball.drawBall();

    /*PVector rHand = skeleton.getScreenCoords(1, SimpleOpenNI.SKEL_RIGHT_HAND) ;
    PVector lHand = skeleton.getScreenCoords(1, SimpleOpenNI.SKEL_LEFT_HAND) ;
    fill(255, 0, 0);
    ellipse(rHand.x, rHand.y, 20, 20);
    ellipse(lHand.x, lHand.y, 20, 20);*/
    float offset = 80;
    text(
        str(paddles[0].points),
        width - (offset + (0.5f * textWidth(str(paddles[0].points)))),
        height - 50);
    text(str(paddles[1].points), offset, height - 50);
    fill(0, 255, 0, 255 - ((255 / (timer + 1)) * (timer + 1)));

    if (timer > 0) {
      String txt = "POINT";
      text(txt, (width / 2) - (0.5f * textWidth(txt)), height / 2);
      timer--;
    }
  }
  // OPENNI CALLBACKS
  public void onNewUser(int userId) {
    println("onNewUser - userId: " + userId);
    println("  start pose detection");

    context.requestCalibrationSkeleton(userId, true);
  }