src | ||
.gitignore | ||
Cargo.toml | ||
README.md |
A particles generator in rust for laser shows
Philosophy
This library should allow users to define their own particle behaviours
- how many particles at start? min/max at any time? how many to add at any time?
- how do particles behave? Are there different types? Different shapes?
- how do particles react with real world? To audio? To a controller?
Constraints
- Manages lists of points in the form {x,y,color} with color encoded as 12 bits (r,g,b)
- i.e. it doesn't speak to the laser directly, we use a middleware for that part (see. xxx)
- it can output to STDOUT or send to redis
- Obviously be as fast as possible
- Use a physics engine as a tool for collision detection, velocity and more
- Q: how do we enable custom behaviours (ex: reacting to audio)
- Q: how do we map physics engine object (ex: ball, square) for users as concept
- Q: how do we convert the physics engine objets to 2D points
- Q: how do we handle 3D? On by default?
- Be easy to use: good defaults for everything
- Handle bounding and drawing boxes
- Handle user custom particle properties (ex: decay, frequency, personality, etc.)
- Handle additional drawings for the current frame due to custom events (ex: segment between two particles)
New project
- Clone lj_rust_template and edit draw.rs
- add lj_particle library crate
- edit the draw function
- draw
Library struct/objects
Particle
- CentralPoint
- Shape : Square, Triangle, Circle, 3DSphere : Trait
- UserData // custom ex: life decay, seed, created_at, frequency
- Group
- PhysicsBody
Point2D
- coordinates(x,y)
- velocity(x,y)
- color(r,g,b)
BoundingBox2D <Xmin,Xmax,Ymin,Ymax> PhysicsEngine PhysicsEngineConfig ParticlesList
Config
- ParticlesGroups: vec<
- RedisConf
- PhysicsEngine
OSCConfig
- OSCCache
- OSCServer <IP,Port>
use LJParticleSystem as ParticleSystem;
use LJBoundingBox as BoundingBox;
use LJClippingBox as ClippingBox;
use LJRedilysis as Redilysis;
use Rapier as PhysicsEngine;
// Configure
let boundingbox = BoundingBox();
let clipping_box = ClippingBox();
let particle_system = ParticleSystem( ParticleSystemConfig, PhysicsEngine, ClippingBox, BoundingBox );
let redilysis = Redilysis ( RedilysisConfig( file_path ) );
// by default, equiprobability to generate a particle from any group
particle_system.new_particle( lambda() => { ... })
// some way to init the particles
world.init();
particle_system.tick = lambda(){
// Configuration update if read via OSC
current_config = self->getConfig();
// Retrieve bandwidth/bpm/rms info (with caching)
analysis = redilysis.update();
// Manage
self.boundingBox();
self.physicsEngine();
for( particle in self.getParticles() ) {
}
n_particles = current_config.particles_amount;
return self.clippingBox();
}
pub fn draw() -> Result<Vec<Point>, Box<dyn std::error::Error>> {
let mut v: Vec<Point> = vec![];
v.push( particle_system.tick() );
Ok(v)
}
OSC CONFIG
S Server = (LJ) OSC Server and client eventual config channel 1 : IP channel X : IP
R Rust = (LJ Particle) OSC Server and Client
U User Interface = (Tablet) HTML Interface
c Program Channel = configurable, uint ex: 1 n Programe name = configurable, string ex: particle_foo_square
Sequence Diagram
# Prerequisite : S is running and available and U is connected to S
# R starts
# R: Do you have my config already ?
R -> S "/program/$c/$n/configure"
# C needs to stock which program is currently used for $n channel and its parameters
# If no, C manifests the need to init the configuration
C -> R "/program/$c/$n/no-config"
# If no-config, R sends its default config for C to store
R -> C "/program/$c/$n/var1 default_value1" # etc.
# In any case, C sends to R the current config
C -> R "/program/$c/$n/var1 value1" # etc.
# C creates an event for the User to change
C -> U "/program/$c/$n"
# U can change the program configuration
U -> C "/program/$c/$n"
Features
- save to redis
- Use a 2D physics engine
- Use attractors/repulsors objects
- Use a 3D physics engine
- Use OSC to update configuration