2015年3月16日 星期一

Week04_鄒昀燕_01160023


飛行(旋轉):
import de.voidplus.leapmotion.*;

LeapMotion leap;


void setup() {
  size(800, 500, OPENGL);
  background(255);
  leap = new LeapMotion(this);
}


void draw() {
  background(255);

  for (Hand hand : leap.getHands ()) {
     hand.draw();
     float   angle  = hand.getYaw();
     PVector pos = hand.getPosition();
     translate(pos.x,pos.y,pos.z);
     rotateY(-radians(angle));
     fill(128);
     stroke(0);
     box(50);
   }
}



地板(與手選轉):
float groundDir=0;
void draw() {
  background(255);
for(int i=-10;i<=10;i++){
  for(int j=-10;j<=10;j++){
    pushMatrix();
    translate(300,300);
    rotateX(radians(70));
    rotateZ(radians(groundDir));
    translate(i*30,j*30);    //數字變大,地板就變大
    box(30);
    popMatrix();

 for (Hand hand : leap.getHands ()) {
     hand.draw();
     float   angle  = hand.getYaw();
     PVector pos    = hand.getPosition();
     translate(pos.x,pos.y,pos.z);
     rotateY(-radians(angle));
     fill(128);
     stroke(0);
     box(50);
     groundDir=-angle;



float nowX=0,nowY=0,nowA=0;
void draw() {
  nowY+=cos(nowA);
  nowX+=sin(nowA);
  background(255);
for(int i=-10;i<=10;i++){
  for(int j=-10;j<=10;j++){
    pushMatrix();
    translate(300,300);
    rotateX(radians(70));
    rotateZ(nowA);
    translate(i*300+nowX,j*300+nowY,-100);   數字不一樣,地板會變成格子!!
    fill(255); box(200);
    popMatrix();
  }
}

  for (Hand hand : leap.getHands ()) {
     hand.draw();
     float   angle  = hand.getYaw();
     PVector pos    = hand.getPosition();
     nowA +=radians(-angle/40);
     translate(pos.x,pos.y,pos.z);
     rotateY(-radians(angle));
     fill(128);
     stroke(0);
     box(100);
     //groundDir=-angle;
   }
}

沒有留言:

張貼留言