Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
/*************************************************************** * Erik Kastner - OpenGL Boxes going up up up in processing ***************************************************************/ import processing.opengl.*; import javax.media.opengl.*; PGraphicsOpenGL pgl; GL gl; ArrayList boxes; void setup() { background(0); size(500,500,OPENGL); boxes = new ArrayList(); colorMode(HSB); frameRate(10); boxes.add(new MyBox(0, 0, 0, color(244), 10, 10, 10)); //noLoop(); //noStroke(); smooth(); lights(); } void draw() { background(0); pgl = (PGraphicsOpenGL) g; gl = pgl.gl; pgl.beginGL(); gl.glEnable(GL.GL_DEPTH_TEST); gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE); //gl.glShadeModel(GL.GL_SMOOTH); pgl.endGL(); MyBox box = (MyBox)boxes.get(boxes.size()-1); camera(box.x+110, noise(frameCount * 0.005)*100-50, noise(frameCount * 0.001)*100-50, box.x, 0, 0, 1, 0, 0); float y = noise(frameCount * 0.02) * 100 - 50; float z = noise(frameCount * 0.06) * 100 - 50; boxes.add(box.addX(random(10,50), random(20,40), random(20,40), color(frameCount%255, 255, 24), y, z)); for (int i=1; i<boxes.size(); i++) { MyBox theBox = (MyBox)boxes.get(i); theBox.display(); } //saveFrame("save/frame-####.png"); } class MyBox { float x; float y; float z; color c; float w; float h; float d; MyBox(float _x, float _y, float _z, color _c, float _w, float _h, float _d) { x = _x; y = _y; z = _z; c = _c; h = _h; w = _w; d = _d; } void display() { pushMatrix(); translate(x,y,z); fill(c); box(w,h,d); popMatrix(); } MyBox addX(float _w, float _h, float depth, color _c, float _y, float _z) { return new MyBox(x+w, _y, _z, _c, _w, _h, depth); } }
From the Design Piracy series on my blog: