貼立體圖在手上
分別貼小球在各個手指
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup() {
size(800, 500, 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());
}
}
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(800, 500, P3D);
leap = new LeapMotion(this);
}
void draw() {
background(255);
for (Hand hand : leap.getHands ())
{
println("pitch:"+hand.getPitch());
pushMatrix();
translate(hand.getPosition().x,hand.getPosition().y+100);
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());
}
}
void myDraw(PVector pos)
{
pushMatrix();
translate(pos.x,pos.y);
fill(255,0,0); sphere(20);
popMatrix();
}
沒有留言:
張貼留言