Help needed with script !!
in
Contributed Library Questions
•
1 year ago
Hi,
I need a bit help with my processing script.
To be honest I have no idea how to change it the way I would like to have it, thats why I'm looking for help !
The idea is to attract the green circles by the red once once they come closer to each other (build cluster and change color) and the blue circles should be attracted by the single red circles.
On the picture you see what exactly I want to do.
--------------------------------------------------------------------------------------------------------------------------------------------------------------
-
import superCAD.*;import controlP5.*;import processing.opengl.*;import kMesh.*;import kGeom.*;import kAgent.*;import blobDetection.*;import kRender.*;
String cadSoftware, ext;boolean record = false;boolean bStop=false;
float gravity = 6;float mass = 4;int count = 0;
int relax = 30;int work = relax*16;//residentialint live = relax*8;//OFFICE
ControlP5 controlP5;
int sepParks = 200;float alignParks = 0.001;float cohesionParks = 0.0001;
int sepRes = 20;float alignRes = 0.01;float cohesionRes = 0.01;
int sepOff = 40;float alignOff = 0.2;float cohesionOff = 0.1;
Slider parks;Slider res;Slider off;Slider aliParks;Slider cohParks;Slider aliRes;Slider cohRes;Slider aliOff;Slider cohOff;
kWorld world1;
void setup(){fill(255);smooth();frameRate(30);size(1400,750, OPENGL);background(0);
controlP5 = new ControlP5(this);
parks = controlP5.addSlider("sepParks",1,200,sepParks,10,20,100,10);aliParks = controlP5.addSlider("alignParks",0.001,2,alignParks,10,40,100,10);cohParks = controlP5.addSlider("cohesionParks",0.001,0.2,cohesionParks,10,60,100,10);
res = controlP5.addSlider("sepRes",1,100,sepRes,180,20,100,10);aliRes = controlP5.addSlider("alignRes",0.01,10,alignRes,180,40,100,10);cohRes = controlP5.addSlider("cohesionRes",0.01,10,cohesionRes,180,60,100,10);
off = controlP5.addSlider("sepOff",40,150,sepOff,360,20,100,10);aliOff = controlP5.addSlider("alignOff",0.001,10,alignOff,360,40,100,10);cohOff = controlP5.addSlider("cohesionOff",0.01,10,cohesionOff,360,60,100,10);
world1 = new kWorld();
for (int i = 0; i < relax; i++){kVec orig = new kVec(random(width),random(height));world1.addkAgentB(new kAgentB(orig, new kVec(random(-1,1),random(-1,1)), 3, 60,"R", mass, gravity, count, -1,random (0.04,0.2),color(255,0,0)));}
for (int i = 0; i < work; i++){
kVec orig2 = new kVec(random(width),random(height));world1.addAgent(new kAgent(orig2, new kVec(random(-1,1),random(-1,1)), 5, 0.01,"R", mass, gravity, count, -1, 1000000,color(0,255,0)));}
for (int i = 0; i < live; i++){kVec orig = new kVec (width/2,height/2);kVec orig2 = new kVec(random(width),random(height));world1.addkAgentC(new kAgentC(orig2, new kVec(random(-1,1),random(-1,1)), 3, 0.1,"R", mass, gravity, count, -1, 10,color(0,255,255)));}}
void draw(){background(0);stroke(255);
if(record)beginRaw("superCAD."+cadSoftware, "output."+ext);
world1.run();
if (record){endRaw();record = false;}
if (frameCount < 1200){//saveFrame("Iconicity_####.jpg");}
}
void keyPressed(){
if (key == 'm' || key == 'M'){cadSoftware = "Maya";ext = "mel";record = true;}// switch(key)// {// case 'm':// cadSoftware = "Maya";// ext = "mel";// break;// }// record = true;if (key == 'p' || key == 'P'){bStop=!bStop;if (bStop){noLoop();}else{loop();}}}
-------------------------------------------------------------------------------------------------------
If you know how to help me, please contact me to get the whole code.
THANKS !!!
1