From 9dbd6499c8456e1f3809bb670cb7ca795cdcf644 Mon Sep 17 00:00:00 2001 From: lapin Date: Fri, 9 Oct 2020 19:00:10 +0200 Subject: [PATCH] all digit are atractor --- LaserOut.pde | 2 -- atractor.pde | 2 +- mini_leap.pde | 95 ++++++++++++++++++++++++++++++--------------------- particle.pde | 5 +-- 4 files changed, 60 insertions(+), 44 deletions(-) diff --git a/LaserOut.pde b/LaserOut.pde index 13e9902..7c8ca20 100644 --- a/LaserOut.pde +++ b/LaserOut.pde @@ -70,5 +70,3 @@ public class LaserOut processing_draw_line(line); // On pourait rajouter une condition si un paraetre est activer } } - - diff --git a/atractor.pde b/atractor.pde index 2a30081..dad3029 100644 --- a/atractor.pde +++ b/atractor.pde @@ -13,7 +13,7 @@ public class Attractor Attractor(){ pos = new PVector(0, 0, 0); is_active = false; - weight = 200; + weight = 20; circle_radius = 20; col = getColInt(0, 0, 50); diff --git a/mini_leap.pde b/mini_leap.pde index 6cb841e..ede5ccc 100644 --- a/mini_leap.pde +++ b/mini_leap.pde @@ -16,7 +16,7 @@ LeapMotion leap; LaserOut laser_frame; int hand_id; Attractor[] attractors = new Attractor[10]; -Particle[] particles = new Particle[10]; +Particle[] particles; PVector min_pos; PVector max_pos; @@ -26,24 +26,75 @@ boolean att_stdout; void setup() { size(800, 500); 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); + particles = new Particle[nb_particle]; - att_stdout = false; - boolean print_stdout = false; - laser_frame = new LaserOut(print_stdout); + laser_frame = new LaserOut(particle_stdout); // init_attractors for (int i = 0; i < attractors.length; i++){ attractors[i] = new Attractor(); } 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(){ for (Attractor att : attractors){ 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("---"); diff --git a/particle.pde b/particle.pde index ebf6d89..13d26e2 100644 --- a/particle.pde +++ b/particle.pde @@ -7,6 +7,7 @@ class Particle{ int circular_id; // the id in the circular buffer PVector[] circular_pos; boolean draw_previous; + float slow_distance; // pour pouvoir faire les trainer il faudrait retenir les position precedente @@ -28,7 +29,8 @@ class Particle{ pos = new PVector(random(50, 750), random(50, 70)); speed = new PVector(0, 0, 0); col = getColInt(255, 255, 255); - + + slow_distance = 0.03; } Particle(){ @@ -55,7 +57,6 @@ class Particle{ speed.y += d.y * factor; float cross = cross_product(getNormalized(speed), d); - float slow_distance = 0.2; // limitation de l'eloignement if (cross < 0){ speed.x *= 1.0 - (slow_distance * abs(cross));