From: Jack Stahl Date: Sun, 24 Nov 2013 01:36:14 +0000 (-0800) Subject: Merge pull request #15 from jackstah/master X-Git-Url: https://git.piment-noir.org/?p=SugarCubes.git;a=commitdiff_plain;h=6ca96b882b2824deb26f3e1d5719f52f8913a173;hp=71515698b89967ed5c723b70cff39a96dedff20f Merge pull request #15 from jackstah/master Fix Swim and balance --- diff --git a/JackieBavaro.pde b/JackieBavaro.pde new file mode 100644 index 0000000..fc1576a --- /dev/null +++ b/JackieBavaro.pde @@ -0,0 +1,265 @@ +class JackieSquares extends SCPattern { + private BasicParameter rateParameter = new BasicParameter("RATE", 0.25); + private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); + private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2); + private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7); + + SinLFO hueMod = new SinLFO(0, 360, 4000); + SinLFO spreadMod = new SinLFO(1, 10, 8000); + + + class FaceFlash { + Face f; + float value; + float hue; + boolean hasPeaked; + + FaceFlash(int n) { + f = model.faces.get(n % model.faces.size()); + hue = random(360); + boolean infiniteAttack = (attackParameter.getValuef() > 0.999); + hasPeaked = infiniteAttack; + value = (infiniteAttack ? 1 : 0); + } + + // returns TRUE if this should die + boolean age(double ms) { + if (!hasPeaked) { + value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); + if (value >= 1.0) { + value = 1.0; + hasPeaked = true; + } + return false; + } else { + value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); + return value <= 0; + } + } + } + + private float leftoverMs = 0; + private List flashes; + private int faceNum = 0; + + public JackieSquares(GLucose glucose) { + super(glucose); + addParameter(rateParameter); + addParameter(attackParameter); + addParameter(decayParameter); + addParameter(saturationParameter); + addModulator(hueMod).trigger(); + addModulator(spreadMod).trigger(); + + flashes = new LinkedList(); + } + + public void run(double deltaMs) { + leftoverMs += deltaMs; + float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100); + while (leftoverMs > msPerFlash) { + leftoverMs -= msPerFlash; + faceNum += int(spreadMod.getValuef()); + flashes.add(new FaceFlash(faceNum)); + } + + for (LXPoint p : model.points) { + colors[p.index] = 0; + } + + for (FaceFlash flash : flashes) { + float hue = (hueMod.getValuef() + flash.hue) % 360.0; + color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100); + for (LXPoint p : flash.f.points) { + colors[p.index] = c; + } + } + + Iterator i = flashes.iterator(); + while (i.hasNext()) { + FaceFlash flash = i.next(); + boolean dead = flash.age(deltaMs); + if (dead) { + i.remove(); + } + } + } +} + + +class JackieLines extends SCPattern { + private BasicParameter rateParameter = new BasicParameter("RATE", 0.25); + private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); + private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2); + private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7); + + SinLFO hueMod = new SinLFO(0, 360, 4000); + SinLFO spreadMod = new SinLFO(1, 10, 8000); + + + class StripFlash { + Strip f; + float value; + float hue; + boolean hasPeaked; + + StripFlash(int n) { + f = model.strips.get(n % model.strips.size()); + hue = random(360); + boolean infiniteAttack = (attackParameter.getValuef() > 0.999); + hasPeaked = infiniteAttack; + value = (infiniteAttack ? 1 : 0); + } + + // returns TRUE if this should die + boolean age(double ms) { + if (!hasPeaked) { + value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); + if (value >= 1.0) { + value = 1.0; + hasPeaked = true; + } + return false; + } else { + value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); + return value <= 0; + } + } + } + + private float leftoverMs = 0; + private List flashes; + private int stripNum = 0; + + public JackieLines(GLucose glucose) { + super(glucose); + addParameter(rateParameter); + addParameter(attackParameter); + addParameter(decayParameter); + addParameter(saturationParameter); + addModulator(hueMod).trigger(); + addModulator(spreadMod).trigger(); + + flashes = new LinkedList(); + } + + public void run(double deltaMs) { + leftoverMs += deltaMs; + float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 100); + while (leftoverMs > msPerFlash) { + leftoverMs -= msPerFlash; + stripNum += int(spreadMod.getValuef()); + flashes.add(new StripFlash(stripNum)); + } + + for (LXPoint p : model.points) { + colors[p.index] = 0; + } + + for (StripFlash flash : flashes) { + float hue = (hueMod.getValuef() + flash.hue) % 360.0; + color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100); + for (LXPoint p : flash.f.points) { + colors[p.index] = c; + } + } + + Iterator i = flashes.iterator(); + while (i.hasNext()) { + StripFlash flash = i.next(); + boolean dead = flash.age(deltaMs); + if (dead) { + i.remove(); + } + } + } +} + + + +class JackieDots extends SCPattern { + private BasicParameter rateParameter = new BasicParameter("RATE", 0.15); + private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); + private BasicParameter decayParameter = new BasicParameter("DECAY", 0.2); + private BasicParameter saturationParameter = new BasicParameter("SAT", 0.7); + + SinLFO hueMod = new SinLFO(0, 360, 4000); + SinLFO spreadMod = new SinLFO(1, 10, 16000); + + + class PointFlash { + LXPoint f; + float value; + float hue; + boolean hasPeaked; + + PointFlash(int n) { + f = model.points.get(n % model.points.size()); + hue = random(360); + boolean infiniteAttack = (attackParameter.getValuef() > 0.999); + hasPeaked = infiniteAttack; + value = (infiniteAttack ? 1 : 0); + } + + // returns TRUE if this should die + boolean age(double ms) { + if (!hasPeaked) { + value = value + (float) (ms / 1000.0f * ((attackParameter.getValuef() + 0.01) * 5)); + if (value >= 1.0) { + value = 1.0; + hasPeaked = true; + } + return false; + } else { + value = value - (float) (ms / 1000.0f * ((decayParameter.getValuef() + 0.01) * 10)); + return value <= 0; + } + } + } + + private float leftoverMs = 0; + private List flashes; + private int pointNum = 0; + + public JackieDots(GLucose glucose) { + super(glucose); + addParameter(rateParameter); + addParameter(attackParameter); + addParameter(decayParameter); + addParameter(saturationParameter); + addModulator(hueMod).trigger(); + addModulator(spreadMod).trigger(); + + flashes = new LinkedList(); + } + + public void run(double deltaMs) { + leftoverMs += deltaMs; + float msPerFlash = 1000 / ((rateParameter.getValuef() + .01) * 5000); + while (leftoverMs > msPerFlash) { + leftoverMs -= msPerFlash; + pointNum += int(spreadMod.getValuef()); + flashes.add(new PointFlash(pointNum)); + } + + for (LXPoint p : model.points) { + colors[p.index] = 0; + } + + for (PointFlash flash : flashes) { + float hue = (hueMod.getValuef() + flash.hue) % 360.0; + color c = lx.hsb(hue, saturationParameter.getValuef() * 100, (flash.value) * 100); + colors[flash.f.index] = c; + } + + Iterator i = flashes.iterator(); + while (i.hasNext()) { + PointFlash flash = i.next(); + boolean dead = flash.age(deltaMs); + if (dead) { + i.remove(); + } + } + } +} + diff --git a/SugarCubes.pde b/SugarCubes.pde index 40f9a76..88f229a 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -65,7 +65,15 @@ LXPattern[] patterns(GLucose glucose) { // new TimTrace(glucose), new TimSpheres(glucose), + // Jackie + new JackieSquares(glucose), + new JackieLines(glucose), + new JackieDots(glucose), + + + // Vincent + new VSTowers(glucose), // Toby new GlitchPlasma(glucose), diff --git a/VincentSiao.pde b/VincentSiao.pde new file mode 100644 index 0000000..48a368e --- /dev/null +++ b/VincentSiao.pde @@ -0,0 +1,119 @@ +class VSTowers extends SCPattern { + private BasicParameter saturationParameter = new BasicParameter("SAT", 80, 0, 100); + private BasicParameter attackParameter = new BasicParameter("ATTK", 0.96, 0.1, 1.0); + private BasicParameter decayParameter = new BasicParameter("DECAY", 0.7, 0.1, 1.0); + private SawLFO hueLfo = new SawLFO(0, 360, 20000); + + private Map towerOn; + + class TowerFlash { + Tower t; + float value; + float maxVal; + float hue; + boolean hasPeaked; + + TowerFlash() { + do { + t = model.towers.get(floor(random(model.towers.size()))); + } while (towerOn.get(t)); + towerOn.put(t, true); + hue = (hueLfo.getValuef() + 50*(random(2)-1.0f)) % 360; + value = 0.0; + maxVal = random(0.4) + 0.6; + } + + boolean run(double deltaMs) { + if (!hasPeaked) { + float atk = attackParameter.getValuef(); + float atkDuration = 10000 * (1/sqrt(atk) - 1.0f); + value = value + (float)deltaMs / atkDuration; + if (value >= maxVal) { + value = maxVal; + hasPeaked = true; + } + return false; + } else { + float dec = decayParameter.getValuef(); + float decDuration = 10000 * (1/sqrt(dec) - 1.0f); + value = value - (float)deltaMs / decDuration; + return value <= 0; + } + } + } + + public VSTowers(GLucose glucose) { + super(glucose); + addParameter(saturationParameter); + addParameter(attackParameter); + addParameter(decayParameter); + addModulator(hueLfo).trigger(); + flashes = new LinkedList(); + towerOn = new HashMap(); + for (Tower t : model.towers) { + towerOn.put(t, false); + } + } + + private List flashes; + private float accDelta = 0; + + public void run(double deltaMs) { + accDelta += deltaMs; + float rate = lx.tempo.rampf(); + float msPerFlash = 5000 * (1/sqrt(rate) - 1.0f); + if (accDelta >= msPerFlash) { + accDelta -= msPerFlash; + if (flashes.size() < model.towers.size()) { + flashes.add(new TowerFlash()); + } + } + for (LXPoint p : model.points) { + if (random(1) < 0.2) { + colors[p.index] = 0; + } + } + for (TowerFlash tf : flashes) { + for (LXPoint p : tf.t.points) { + float towerHeight = model.yMin + tf.value * (model.yMax - model.yMin); + if (p.y <= towerHeight) { + colors[p.index] = lx.hsb( + (tf.hue + tf.value*50 - p.y/2) % 360, + saturationParameter.getValuef(), + tf.value*100); + } + } + if (tf.hasPeaked) { + float towerMaxHeight = model.yMin + tf.maxVal * (model.yMax - model.yMin); + Cube top = tf.t.cubes.get(tf.t.cubes.size()-1); + for (int i = tf.t.cubes.size()-1; i >= 0; --i) { + Cube c = tf.t.cubes.get(i); + float maxY = c.points.get(0).y; + for (LXPoint p : c.points) { + maxY = max(maxY, p.y); + } + if (towerMaxHeight < maxY) { + top = c; + } + } + for (LXPoint p : top.points) { + if (tf.value > 0.5) { + colors[p.index] = lx.hsb(0, 0, tf.value*100); + } else if (random(1) < 0.2) { + colors[p.index] = 0; + } + } + } + } + // Run flashes and remove completed ones + Iterator it = flashes.iterator(); + while (it.hasNext()) { + TowerFlash flash = it.next(); + if (flash.run(deltaMs)) { + towerOn.put(flash.t, false); + it.remove(); + } + } + } +} + diff --git a/_Internals.pde b/_Internals.pde index 61c453e..425ea0e 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -36,9 +36,6 @@ final float TRAILER_WIDTH = 240; final float TRAILER_DEPTH = 97; final float TRAILER_HEIGHT = 33; -final int MaxCubeHeight = 7; -final int NumBackTowers = 18; - int targetFramerate = 60; int startMillis, lastMillis; diff --git a/_Mappings.pde b/_Mappings.pde index 435ca90..171ff13 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -13,6 +13,9 @@ * when physical changes or tuning is being done to the structure. */ +final int MaxCubeHeight = 6; +final int NumBackTowers = 16; + public Model buildModel() { // Shorthand helpers for specifying wiring more quickly @@ -24,8 +27,6 @@ public Model buildModel() { // Utility value if you need the height of a cube shorthand final float CH = Cube.EDGE_HEIGHT; final float CW = Cube.EDGE_WIDTH ; - - // Positions for the bass box final float BBY = BassBox.EDGE_HEIGHT + BoothFloor.PLEXI_WIDTH; @@ -79,14 +80,14 @@ public Model buildModel() { for (int i=0; i(); for (int i=0; i < st.n; i++) { Cube.Wiring w = (i < st.wiring.length) ? st.wiring[i] : WRR; @@ -239,48 +244,63 @@ public PandaMapping[] buildPandaList() { return new PandaMapping[] { new PandaMapping( "10.200.1.28", new ChannelMapping[] { - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 16, 17, 18}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 4, 5, 6}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 7, 8, 9}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 10, 11, 12}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 13, 14, 15}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37, 38, 39 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 43, 44, 45 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 46, 47, 48 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), // new front thing + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), // new back thing + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 13, 14, 15 }), // new back thing }), new PandaMapping( "10.200.1.29", new ChannelMapping[] { - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 34, 35, 36}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19, 20, 21}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 22, 23, 24}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 25, 26, 27}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28, 29, 30}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 31, 32, 33}), - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19, 20, 21 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 4, 5, 6 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 7, 8, 9 }), + + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 10, 11, 12 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 16, 17, 18 }), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 34, 35, 36}), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 19, 20, 21}), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 22, 23, 24}), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 25, 26, 27}), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28, 29, 30}), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 31, 32, 33}), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), }), new PandaMapping( "10.200.1.30", new ChannelMapping[] { - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}), // 30 J3 * - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}), // 30 J4 //ORIG * - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37, 38, 39}), // 30 J7 * - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 40, 41, 42}), // 30 J8 * - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 43, 44, 45}), // 30 J13 (not working) - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 46, 47, 48}), // 30 J14 (unplugged) - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 49, 50, 51}), // 30 J15 (unplugged) - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 52, 53, 54}), // 30 J16 + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 40, 41, 42 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 22, 23, 24 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 25, 26, 27 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 28, 29, 30 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 31, 32, 33 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 34, 35, 36 }), +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}), // 30 J3 * +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1,1}), // 30 J4 //ORIG * +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 37, 38, 39}), // 30 J7 * +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 40, 41, 42}), // 30 J8 * +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 43, 44, 45}), // 30 J13 (not working) +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 46, 47, 48}), // 30 J14 (unplugged) +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 49, 50, 51}), // 30 J15 (unplugged) +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 52, 53, 54}), // 30 J16 }), - new PandaMapping( - "10.200.1.31", new ChannelMapping[] { - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 65, 66}), // J3 - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}), // J4 - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 55, 56}), // 30 J7 - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 57, 58}), // J8 - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 59, 60}), // J13 - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 61, 62}), // 30 J14 - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 63, 64}), // J15 - new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}), // J16 - }), +// new PandaMapping( +// "10.200.1.31", new ChannelMapping[] { +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 65, 66}), // J3 +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}), // J4 +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 55, 56}), // 30 J7 +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 57, 58}), // J8 +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 59, 60}), // J13 +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 61, 62}), // 30 J14 +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 63, 64}), // J15 +// new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1,1}), // J16 +// }), + // new PandaMapping( // "10.200.1.32", new ChannelMapping[] { // new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { }), // J3 diff --git a/_PandaDriver.pde b/_PandaDriver.pde index 24afa20..5d8ad24 100644 --- a/_PandaDriver.pde +++ b/_PandaDriver.pde @@ -84,10 +84,17 @@ public static class PandaDriver { * corner of the cube the data wire comes in. */ private final static int[][] CUBE_STRIP_ORDERINGS = new int[][] { +// { 2, 1, 0, 3, 13, 12, 15, 14, 4, 7, 6, 5, 11, 10, 9, 8 }, // FRONT_LEFT +// { 6, 5, 4, 7, 1, 0, 3, 2, 8, 11, 10, 9, 15, 14, 13, 12 }, // FRONT_RIGHT +// { 14, 13, 12, 15, 9, 8, 11, 10, 0, 3, 2, 1, 7, 6, 5, 4 }, // REAR_LEFT +// { 10, 9, 8, 11, 5, 4, 7, 6, 12, 15, 14, 13, 3, 2, 1, 0 }, // REAR_RIGHT + + { 2, 1, 0, 3, 13, 12, 15, 14, 4, 7, 6, 5, 11, 10, 9, 8 }, // FRONT_LEFT { 6, 5, 4, 7, 1, 0, 3, 2, 8, 11, 10, 9, 15, 14, 13, 12 }, // FRONT_RIGHT { 14, 13, 12, 15, 9, 8, 11, 10, 0, 3, 2, 1, 7, 6, 5, 4 }, // REAR_LEFT - { 10, 9, 8, 11, 5, 4, 7, 6, 12, 15, 14, 13, 3, 2, 1, 0 }, // REAR_RIGHT + { 9, 8, 11, 5, 4, 7, 6, 10, 14, 2, 1, 0, 3, 13, 12, 15 }, // REAR_RIGHT + }; private final static int[][] BASS_STRIP_ORDERING = {