2015年3月9日 星期一

第三週課程

第一週課程

import de.voidplus.leapmotion.*;

LeapMotion leap;

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

void draw(){
  background(255);
  for(Hand hand : leap.getHands()){
    hand.draw();
  }
}



















手掌中心加上方塊

import de.voidplus.leapmotion.*;

LeapMotion leap;

void setup(){
  size(800,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(800,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());

  }
}

void myDraw(PVector pos){
  pushMatrix();
  translate(pos.x, pos.y);
  fill(255,0,0); sphere(20);
  popMatrix();
}



沒有留言:

張貼留言