We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, I'm trying to create some visuals based on a Wind Map. I got the visuals to work with the parameters setting the thickness and turbulence of the particles but I would like to be able to control those parameters through sliders on an interface so I have more control of it.
I added the sliders to control these parameters but It's not changing the visuals live for some reason. I think it might be because of the positioning of the elements in my code, so I will past it here a section of my code and hopefully someone with experience can point me where i'm getting this wrong?
int sParticles = 5000;
int sNoiseScale = 5000;
int sLength = 5;
float sRandomA = .5;
float sRandomB = 2;
int num = sParticles;
Particle[] particles = new Particle[num];
float noiseScale=sNoiseScale, noiseStrength=5; // Turbulence
void setup() {
cp5 = new ControlP5(this);
cp5.addSlider("sParticles").setPosition(0,0).setRange(0,10000);
cp5.addSlider("sNoiseScale").setPosition(160,0).setRange(0,10000);
cp5.addSlider("sLength").setPosition(330,0).setRange(0,20);
cp5.addSlider("sRandomA").setPosition(490,0).setRange(0,5);
cp5.addSlider("sRandomB").setPosition(650,0).setRange(0,5);
size(1920, 1080);
noStroke();
for (int i=0; i<num; i++) {
PVector loc = new PVector(random(width*1.2),
random(height), random(sRandomA, sRandomB)); // Thickness
float angle = random(TWO_PI);
PVector dir = new PVector(cos(angle), sin(angle));
float speed = random(.5, 2);
particles[i]= new Particle(loc, dir, speed);
}
}
Answers
Edit post, highlight code, press ctrl-o
Where is your draw method??? Please post a full, runnable example.
Sure! here it is.