From 36e19b7b5b923666a56fd4a941fb0f1ada725093 Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Wed, 26 Feb 2014 00:49:00 -0800 Subject: [PATCH] Few tiny cleanups --- _Internals.pde | 101 ------------------------------------------ _Mappings.pde | 6 --- _UIImplementation.pde | 101 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 107 deletions(-) diff --git a/_Internals.pde b/_Internals.pde index 0362a7c..b593f3e 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -347,107 +347,6 @@ void draw() { } } -class UICubesLayer extends UICameraComponent { - void onDraw(UI ui) { - color[] simulationColors = lx.getColors(); - String displayMode = uiCrossfader.getDisplayMode(); - if (displayMode == "A") { - simulationColors = lx.engine.getDeck(LEFT_DECK).getColors(); - } else if (displayMode == "B") { - simulationColors = lx.engine.getDeck(RIGHT_DECK).getColors(); - } - - long simulationStart = System.nanoTime(); - if (simulationOn) { - drawSimulation(simulationColors); - } - simulationNanos = System.nanoTime() - simulationStart; - - camera(); - javax.media.opengl.GL gl = ((PGraphicsOpenGL)g).beginGL(); - gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT); - ((PGraphicsOpenGL)g).endGL(); - strokeWeight(1); - } - - void drawSimulation(color[] simulationColors) { - translate(0, 30, 0); - - noStroke(); - fill(#141414); - drawBox(0, -TRAILER_HEIGHT, 0, 0, 0, 0, TRAILER_WIDTH, TRAILER_HEIGHT, TRAILER_DEPTH, TRAILER_HEIGHT/2.); - fill(#070707); - stroke(#222222); - beginShape(); - vertex(0, 0, 0); - vertex(TRAILER_WIDTH, 0, 0); - vertex(TRAILER_WIDTH, 0, TRAILER_DEPTH); - vertex(0, 0, TRAILER_DEPTH); - endShape(); - - // Draw the logo on the front of platform - pushMatrix(); - translate(0, 0, -1); - float s = .07; - scale(s, -s, s); - image(logo, TRAILER_WIDTH/2/s-logo.width/2, TRAILER_HEIGHT/2/s-logo.height/2-2/s); - popMatrix(); - - noStroke(); - for (Cube c : model.cubes) { - drawCube(c); - } - - noFill(); - strokeWeight(2); - beginShape(POINTS); - for (LXPoint p : model.points) { - stroke(simulationColors[p.index]); - vertex(p.x, p.y, p.z); - } - endShape(); - } - - void drawCube(Cube c) { - float in = .15; - noStroke(); - fill(#393939); - drawBox(c.x+in, c.y+in, c.z+in, c.rx, c.ry, c.rz, Cube.EDGE_WIDTH-in*2, Cube.EDGE_HEIGHT-in*2, Cube.EDGE_WIDTH-in*2, Cube.CHANNEL_WIDTH-in); - } - - void drawBox(float x, float y, float z, float rx, float ry, float rz, float xd, float yd, float zd, float sw) { - pushMatrix(); - translate(x, y, z); - rotate(rx / 180. * PI, -1, 0, 0); - rotate(ry / 180. * PI, 0, -1, 0); - rotate(rz / 180. * PI, 0, 0, -1); - for (int i = 0; i < 4; ++i) { - float wid = (i % 2 == 0) ? xd : zd; - - beginShape(); - vertex(0, 0); - vertex(wid, 0); - vertex(wid, yd); - vertex(wid - sw, yd); - vertex(wid - sw, sw); - vertex(0, sw); - endShape(); - beginShape(); - vertex(0, sw); - vertex(0, yd); - vertex(wid - sw, yd); - vertex(wid - sw, yd - sw); - vertex(sw, yd - sw); - vertex(sw, sw); - endShape(); - - translate(wid, 0, 0); - rotate(HALF_PI, 0, -1, 0); - } - popMatrix(); - } -} - void drawDiagnostics(long drawNanos, long simulationNanos, long uiNanos, long gammaNanos) { float ws = 4 / 1000000.; int thirtyfps = 1000000000 / 30; diff --git a/_Mappings.pde b/_Mappings.pde index b7b6a86..8798fb5 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -24,7 +24,6 @@ static final float FLOOR = 0; * The second value is the offset moving NW (negative comes forward-right). */ static final float[][] TOWER_CONFIG = new float[][] { - // x, z, y, # new float[] { 0, 0, RISER, 4 }, new float[] { 25, -10, RISER, 4 }, new float[] { 50, -22.5, FLOOR, 5 }, @@ -39,11 +38,6 @@ static final float[][] TOWER_CONFIG = new float[][] { public Model buildModel() { - // TODO: (Mark Slee, Alex Green, or Ben Morrow): The Cube # is determined by the order in this list. - // "raw object index" is serialized by running through towermapping and then individual cube mapping below. - // We can do better than this. The raw object index should be obvious from the code-- looking through the - // rendered simulation and counting through cubes in mapping mode is grossly inefficient. - List towers = new ArrayList(); Cube[] cubes = new Cube[200]; int cubeIndex = 1; diff --git a/_UIImplementation.pde b/_UIImplementation.pde index 1e78bee..ba0f110 100644 --- a/_UIImplementation.pde +++ b/_UIImplementation.pde @@ -11,6 +11,107 @@ * Custom UI components using the framework. */ +class UICubesLayer extends UICameraComponent { + void onDraw(UI ui) { + color[] simulationColors = lx.getColors(); + String displayMode = uiCrossfader.getDisplayMode(); + if (displayMode == "A") { + simulationColors = lx.engine.getDeck(LEFT_DECK).getColors(); + } else if (displayMode == "B") { + simulationColors = lx.engine.getDeck(RIGHT_DECK).getColors(); + } + + long simulationStart = System.nanoTime(); + if (simulationOn) { + drawSimulation(simulationColors); + } + simulationNanos = System.nanoTime() - simulationStart; + + camera(); + javax.media.opengl.GL gl = ((PGraphicsOpenGL)g).beginGL(); + gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT); + ((PGraphicsOpenGL)g).endGL(); + strokeWeight(1); + } + + void drawSimulation(color[] simulationColors) { + translate(0, 30, 0); + + noStroke(); + fill(#141414); + drawBox(0, -TRAILER_HEIGHT, 0, 0, 0, 0, TRAILER_WIDTH, TRAILER_HEIGHT, TRAILER_DEPTH, TRAILER_HEIGHT/2.); + fill(#070707); + stroke(#222222); + beginShape(); + vertex(0, 0, 0); + vertex(TRAILER_WIDTH, 0, 0); + vertex(TRAILER_WIDTH, 0, TRAILER_DEPTH); + vertex(0, 0, TRAILER_DEPTH); + endShape(); + + // Draw the logo on the front of platform + pushMatrix(); + translate(0, 0, -1); + float s = .07; + scale(s, -s, s); + image(logo, TRAILER_WIDTH/2/s-logo.width/2, TRAILER_HEIGHT/2/s-logo.height/2-2/s); + popMatrix(); + + noStroke(); + for (Cube c : model.cubes) { + drawCube(c); + } + + noFill(); + strokeWeight(2); + beginShape(POINTS); + for (LXPoint p : model.points) { + stroke(simulationColors[p.index]); + vertex(p.x, p.y, p.z); + } + endShape(); + } + + void drawCube(Cube c) { + float in = .15; + noStroke(); + fill(#393939); + drawBox(c.x+in, c.y+in, c.z+in, c.rx, c.ry, c.rz, Cube.EDGE_WIDTH-in*2, Cube.EDGE_HEIGHT-in*2, Cube.EDGE_WIDTH-in*2, Cube.CHANNEL_WIDTH-in); + } + + void drawBox(float x, float y, float z, float rx, float ry, float rz, float xd, float yd, float zd, float sw) { + pushMatrix(); + translate(x, y, z); + rotate(rx / 180. * PI, -1, 0, 0); + rotate(ry / 180. * PI, 0, -1, 0); + rotate(rz / 180. * PI, 0, 0, -1); + for (int i = 0; i < 4; ++i) { + float wid = (i % 2 == 0) ? xd : zd; + + beginShape(); + vertex(0, 0); + vertex(wid, 0); + vertex(wid, yd); + vertex(wid - sw, yd); + vertex(wid - sw, sw); + vertex(0, sw); + endShape(); + beginShape(); + vertex(0, sw); + vertex(0, yd); + vertex(wid - sw, yd); + vertex(wid - sw, yd - sw); + vertex(sw, yd - sw); + vertex(sw, sw); + endShape(); + + translate(wid, 0, 0); + rotate(HALF_PI, 0, -1, 0); + } + popMatrix(); + } +} + class UIBlendMode extends UIWindow { public UIBlendMode(float x, float y, float w, float h) { super(lx.ui, "BLEND MODE", x, y, w, h); -- 2.34.1