all digit are atractor

This commit is contained in:
lapin 2020-10-09 19:00:10 +02:00
parent afd9ae51f8
commit 9dbd6499c8
4 changed files with 60 additions and 44 deletions

View File

@ -70,5 +70,3 @@ public class LaserOut
processing_draw_line(line); // On pourait rajouter une condition si un paraetre est activer processing_draw_line(line); // On pourait rajouter une condition si un paraetre est activer
} }
} }

View File

@ -13,7 +13,7 @@ public class Attractor
Attractor(){ Attractor(){
pos = new PVector(0, 0, 0); pos = new PVector(0, 0, 0);
is_active = false; is_active = false;
weight = 200; weight = 20;
circle_radius = 20; circle_radius = 20;
col = getColInt(0, 0, 50); col = getColInt(0, 0, 50);

View File

@ -16,7 +16,7 @@ LeapMotion leap;
LaserOut laser_frame; LaserOut laser_frame;
int hand_id; int hand_id;
Attractor[] attractors = new Attractor[10]; Attractor[] attractors = new Attractor[10];
Particle[] particles = new Particle[10]; Particle[] particles;
PVector min_pos; PVector min_pos;
PVector max_pos; PVector max_pos;
@ -26,24 +26,75 @@ boolean att_stdout;
void setup() { void setup() {
size(800, 500); size(800, 500);
background(0); background(0);
int particle_path_length = 20;
int nb_particle = 10;
boolean particle_stdout = true; // print particle on stdout
att_stdout = false; // print attroctor on stdout
// ... // ...
leap = new LeapMotion(this); leap = new LeapMotion(this);
particles = new Particle[nb_particle];
att_stdout = false; laser_frame = new LaserOut(particle_stdout);
boolean print_stdout = false;
laser_frame = new LaserOut(print_stdout);
// init_attractors // init_attractors
for (int i = 0; i < attractors.length; i++){ for (int i = 0; i < attractors.length; i++){
attractors[i] = new Attractor(); attractors[i] = new Attractor();
} }
for (int i = 0; i < particles.length; i++){ for (int i = 0; i < particles.length; i++){
particles[i] = new Particle(30); // number of previous position drawn if (particle_path_length > 0)
particles[i] = new Particle(particle_path_length); // number of previous position drawn
else
particles[i] = new Particle(); // no previous article
} }
} }
void draw() {
background(50);
// ...
int fps = leap.getFrameRate();
int i = 0;
int att_id;
for (Hand hand : leap.getHands ()) {
if (i >= 2)
{
println("\n\n\n\t\t !! MORE THAN 2 hands isn't implemented");
continue;
}
// --------------------------------------------------
// Drawing
// hand.draw();
// // update attractors position and draw
// att_id = i * 5 + 0; // 5 => number of finger
// PVector pos = hand.getIndexFinger().getPositionOfJointDip();
// attractors[att_id].update_pos(pos);
int j = 0;
for (Finger finger : hand.getFingers()) {
att_id = i * 5 + j; // 5 => nunber of finger
PVector pos = finger.getPositionOfJointDip();
attractors[att_id].update_pos(pos);
j++;
}
i++;
}
particles_update_position();
draw_attractors();
draw_particles();
laser_frame.print_frame(); // print frame on stdout
disable_attractors();
}
void disable_attractors(){ void disable_attractors(){
for (Attractor att : attractors){ for (Attractor att : attractors){
att.is_active = false; att.is_active = false;
@ -69,40 +120,6 @@ void particles_update_position(){
} }
} }
void draw() {
background(50);
// ...
int fps = leap.getFrameRate();
int i = 0;
int att_id;
for (Hand hand : leap.getHands ()) {
if (i >= 2)
{
println("\n\n\n\t\t !! MORE THAN 2 hands isn't implemented");
continue;
}
// --------------------------------------------------
// Drawing
// hand.draw();
// update attractors position and draw
att_id = i * 5 + 0; // 5 => number of finger
PVector pos = hand.getIndexFinger().getPositionOfJointDip();
attractors[att_id].update_pos(pos);
i++;
}
particles_update_position();
draw_attractors();
draw_particles();
laser_frame.print_frame(); // print frame on stdout
}
// println("finger_pos:", pos); // println("finger_pos:", pos);
// // println("---"); // // println("---");

View File

@ -7,6 +7,7 @@ class Particle{
int circular_id; // the id in the circular buffer int circular_id; // the id in the circular buffer
PVector[] circular_pos; PVector[] circular_pos;
boolean draw_previous; boolean draw_previous;
float slow_distance;
// pour pouvoir faire les trainer il faudrait retenir les position precedente // pour pouvoir faire les trainer il faudrait retenir les position precedente
@ -29,6 +30,7 @@ class Particle{
speed = new PVector(0, 0, 0); speed = new PVector(0, 0, 0);
col = getColInt(255, 255, 255); col = getColInt(255, 255, 255);
slow_distance = 0.03;
} }
Particle(){ Particle(){
@ -55,7 +57,6 @@ class Particle{
speed.y += d.y * factor; speed.y += d.y * factor;
float cross = cross_product(getNormalized(speed), d); float cross = cross_product(getNormalized(speed), d);
float slow_distance = 0.2;
// limitation de l'eloignement // limitation de l'eloignement
if (cross < 0){ if (cross < 0){
speed.x *= 1.0 - (slow_distance * abs(cross)); speed.x *= 1.0 - (slow_distance * abs(cross));