// by Reas & Fry. O'Reilly / Make 2010
import de.voidplus.leapmotion.*;
LeapMotion leap;
PImage img;
float x1 = 40;
float x2 = 20;
int cuantos = 16000;
Pelo[] lista ;
float radio = 200;
float rx = 0;
float ry =0;
void setup() {
size(1650, 800,P3D);
img = loadImage("00.png");
radio = height/10;
lista = new Pelo[cuantos];
for (int i = 0; i < lista.length; i++) {
lista[i] = new Pelo();
}
noiseDetail(3);
leap=new LeapMotion(this);
}
void draw() {
background(255);
image(img, 0, 0);
/*fill(0,191,255);
noStroke();
x1 += 0.5;
x2 += 0.5;
arc(x1, 30, 40, 40, 0, 8);
arc(x1+30, 30, 40, 40, 0, 8);
arc(x1+15, 30+15, 40, 40, 0, 8);
arc(x2, 90, 40, 40, 0.52, 5.76);
*/
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(125);
stroke(0);
/*
box(100);
*/
/* float rxp = (mouseX-(width/2)) * 0.005;
float ryp = (mouseY-(height/2)) * 0.005;
rx = rx*0.9 + rxp*0.1;
ry = ry*0.9 + ryp*0.1;
translate(width/2, height/2);
rotateY(rx);
rotateX(ry);
*/
fill(100,100,255);
noStroke();
sphere(radio);
for (int i = 0; i < lista.length; i++) {
lista[i].dibujar();
}
}}
class Pelo
{
float z = random(-radio, radio);
float phi = random(TWO_PI);
float largo = random(1.15, 1.2);
float theta = asin(z/radio);
Pelo() { // what's wrong with a constructor here
z = random(-radio, radio);
phi = random(TWO_PI);
largo = random(1.15, 1.2);
theta = asin(z/radio);
}
void dibujar() {
float off = (noise(millis() * 0.0005, sin(phi))-0.5) * 0.3;
float offb = (noise(millis() * 0.0007, sin(z) * 0.01)-0.5) * 0.3;
float thetaff = theta+off;
float phff = phi+offb;
float x = radio * cos(theta) * cos(phi);
float y = radio * cos(theta) * sin(phi);
float z = radio * sin(theta);
float xo = radio * cos(thetaff) * cos(phff);
float yo = radio * cos(thetaff) * sin(phff);
float zo = radio * sin(thetaff);
float xb = xo * largo;
float yb = yo * largo;
float zb = zo * largo;
strokeWeight(1);
beginShape(LINES);
stroke(0);
vertex(x, y, z);
stroke(200, 150);
vertex(xb, yb, zb);
endShape();
}
}
沒有留言:
張貼留言