import processing.opengl.*; // library for easy manipulation of cameras import damkjer.ocd.*; // create camera from OCD library Camera camera1; // max nodes, 25*25 for example int nodeAmount = 625; // nodes array: x,y,z,force float[][] nodes = new float[int(nodeAmount)][4]; // rotationZ float[] rotationY = new float[int(nodeAmount)]; // rotationZ Target float[] rotationTargetY = new float[int(nodeAmount)]; // image loading setup PImage a; int imageSize = 25; int[][] aPixels; int currentImage = 0; int maxImage = 5; // setup *********************************************************************************** void setup() { size(800, 600, OPENGL); colorMode(HSB, 100); framerate(30); generateNodes(); // little buggy camera constructor from OCD library camera1 = new Camera(this, 10.0, -100.0, 0.0, 60.0, 0.0, 60.0, 0.0, 1.0, 0.0, radians(PI/7), (width/height), 1.0, 1000.0); } // main method *********************************************************************************** void draw() { background(20,30,30); camera1.feed(); drawNodes(); iterateRotation(); keyboardListener(); cameraNavigation(); } // generate data *********************************************************************************** void generateNodes() { float x = 0; float y = 0; float z = 0; for (int i=0; i144) && (x%2==0) ) { x = 3; z += sqrt(27)+(random(10)-5)/5; } else if (x>147){ x = 0; z += sqrt(27)+(random(10)-5)/5; } nodes[i][0] = x; nodes[i][1] = y; nodes[i][2] = z; // and force nodes[i][3] = 0; } } // Calculate forces ********************************************************************************************* void iterateRotation(){ for(int i=0; i maxImage){ currentImage = 0; } } void displayMyImage(){ float rr, gg, bb, tt; for(int i=0; i0){ nodes[(i*imageSize)+j+fix][3] = tt-50; } } } } // keyboardListener *************************************************************************************************************** void keyboardListener(){ if(keyPressed) { if(key == 'r' || key == 'R') { randomForces(); } if(key == 's' || key == 'S') { resetForces(); } if(key == 'p' || key == 'P') { patternForces(); } if(key == 'i' || key == 'I') { loadMyImage(); displayMyImage(); } } } // 3d navigation *************************************************************************************************************** void cameraNavigation() { if (!mousePressed){ // } else if (mouseButton == LEFT) { camera1.circle(radians(mouseX - pmouseX) / -2.0); camera1.arc(radians(mouseY - pmouseY) / -2.0); } else if (mouseButton == RIGHT) { camera1.zoom(radians(mouseY - pmouseY) / 2.0); } else if (mouseButton == CENTER) { camera1.look(radians(mouseX - pmouseX) / 6.0, radians(mouseY - pmouseY) / 2.0); } }