LeapMotion leap;
void setup(){
size(600,600,P3D);
leap=new LeapMotion(this);
}
void draw(){
background(255);
for(Hand hand: leap.getHands()){
hand.draw();
PVector pos=hand.getPosition();//手的向量
translate(pos.x,pos.y);
fill(255,0,0); box(100);//畫方塊
}
}
****************************************
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(600,600,P3D);
leap=new LeapMotion(this);
}
void draw(){
background(255);
for(Hand hand: leap.getHands()){
hand.draw();
myDraw(hand.getPosition());//手掌
myDraw(hand.getThumb().getPosition());//拇指
myDraw(hand.getIndexFinger().getPosition());//食指
myDraw(hand.getMiddleFinger().getPosition());//中指
myDraw(hand.getRingFinger().getPosition());//無名指
myDraw(hand.getPinkyFinger().getPosition());//小指
/*用函式代替下面的東西*/
/*PVector pos=hand.getPosition();
translate(pos.x,pos.y);
fill(255,0,0); box(100);*/
}
}
void myDraw(PVector pos){//設一個函式把動作包起來
pushMatrix();
translate(pos.x,pos.y);
fill(255,0,0); sphere(20);//畫一顆球
popMatrix();//跟圖學一樣用push、pop保護起來
}
****************************************
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(600,600,P3D);
leap=new LeapMotion(this);
}
void draw(){
background(255);
for(Hand hand: leap.getHands()){
println("yaw"+hand.getYaw());
pushMatrix();
translate(300,300);
rotateY(hand.getYaw()*0.1);
box(100);
popMatrix();
hand.draw();
myDraw(hand.getPosition());
myDraw(hand.getThumb().getPosition());
myDraw(hand.getIndexFinger().getPosition());
myDraw(hand.getMiddleFinger().getPosition());
myDraw(hand.getRingFinger().getPosition());
myDraw(hand.getPinkyFinger().getPosition());
/*PVector pos=hand.getPosition();
translate(pos.x,pos.y);
fill(255,0,0); box(100);*/
}
}
void myDraw(PVector pos){
pushMatrix();
translate(pos.x,pos.y);
fill(255,0,0); sphere(20);
popMatrix();
}
****************************************
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(600,600,P3D);
leap=new LeapMotion(this);
}
void draw(){
background(255);
for(Hand hand: leap.getHands()){
println("yaw"+hand.getYaw());
pushMatrix();
translate(300,300);
rotateY(-radians(hand.getYaw())); //角度轉徑度
stroke(0); fill(255); box(100); //加邊框
popMatrix();
hand.draw();
myDraw(hand.getPosition());
myDraw(hand.getThumb().getPosition());
myDraw(hand.getIndexFinger().getPosition());
myDraw(hand.getMiddleFinger().getPosition());
myDraw(hand.getRingFinger().getPosition());
myDraw(hand.getPinkyFinger().getPosition());
/*PVector pos=hand.getPosition();
translate(pos.x,pos.y);
fill(255,0,0); box(100);*/
}
}
void myDraw(PVector pos){
pushMatrix();
translate(pos.x,pos.y);
fill(255,0,0); sphere(20);
popMatrix();
}
****************************************
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(600,600,P3D);
leap=new LeapMotion(this);
}
void draw(){
background(255);
for(Hand hand: leap.getHands()){
//println("yaw"+hand.getYaw());
println("pitch"+hand.getPitch());
pushMatrix();
translate(hand.getPosition().x, hand.getPosition().y);
rotateZ(radians(hand.getPitch()));
rotateY(-radians(hand.getYaw()));
stroke(0); fill(255); box(100);
popMatrix();
hand.draw();
myDraw(hand.getPosition());
myDraw(hand.getThumb().getPosition());
myDraw(hand.getIndexFinger().getPosition());
myDraw(hand.getMiddleFinger().getPosition());
myDraw(hand.getRingFinger().getPosition());
myDraw(hand.getPinkyFinger().getPosition());
/*PVector pos=hand.getPosition();
translate(pos.x,pos.y);
fill(255,0,0); box(100);*/
}
}
void myDraw(PVector pos){
pushMatrix();
translate(pos.x,pos.y);
fill(255,0,0); sphere(20);
popMatrix();
}
****************************************





沒有留言:
張貼留言