Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Lesson 4.1 – Basic Leap Examples

Using Gestures:
import de.voidplus.leapmotion.*;

LeapMotion leap;


void setup(){
    size(800, 500);
    background(255);
    // leap = new LeapMotion(this).withGestures(); // with all gestures
     leap = new LeapMotion(this).withGestures("swipe"); // Leap detects only swipe gestures.
}

void draw(){
}

// ----- SWIPE GESTURE -----

void leapOnSwipeGesture(SwipeGesture g, int state){
  
          int  id                  = g.getId();
          PVector position_start      = g.getStartPosition();
          PVector position            = g.getPosition();

    switch(state){
        case 1: // Start
            break;
        case 2: // Update
            break;
        case 3: // Stop
            position.sub(position_start);
            position.normalize();
            if(position.x >= 0) {
               println("towards right");
            } else {
              println("towards left");
            }
             break;
        }
}



Finding hand positions:
import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup(){
  size(1000, 800);
  leap = new LeapMotion(this);
}

void draw(){
  background(255);


  // ========= get hand locations from Leapmotion =========
  for(Hand hand : leap.getHands()){

    // ----- Variables -----
    PVector hand_position    = hand.getPosition();
    boolean hand_is_left     = hand.isLeft();
    boolean hand_is_right    = hand.isRight();
    
   if(hand_is_left) {
         // println("left"+hand_position);
          fill(0,0,255);
          ellipse(hand_position.x, hand_position.y, 16, 16);
    } 
  if(hand_is_right) {
        fill(255,0,0);
          //println("right"+hand_position);
          ellipse(hand_position.x, hand_position.y, 16, 16);
    } 
   }
}