//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)]; // counter for timing int timingCounter = 0; // image loading setup PImage a; int imageSize = 25; int[][] aPixels; int currentImage = 1; int maxImage = 20; String animation = "count"; int frameRate = 1; // setup *********************************************************************************** void setup() { size(800, 600, P3D); colorMode(HSB, 100); framerate(25); generateNodes(); // smooth(); // little buggy camera constructor from OCD library camera1 = new Camera(this, 10.0, -60.0, 0.0, 78.0, 0.0, 60.0, 0.0, 1.0, 0.0, radians(PI/7), (width/height), 1.0, 1000.0); camera1.zoom(radians(130) / 2.0); } // main method *********************************************************************************** void draw() { background(20,30,30); camera1.feed(); drawNodes(); iterateRotation(); keyboardListener(); cameraNavigation(); // timing timingCounter += 1; if (timingCounter>5){ timingCounter = 0; loadMyImage(); displayMyImage(); } } // generate data *********************************************************************************** void generateNodes() { float x = 0; float y = 0; float z = 0; int j=0; for (int i=0; i24) { j = 0; x = 0; z += 6; } float humanizer = (random(10)-5)/100; x += 6+humanizer; z += humanizer; 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 9){ zeros = "00"; } if (currentImage > 99){ zeros = "0"; } a = loadImage(animation+zeros+currentImage+".gif"); for(int i=0; i maxImage){ currentImage = 1; if (animation == "count"){ animation = "ripple"; } else if (animation == "ripple"){ animation = "rotation"; } else if (animation == "rotation"){ animation = "hand"; frameRate = 5; maxImage = 128; } else if (animation == "hand"){ animation = "count"; frameRate = 1; maxImage = 20; } } } 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); } }