Swarm setup - does not work
in
Contributed Library Questions
•
7 months ago
hi everyone
I am new to processing and the code was meant to 2d swarm setup, but does not appear anything.
here's my code. Many thanks for your time!!!
import toxi.math.conversion.*;
import toxi.geom.*;
import toxi.math.*;
import toxi.geom.mesh2d.*;
import toxi.util.datatypes.*;
import toxi.util.events.*;
import toxi.geom.mesh.subdiv.*;
import toxi.geom.mesh.*;
import toxi.math.waves.*;
import toxi.util.*;
import toxi.math.noise.*;
import plethora.core.*;
import processing.opengl.*;
import controlP5.*;
int pop = 600;
int DIMX = 600;
int DIMY=600;
int DIMZ=600;
ArrayList <Ple_Agent>boids;
float rotX, rotY;
PMatrix3D currCameraMatrix;
PGraphics3D g3;
//PeasyCam cam;
ControlP5 controlP5;
void setup(){
size(800,800,OPENGL);
g3 = (PGraphics3D)g;
// cam = new PeasyCam(this, 600);
initGUI();
boids = new ArrayList<Ple_Agent>();
for(int i=0; i<pop; i++){
Vec3D v = new Vec3D(0,0,0);
Ple_Agent pa = new Ple_Agent(this, v);
Vec3D initialVelocity = new Vec3D (random(-1, 1), random(-1, 1), 0 );
pa.setVelocity(initialVelocity);
pa.initTail(5);
boids.add(pa);
}
controlP5.setAutoDraw(false);
}
void draw() {
background(235);
pushMatrix();
translate(width/2, height/2);
rotateY(rotY);
rotateX(rotX);
rect(-DIMX/2, -DIMY/2, DIMX, DIMY);
//buildBox(DIMX, DIMY, DIMZ);
popMatrix();
//gui();
}
void gui() {
currCameraMatrix = new PMatrix3D(g3.camera);
camera();
controlP5.draw();
g3.camera = currCameraMatrix;
}
void initGUI() {
controlP5 = new ControlP5(this);
}
void mouseDragged() {
rotX = radians(mouseY);
rotY = radians(mouseX);
}
1