2014年3月10日 星期一

Week04

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();
  }
}

import de.voidplus.leapmotion.*;
import javax.vecmath.Vector3f;
import processing.core.PApplet;
import peasy.*;
import bRigid.*;

LeapMotion leap;
PeasyCam cam;
BPhysics physics;
BObject rigid;
BTerrain terrain;

void setup(){
  size(800, 500, P3D);
  frameRate(60);
  cam = new PeasyCam(this, 200);
  cam.pan(0, 50);
  cam.rotateX(.4f);
  leap = new LeapMotion(this);
  physics = new BPhysics();
  physics.world.setGravity(new Vector3f(0, 40, 0));
  float height = 1.1f;
  terrain = new BTerrain(this, 110, height, 10, new Vector3f(), new Vector3f(2, 2, 2));
  physics.addBody(terrain);
  rigid = new BBox(this, 5, 1.0f, 10.0f, 1.0f);
}

void draw(){
  background(255);
  lights();
  rotateY(frameCount*.002f);
  physics.update();
  terrain.display();
  for (int i =1;i<physics.rigidBodies.size();i++) {
    BObject b = (BObject) physics.rigidBodies.get(i);
    b.display(50, 50, 50);
  }
  for(Hand hand : leap.getHands()){
    hand.draw();
    for(Finger finger : hand.getFingers()){
      int n=hand.countFingers();
      if(n>1){
        Vector3f pos = new Vector3f(random(-90, 90), -30, random(-90, 90));
        BObject r = new BObject(this, 5, rigid, pos, true);
        physics.addBody(r);
      }
    }

  }
}

沒有留言:

張貼留言