redo with new anti-GLucose
authorBen Morrow <childoftv@gmail.com>
Mon, 3 Mar 2014 06:02:04 +0000 (22:02 -0800)
committerBen Morrow <childoftv@gmail.com>
Mon, 3 Mar 2014 06:02:04 +0000 (22:02 -0800)
18 files changed:
1  2 
AlexGreen.pde
AntonK.pde
Grizzly.pde
Internals.pde
JR.pde
JackieBavaro.pde
MIDI.pde
Mappings.pde
MarkSlee.pde
Model.pde
UIImplementation.pde
libraries/HeronLX.jar
libraries/JGraphT.jar
libraries/ScreenShot.dll
libraries/ScreenShot.jar
libraries/rwmidi.jar
libraries/toxiclibscore.jar
sketch.properties

diff --cc AlexGreen.pde
index 3e164d8bff34509891657cf09d585d69026c3f8a,54af5c04b14f40f24a35f963760afb4f793148f3..5a35b3e31bc24edb50b352d2d69d198569220436
@@@ -1,3 -1,3 +1,4 @@@
++
  class SineSphere extends APat {
    float modelrad = sqrt((model.xMax)*(model.xMax) + (model.yMax)*(model.yMax) + (model.zMax)*(model.zMax));
    private BasicParameter yrotspeed = new BasicParameter("yspeed", 3000, 1, 10000);
diff --cc AntonK.pde
Simple merge
diff --cc Grizzly.pde
index 0000000000000000000000000000000000000000,25d390f07fba7d653039521539f7dabd395a2ca4..5f46b967d6cfae3628f7f9f4645dd60af3d1fdb1
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,158 +1,158 @@@
 -
+ /**
+  *     DOUBLE BLACK DIAMOND        DOUBLE BLACK DIAMOND
+  *
+  *         //\\   //\\                 //\\   //\\  
+  *        ///\\\ ///\\\               ///\\\ ///\\\
+  *        \\\/// \\\///               \\\/// \\\///
+  *         \\//   \\//                 \\//   \\//H
+  *
+  *        EXPERTS ONLY!!              EXPERTS ONLY!!
+  *
+  * If you are an artist, you may ignore this file! It contains
+  * the code to drive grizzly board outputs.
+  */
++import java.net.*;
+ GrizzlyOutput[] buildGrizzlies() throws SocketException, UnknownHostException {
+   return new GrizzlyOutput[] {
+     new GrizzlyOutput(lx, "192.168.88.100", 6, 5, 6, 7, 7, 8, 1, 2, 4, 3, 11, 10, 9, 9, 12, 13),
+     new GrizzlyOutput(lx, "192.168.88.101", 25, 23, 24, 43, 45, 44, 1, 1, 1, 1, 1, 41, 42, 21, 20, 22),
+     new GrizzlyOutput(lx, "192.168.88.104", 26, 28, 27, 19, 18, 17, 1, 1, 18, 19, 15, 16, 14, 29, 30, 31),
+     new GrizzlyOutput(lx, "192.168.88.105", 1, 1, 1, 39, 38, 40, 34, 35, 33, 32, 37, 37, 1, 1, 1, 1),
+   };
+ }
+ /**
+  * Grizzly Output, sends packets to one grizzly board with a fixed IP and a number
+  * of channels.
+  */
+ class GrizzlyOutput extends LXDatagramOutput {
+   public final String ipAddress;
+   
+   private int frameNumber = 0;
+   
+   public GrizzlyOutput(LX lx, String ipAddress, int ... cubeIndices) throws UnknownHostException, SocketException {
+     super(lx);
+     this.ipAddress = ipAddress;
+     int channelNum = 0;
+     for (int rawCubeIndex : cubeIndices) {
+       if (rawCubeIndex > 0) {
+         Cube cube = model.getCubeByRawIndex(rawCubeIndex);
+         addDatagram(new GrizzlyDatagram(this, channelNum, cube).setAddress(ipAddress));
+       }
+       ++channelNum;
+     }
+     this.enabled.setValue(false);
+   }
+   
+   protected void beforeSend(int[] colors) {
+     ++frameNumber;
+   }
+   
+   public int getFrameNumber() {
+     return this.frameNumber;
+   }
+ }
+ /**
+  * Datagram to a Grizzlyboard. A simple fixed OSC packet.
+  */
+ static class GrizzlyDatagram extends LXDatagram {
+   
+   private static byte[] oscString(String s) {
+     int len = s.length();
+     int padding = (4 - ((len + 1) % 4)) % 4;
+     byte[] bytes = new byte[len + 1 + padding];
+     System.arraycopy(s.getBytes(), 0, bytes, 0, len);
+     for (int i = len; i < bytes.length; ++i) {
+       bytes[i] = 0;
+     }
+     return bytes;
+   }
+   
+   private static int oscIntCopy(int i, byte[] buffer, int pos) {
+     buffer[pos] = (byte) ((i >> 24) & 0xff);
+     buffer[pos + 1] = (byte) ((i >> 16) & 0xff);
+     buffer[pos + 2] = (byte) ((i >> 8) & 0xff);
+     buffer[pos + 3] = (byte) (i & 0xff);
+     return 4;
+   }
+   
+   private final static int[] STRIP_ORDERING = new int[] { 9, 8, 11, 5, 4, 7, 6, 10, 14, 2, 1, 0, 3, 13, 12, 15 };
+   
+   private static int[] cubePointIndices(Cube cube) {
+     int[] pointIndices = new int[Cube.POINTS_PER_CUBE - 2];
+     int pi = 0;
+     for (int stripIndex : STRIP_ORDERING) {
+       Strip strip = cube.strips.get(stripIndex);
+       int stripLen = ((stripIndex == 9) || (stripIndex == 15)) ? 15 : 16;
+       for (int i = stripLen-1; i >= 0; --i) {
+         pointIndices[pi++] = strip.points.get(i).index;
+       }
+     }
+     return pointIndices;
+   }
+   
+   private final static byte[] OSC_ADDRESS = oscString("/shady/pointbuffer");
+   private final static byte[] OSC_TYPETAG = oscString(",iiiiibi");  
+   private final static int HEADER_LENGTH = OSC_ADDRESS.length + OSC_TYPETAG.length + 24;
+   private final static int FOOTER_LENGTH = 4;
+   private final static int OSC_PORT = 779;
+   private GrizzlyOutput output;
+   
+   private int[] pointIndices;
+   private final int frameNumberPos;
+   
+   private final int dataPos;
+   
+   public GrizzlyDatagram(GrizzlyOutput output, int channelNum, Cube cube) {
+     this(output, channelNum, cubePointIndices(cube));
+   }
+   
+   public GrizzlyDatagram(GrizzlyOutput output, int channelNum, int[] pointIndices) {
+     super(HEADER_LENGTH + 4*pointIndices.length + FOOTER_LENGTH);
+     setPort(OSC_PORT);
+     
+     this.output = output;
+     this.pointIndices = pointIndices;
+     int dataLength = 4*pointIndices.length;
+     
+     int pos = 0;
+     // OSC address
+     System.arraycopy(OSC_ADDRESS, 0, this.buffer, pos, OSC_ADDRESS.length);
+     pos += OSC_ADDRESS.length;
+     // OSC typetag
+     System.arraycopy(OSC_TYPETAG, 0, this.buffer, pos, OSC_TYPETAG.length);
+     pos += OSC_TYPETAG.length;
+     this.frameNumberPos = pos;
+     pos += oscIntCopy(0, this.buffer, pos); // placeholder for frame number
+     pos += oscIntCopy(0xDEADBEEF, this.buffer, pos);
+     pos += oscIntCopy(channelNum, this.buffer, pos);
+     pos += oscIntCopy(0xFEEDBEEF, this.buffer, pos);
+     pos += oscIntCopy(dataLength, this.buffer, pos);
+     pos += oscIntCopy(dataLength, this.buffer, pos);
+     this.dataPos = pos;
+     
+     // end header
+     oscIntCopy(0xBEFFFFEB, this.buffer, this.buffer.length - 4);
+   }
+   
+   void onSend(int[] colors) {
+     oscIntCopy(this.output.getFrameNumber(), this.buffer, frameNumberPos);
+     int dataIndex = this.dataPos;
+     for (int index : this.pointIndices) {
+       color c = (index >= 0) ? colors[index] : 0;
+       this.buffer[dataIndex] = (byte) 0; // unused, alpha
+       this.buffer[dataIndex + 1] = (byte) ((c >> 16) & 0xff); // r
+       this.buffer[dataIndex + 2] = (byte) ((c >> 8) & 0xff); // g
+       this.buffer[dataIndex + 3] = (byte) (c & 0xff); // b
+       dataIndex += 4;
+     }
+   }
+ }
diff --cc Internals.pde
Simple merge
diff --cc JR.pde
Simple merge
Simple merge
diff --cc MIDI.pde
Simple merge
diff --cc Mappings.pde
Simple merge
diff --cc MarkSlee.pde
Simple merge
diff --cc Model.pde
index 0000000000000000000000000000000000000000,33762464c3c4ed4eaa50cfa225fea6befac50021..33762464c3c4ed4eaa50cfa225fea6befac50021
mode 000000,100644..100644
--- /dev/null
+++ b/Model.pde
index 0ea8073ddb57d6701a6a0a1b55df6fc88c89bbe8,ba0f110bc826a00aec85ce91e1b7ad52e9520c37..7750ab930c365a3322d635b6f82728483f0bca7c
   *
   * Custom UI components using the framework.
   */
-  
- class UIPatternDeck extends UIWindow {
-     
-   LXDeck deck;
-   
-   public UIPatternDeck(LXDeck deck, String label, float x, float y, float w, float h) {
-     super(label, x, y, w, h);
-     this.deck = deck;
-     int yp = titleHeight;
-         
-     List<ScrollItem> items = new ArrayList<ScrollItem>();
-     for (LXPattern p : deck.getPatterns()) {
-       items.add(new PatternScrollItem(p));
-     }    
-     final UIScrollList patternList = new UIScrollList(1, yp, w-2, 140).setItems(items);
-     patternList.addToContainer(this);
-     yp += patternList.h + 10;
-     
-     final UIParameterKnob[] parameterKnobs = new UIParameterKnob[12];
-     for (int ki = 0; ki < parameterKnobs.length; ++ki) {
-       parameterKnobs[ki] = new UIParameterKnob(5 + 34*(ki % 4), yp + (ki/4) * 48);
-       parameterKnobs[ki].addToContainer(this);
 -
++import java.util.Arrays;
+ 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;
      
-     LXDeck.Listener lxListener = new LXDeck.AbstractListener() {
-       public void patternWillChange(LXDeck deck, LXPattern pattern, LXPattern nextPattern) {
-         patternList.redraw();
-       }
-       public void patternDidChange(LXDeck deck, LXPattern pattern) {
-         patternList.redraw();
-         int pi = 0;
-         for (LXParameter parameter : pattern.getParameters()) {
-           if (pi >= parameterKnobs.length) {
-             break;
-           }
-           parameterKnobs[pi++].setParameter(parameter);
-         }
-         while (pi < parameterKnobs.length) {
-           parameterKnobs[pi++].setParameter(null);
-         }
-       }
-     };
-     
-     deck.addListener(lxListener);
-     lxListener.patternDidChange(deck, deck.getActivePattern());
-     
+     camera();
 -    javax.media.opengl.GL gl = ((PGraphicsOpenGL)g).beginGL();
 -    gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT);
 -    ((PGraphicsOpenGL)g).endGL();
++    PGraphicsOpenGL gl = (PGraphicsOpenGL) g;  
+     strokeWeight(1);
    }
    
-   class PatternScrollItem extends AbstractScrollItem {
-     
-     private LXPattern pattern;
-     private String label;
-     
-     PatternScrollItem(LXPattern pattern) {
-       this.pattern = pattern;
-       label = className(pattern, "Pattern");
-     }
-     
-     public String getLabel() {
-       return label;
-     }
-     
-     public boolean isSelected() {
-       return deck.getActivePattern() == pattern;
-     }
+   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();
      
-     public boolean isPending() {
-       return deck.getNextPattern() == pattern;
+     noStroke();
+     for (Cube c : model.cubes) {
+       drawCube(c);
      }
-     
-     public void onMousePressed() {
-       deck.goPattern(pattern);
+   
+     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();
    }
  }
  
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..7c388a7187aa6cce3490c50164ba4cf90dbee62f
new file mode 100755 (executable)
Binary files differ
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..1db92e60a5c2366f9eb3d5928e2405351398ae61
new file mode 100644 (file)
Binary files differ
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..68a6c99f340b669cda7ccd01a7923da70035c033
new file mode 100755 (executable)
Binary files differ
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..c75b8de040d302fe178a9978eebf6b3f230fe5b8
new file mode 100755 (executable)
Binary files differ
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..4788ff68beb23ae45330764ea00ed4c45f9d03aa
new file mode 100755 (executable)
Binary files differ
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..18fbbfe8671e1317e61ce41c8945e4eb78509f08
new file mode 100755 (executable)
Binary files differ
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..8630fa24ac7a4cc1429c0aca64fb8630782f0cf6
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,2 @@@
++mode.id=processing.mode.java.JavaMode
++mode=Java