Search code examples
processingleap-motion

Tracking X value of hand from leap motion in processing


ArrayList<PVector> pointss; 
PVector fp; 

 for (Hand hand : leap.getHands()) {
    for (Finger finger : hand.getFingers()) {
       fp   = finger.getPosition(); 
    }
 }

In the project I'm working on, I need to replace the mouseX variable with the X variable generated by the leap motion for hand tracking. It tracks the hand with [X, Y, Z] but since I need to save the variable that holds this data as a PVector I am not sure how to get the X variable out of it.

Any help is greatly appreciated.


Solution

  • If you have a PVector instance, you can simply reference its x field.

    PVector p = new PVector(100, 200, 300);
    println(p.x); //prints 100
    

    More info can be found in the reference.