HW1 猜拳
import de.voidplus.leapmotion.*;PImage img2, img0, img5;
LeapMotion leap;
void setup() {
size(800, 500, P3D);
background(255);
noStroke();
fill(50);
// ...
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/603/%B3%E6%A4%B8%A5%7C/%BDd%A8%D2%C0%C9/%B3y%AB%AC/%A5%DB%C0Y-%B6%C0.png");
img5=loadImage("http://elearning.slps.ntpc.edu.tw/6/100/samples/%E7%AC%AC04%E7%AB%A0-%E5%89%AA%E5%88%80%E7%9F%B3%E9%A0%AD%E5%B8%83%E7%8C%9C%E6%8B%B3/%E9%80%A0%E5%9E%8B/%E5%B8%83-%E9%BB%83.png");
leap = new LeapMotion(this);
}
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();
int f=hand.countFingers();
if (f==0||f==1)image(img0, 0, 0);
if (f==2||f==3)image(img2, 0, 0);
if (f==5||f==4)image(img5, 0, 0);
// 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");
}
HW2 會跟著手座標移動的猜拳
import de.voidplus.leapmotion.*;
PImage img2, img0, img5;
LeapMotion leap;
void setup() {
size(800, 500, P3D);
background(255);
noStroke();
fill(50);
// ...
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/603/%B3%E6%A4%B8%A5%7C/%BDd%A8%D2%C0%C9/%B3y%AB%AC/%A5%DB%C0Y-%B6%C0.png");
img5=loadImage("http://elearning.slps.ntpc.edu.tw/6/100/samples/%E7%AC%AC04%E7%AB%A0-%E5%89%AA%E5%88%80%E7%9F%B3%E9%A0%AD%E5%B8%83%E7%8C%9C%E6%8B%B3/%E9%80%A0%E5%9E%8B/%E5%B8%83-%E9%BB%83.png");
imageMode(CENTER);
leap = new LeapMotion(this);
}
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();
int f=hand.countFingers();
if (f==0||f==1)image(img0,hand_position.x,hand_position.y);
if (f==2||f==3)image(img2,hand_position.x,hand_position.y);
if (f==5||f==4)image(img5,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");
}
HW3期中作品
第一人稱射擊遊戲~~~以手及動作發射!以手掌位置來移動
或是,扮演蜘蛛人,以手勢吐絲


沒有留言:
張貼留言