Hello,
Having mucho problem with my "next step" in learning about classes and particle systems.
Here is my code so far (Giving me an error).
My hope was to take this thingy http://openprocessing.org/visuals/?visualID=5032 (haven't used openProcessing in a while), and make it broader in order to learn more about particle systems and classes. i.e. extend from multiple points across screen and be drawn towards mouse/wrap it up.
But yeah, I think I've either seriously misunderstood a key concept or b) approached the solution using the wrong tools. Please help!
Tendril_try3
Code:
import traer.physics.*;
tenSys tens;
Tendril[] ten;
void setup(){
size(640,480);
background(#6CA5D6);
smooth();
colorMode(HSB);
ten = new Tendril[20];
for(int i = 0; i < ten.length; i++){
ten[i].setTendril(i*30, 0, 0);
}
}
void draw(){
physics.tick( 1.0 );
tens.updateMouse();
stroke(#000000);
for(int i = 0; i < ten.length; i++) {
line( ten[i].ten1.position().x(), ten[i].ten1.position().y(),
ten[i].ten2.position().x(), ten[i].ten2.position().y());
}
}
void mouseClicked(){
saveFrame("p" + month() + day() + hour() + minute() + second() + ".png");
}
TenSys
Code:Super Class tenSys{
ParticleSystem physics;
Particle mouse;
tenSys(){
physics = new ParticleSystem( 0, 0.1);
mouse = physics.makeParticle();
mouse.makeFixed();
}
void updateMouse(){
mouse.position().set( mouseX, mouseY, 0);
}
}
Tendril
Code:class Tendril extends tenSys{
Particle ten1;
Particle ten2;
Spring spring;
Tendril(){
ten1 = physics.makeParticle(1.0, 0, 0, 0);
ten2 = physics.makeParticle(1.0, 0, 0, 0);
mouse.makeFixed();
physics.makeSpring( ten1, ten2, 0.01, 0.02, 100.0 );
physics.makeAttraction( ten1, ten2, -10000, 2.0 );
physics.makeAttraction( ten1, mouse, 1000, 50 );
physics.makeAttraction( ten2, mouse, 1000, 50 );
}
void drawTendril(){
stroke(#000000);
line( ten1.position().x(), ten1.position().y(), ten2.position().x(), ten2.position().y());
}
void setTendril(float x, float y, float z){
ten1.position().set( x, y, z );
ten2.position().set( x, y, z );
}
}