From d9e53bb67c95b3b1c3bda6c55073eebf5cd55b3a Mon Sep 17 00:00:00 2001 From: alban Date: Sat, 27 Jan 2024 21:21:10 +0100 Subject: [PATCH] init: specs --- .gitignore | 1 + Cargo.toml | 8 +++ README.md | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 3 + 4 files changed, 184 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 README.md create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c79c7ff --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "pp-particles" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/README.md b/README.md new file mode 100644 index 0000000..7b10fa0 --- /dev/null +++ b/README.md @@ -0,0 +1,172 @@ +# 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 + +1. Clone lj_rust_template and edit draw.rs +2. add lj_particle library crate +3. edit the draw function +4. 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 +PhysicsEngine +PhysicsEngineConfig +ParticlesList + +Config +- ParticlesGroups: vec< +- RedisConf +- PhysicsEngine + +OSCConfig +- OSCCache +- OSCServer + + +```rust + +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, Box> { + let mut v: Vec = 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 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}