/* * volumatrix * Fredrik Bridell 2007-01-22 * * This is a Processing sketch done for an installation that may or not * be produced. It loads images (regular jpegs) and maps them onto a * low-resolution three-dimensional pixel grid. There are two versions, * one where the grid is a sort of curved shape (the depth is proportional * to the distance to the middle). The other vesion is just a cube where * each pixel gets a random depth. You can turn the shape using the mouse * or press 0 (zero) to see it rotate automatically. * * Note: this is a SKETCH. My apologies for the particularly ugly code. * * use mouse to rotate the shape or push some key controls: * RETURN or ENTER to toggle image * x/X to decrease/INCREASE number of rows * y/Y ti decrease/INCREASE number of columns * z/Z to decrease/INCREASE the z scaling * d/D to decrease/INCREASE the distance (spacing) between pixels * SPACE to print out your current variable settings (in Processing) * p to toggle parabolic mode * b to toggle balls or ellipses (balls are A LOT slower) * 1 - preset, flat image * 2 - preset, at an angle * 0 - toggle automatic rotation */ // angles of rotation float ax=0; float ay=0; float az=0; boolean autorotate=true; boolean explodedMode=false; // if false, show parabolic mode, if true, exploded boolean drawBalls = false; int oldMouseX; int oldMouseY; PImage img; // source image int numCols = 24; // number of cells (x) int numRows = 24; // number of rows (y) int spacing = 5; // spacing between grid rows and columns float spacingZ = 3.0; // larger values give taller chandelier float cellx, celly; // size of each cell... int imageNumber; String[] imageList = { "puppy.jpg", "innocentx.jpg", "joconde.jpg", "frankenstein.jpg" }; float[][] depth; // stores cell depths for exploded mode, not parabolic void setup(){ background(0); size(800, 600, P3D); noStroke(); imageNumber=int(random(imageList.length)); toggleImage(); oldMouseX=mouseX; oldMouseY=mouseY; } // calculates new values // call this method after you change the x/y resolution of the grid // or the pixel dimensions of the source image void changeResolution(){ cellx = img.width / float(numCols); celly = img.height / float(numRows); // calculate random depths for exploded mode depth = new float[numCols][numRows]; for(int x=0; x