import de.voidplus.leapmotion.*;
LeapMotion leap;
PImage img0,img2,img5;
void setup(){
size(800, 500, P3D);
background(255);
noStroke(); fill(50);
// ...
leap = new LeapMotion(this);
img2=loadImage("http://163.30.164.5/100-%A4W/603/%B3%E6%A4%B8%A5%7C/%BDd%A8%D2%C0%C9/%B3y%AB%AC/%B0%C5%A4M-%B6%C0.png");
img0=loadImage("http://163.30.164.5/100-%A4W/606/%B3%E6%A4%B8%A5%7C/%BDd%A8%D2%C0%C9/%B3y%AB%AC/%A5%DB%C0Y.gif");
img5=loadImage("http://163.30.164.5/100-%A4W/606/%B3%E6%A4%B8%A5%7C/%BDd%A8%D2%C0%C9/%B3y%AB%AC/%A5%AC-%B6%C0.png");
imageMode(CENTER);
}
void draw(){
background(255);
// ...
int fps = leap.getFrameRate();
// HANDS
for(Hand hand : leap.getHands()){
hand.draw();
int hand_id = hand.getId();
PVector hand_position = hand.getPosition();
PVector hand_stabilized = hand.getStabilizedPosition();
PVector hand_direction = hand.getDirection();
PVector hand_dynamics = hand.getDynamics();
float hand_roll = hand.getRoll();
float hand_pitch = hand.getPitch();
float hand_yaw = hand.getYaw();
float hand_time = hand.getTimeVisible();
PVector sphere_position = hand.getSpherePosition();
float sphere_radius = hand.getSphereRadius();
println("X:"+hand_position.x + "Y:"+hand_position.y);
int n=hand.countFingers();
if(n==2) image(img2,hand_position.x,hand_position.y);
if(n==5) image(img5,hand_position.x,hand_position.y);
if(n==0) image(img0,hand_position.x,hand_position.y);
// FINGERS
for(Finger finger : hand.getFingers()){
// Basics
finger.draw();
int finger_id = finger.getId();
PVector finger_position = finger.getPosition();
PVector finger_stabilized = finger.getStabilizedPosition();
PVector finger_velocity = finger.getVelocity();
PVector finger_direction = finger.getDirection();
float finger_time = finger.getTimeVisible();
// Touch Emulation
int touch_zone = finger.getTouchZone();
float touch_distance = finger.getTouchDistance();
switch(touch_zone){
case -1: // None
break;
case 0: // Hovering
// println("Hovering (#"+finger_id+"): "+touch_distance);
break;
case 1: // Touching
// println("Touching (#"+finger_id+")");
break;
}
}
// TOOLS
for(Tool tool : hand.getTools()){
// Basics
tool.draw();
int tool_id = tool.getId();
PVector tool_position = tool.getPosition();
PVector tool_stabilized = tool.getStabilizedPosition();
PVector tool_velocity = tool.getVelocity();
PVector tool_direction = tool.getDirection();
float tool_time = tool.getTimeVisible();
// Touch Emulation
int touch_zone = tool.getTouchZone();
float touch_distance = tool.getTouchDistance();
switch(touch_zone){
case -1: // None
break;
case 0: // Hovering
// println("Hovering (#"+tool_id+"): "+touch_distance);
break;
case 1: // Touching
// println("Touching (#"+tool_id+")");
break;
}
}
}
// DEVICES
// for(Device device : leap.getDevices()){
// float device_horizontal_view_angle = device.getHorizontalViewAngle();
// float device_verical_view_angle = device.getVerticalViewAngle();
// float device_range = device.getRange();
// }
}
void leapOnInit(){
// println("Leap Motion Init");
}
void leapOnConnect(){
// println("Leap Motion Connect");
}
void leapOnFrame(){
// println("Leap Motion Frame");
}
void leapOnDisconnect(){
// println("Leap Motion Disconnect");
}
void leapOnExit(){
// println("Leap Motion Exit");
}


沒有留言:
張貼留言