// from 2010 demo by Reza. // It plots random data on 3D import processing.opengl.*; //import peasy.org.apache.commons.math.*; import peasy.*; //import peasy.org.apache.commons.math.geometry.*; PeasyCam cam; ArrayList transactions = null; //create a container for transactions from the data int squareSize = 5; //sets the size of the squares being drawn int counter = 0; //counter to keep track of the transactions being used. float value = 0; int gridInterval = 50; int PLOTX1, PLOTX2; int PLOTY1, PLOTY2; int PLOTZ1, PLOTZ2; int DATAMIN, DATAMAX; int DATAMINZ, DATAMAXZ; int XMIN, XMAX; int XINTERVAL; int YINTERVAL; int ZINTERVAL; PFont font; void setup() { ///Set up Canvas size(1000,700,OPENGL); //setup a 500 by 500 Pixel Space to work with 280 transactions...for you want to show more make sure you have enough transactions in your splxmldata.txt file. hint(DISABLE_OPENGL_2X_SMOOTH); hint(ENABLE_OPENGL_4X_SMOOTH); smooth(); frameRate(1000); //set the frameRate of the Visualization font = loadFont("Helvetica-18.vlw"); PLOTX1 = -750; PLOTX2 = 750; PLOTY1 = -500; PLOTY2 = 500; PLOTZ1 = -250; PLOTZ2 = 250; DATAMIN = 0; DATAMAX = 500; DATAMINZ = 0; DATAMAXZ = 250; XMIN = 0; XMAX = PLOTX2; XINTERVAL = 50; YINTERVAL = 50; ZINTERVAL = 50; cam = new PeasyCam(this,(PLOTX1+PLOTX2)*.5,(PLOTY1+PLOTY2)*.5,(PLOTZ1+PLOTZ2)*.5, 1000); cam.setMinimumDistance(1); cam.setMaximumDistance(5000); } void draw() //draw loop that runs over and over until user quits { background(31,126,255); //sets the background color; axis(); drawGrid(); drawPlot(); drawTitle(); drawAxisLabels(); drawXLabels(); drawYLabels(); drawZLabels(); drawData(); counter = 0; //sets the counter to zero to start over again } void axis() { strokeWeight(2); stroke(255,255,255); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX2,PLOTY1,PLOTZ1); stroke(255,255,255); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX1,PLOTY2,PLOTZ1); stroke(255,255,255); line(PLOTX1,PLOTY1,PLOTZ1,PLOTX1,PLOTY1,PLOTZ2); } void drawData() { stroke(255,50); strokeWeight(2); fill(255,50); for(int x = PLOTX1; x <= PLOTX2; x+=XINTERVAL) { beginShape(TRIANGLE_STRIP); for(int y = PLOTY1; y <= PLOTY2; y+=YINTERVAL) { for(int z = PLOTZ1; z < PLOTZ2; z+=ZINTERVAL) { vertex(x,y,PLOTZ1*noise(y*x)); vertex(x+XINTERVAL,y,PLOTZ1*noise(y*x)); } } endShape(); } }