From: Micah Elizabeth Scott Date: Sat, 8 Mar 2014 03:47:42 +0000 (-0800) Subject: Merge branch 'processing-2' X-Git-Url: https://git.piment-noir.org/?p=SugarCubes.git;a=commitdiff_plain;h=f109415988e59cd5e255ce6baac40abc57f307d8;hp=d3016df6068e182a317be0451674411937fd7e95 Merge branch 'processing-2' --- diff --git a/AlexGreen.pde b/AlexGreen.pde index 54af5c0..5a35b3e 100644 --- a/AlexGreen.pde +++ b/AlexGreen.pde @@ -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 --git a/AntonK.pde b/AntonK.pde index 5010a4e..5b286f1 100644 --- a/AntonK.pde +++ b/AntonK.pde @@ -1,7 +1,8 @@ /************************************************************** * WORKING PATTERNS **************************************************************/ - +import java.util.List; +import java.util.LinkedList; class AKPong extends SCPattern { private final BasicParameter speed = new BasicParameter("Speed", 0); diff --git a/_Grizzly.pde b/Grizzly.pde similarity index 99% rename from _Grizzly.pde rename to Grizzly.pde index 51de8f3..5741778 100644 --- a/_Grizzly.pde +++ b/Grizzly.pde @@ -11,7 +11,7 @@ * 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", 0, 0, 0, 39, 38, 40, 0, 37, 35, 0, 21, 20, 22, 0, 33, 32 ), diff --git a/_Internals.pde b/Internals.pde similarity index 99% rename from _Internals.pde rename to Internals.pde index b593f3e..31f8ffc 100644 --- a/_Internals.pde +++ b/Internals.pde @@ -134,7 +134,6 @@ void setup() { size(VIEWPORT_WIDTH, VIEWPORT_HEIGHT, OPENGL); frameRate(targetFramerate); noSmooth(); - // hint(ENABLE_OPENGL_4X_SMOOTH); // no discernable improvement? logTime("Created viewport"); // Create the model @@ -224,6 +223,9 @@ void setup() { println("Total setup: " + (millis() - startMillis) + "ms"); println("Hit the 'o' key to toggle live output"); + + lx.engine.framesPerSecond.setValue(120); + lx.engine.setThreaded(true); } public SCPattern getPattern() { @@ -360,7 +362,7 @@ void drawDiagnostics(long drawNanos, long simulationNanos, long uiNanos, long ga noStroke(); int xp = x; float hv = 0; - for (long val : new long[] {lx.timer.drawNanos, simulationNanos, uiNanos, gammaNanos, lx.timer.outputNanos }) { + for (long val : new long[] {lx.timer.drawNanos, simulationNanos, uiNanos, gammaNanos, lx.engine.timer.outputNanos }) { fill(lx.hsb(hv % 360, 100, 80)); rect(xp, y, val * ws, h-1); hv += 140; diff --git a/JR.pde b/JR.pde index 4abcc62..07ddf38 100644 --- a/JR.pde +++ b/JR.pde @@ -1,3 +1,5 @@ +import java.util.Map; +import java.util.TreeMap; color BLACK = #000000; class Gimbal extends SCPattern { diff --git a/JackieBavaro.pde b/JackieBavaro.pde index 806fec0..fe18092 100644 --- a/JackieBavaro.pde +++ b/JackieBavaro.pde @@ -1,3 +1,4 @@ +import java.util.Iterator; class JackieSquares extends SCPattern { private BasicParameter rateParameter = new BasicParameter("RATE", 0.25); private BasicParameter attackParameter = new BasicParameter("ATTK", 0.3); diff --git a/_MIDI.pde b/MIDI.pde similarity index 98% rename from _MIDI.pde rename to MIDI.pde index 562aa86..a618321 100644 --- a/_MIDI.pde +++ b/MIDI.pde @@ -15,7 +15,7 @@ * set your SCPattern class to respond to the controllers that you * care about. */ - +import processing.event.*; interface MidiEngineListener { public void onFocusedDeck(int deckIndex); } @@ -264,7 +264,7 @@ public class VirtualKeyMidiInput extends SCMidiInput { } else { mapKeys(); } - registerKeyEvent(this); + registerMethod("keyEvent",this); } private void mapAPC() { @@ -321,19 +321,19 @@ public class VirtualKeyMidiInput extends SCMidiInput { if (!enabled) { return; } - char c = Character.toLowerCase(e.getKeyChar()); + char c = 0;//0Character.toLowerCase(e.getKeyChar()); NoteMeta nm = keyToNote.get(c); if (nm != null) { - switch (e.getID()) { - case KeyEvent.KEY_PRESSED: + switch (e.getKeyCode()) { + case KeyEvent.PRESS: noteOnReceived(new Note(Note.NOTE_ON, nm.channel, nm.number + octaveShift*12, 127)); break; - case KeyEvent.KEY_RELEASED: + case KeyEvent.RELEASE: noteOffReceived(new Note(Note.NOTE_OFF, nm.channel, nm.number + octaveShift*12, 0)); break; } } - if ((mode == KEYS) && (e.getID() == KeyEvent.KEY_PRESSED)) { + if ((mode == KEYS) && (e.getKeyCode() == KeyEvent.PRESS)) { switch (c) { case 'z': octaveShift = constrain(octaveShift-1, -4, 4); @@ -523,7 +523,7 @@ public class APC40MidiInput extends GenericDeviceMidiInput { return true; case 83: // scene 2 - effects.flash.trigger(); + //effects.flash.trigger(); return true; case 84: // scene 3 diff --git a/_Mappings.pde b/Mappings.pde similarity index 100% rename from _Mappings.pde rename to Mappings.pde diff --git a/MarkSlee.pde b/MarkSlee.pde index a2d36fd..fea4a43 100644 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@ -1,3 +1,4 @@ +import java.util.Stack; class Cathedrals extends SCPattern { private final BasicParameter xpos = new BasicParameter("XPOS", 0.5); @@ -222,7 +223,7 @@ class MidiMusic extends SCPattern { effects.boom.trigger(); break; case 40: - effects.flash.trigger(); + //effects.flash.trigger(); break; } } diff --git a/_Model.pde b/Model.pde similarity index 100% rename from _Model.pde rename to Model.pde diff --git a/_Presets.pde b/Presets.pde similarity index 100% rename from _Presets.pde rename to Presets.pde diff --git a/SugarCubes.pde b/SugarCubes.pde index 36e6317..9d72c5d 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -26,7 +26,7 @@ LXPattern[] patterns(LX lx) { return new LXPattern[] { - new SineSphere(lx), + //new SineSphere(lx), //new CubeCurl(lx), // Slee diff --git a/_UIImplementation.pde b/UIImplementation.pde similarity index 83% rename from _UIImplementation.pde rename to UIImplementation.pde index ba0f110..0f73b99 100644 --- a/_UIImplementation.pde +++ b/UIImplementation.pde @@ -11,8 +11,68 @@ * Custom UI components using the framework. */ +import java.nio.*; +import java.util.Arrays; class UICubesLayer extends UICameraComponent { + +int nvert = 200000; +int SIZEOF_INT = Integer.SIZE / 8; +int SIZEOF_FLOAT = Float.SIZE / 8; + +PGL pgl; +PShader sh; + +int vertLoc; +int colorLoc; + +IntBuffer vboName; +FloatBuffer vertData; + + boolean initted = false; + PShape sha1; + int numPoints = 10000; + + void initme() + { + nvert = model.points.size(); + sh = loadShader("frag.glsl", "vert.glsl"); + /*color[] simulationColors = lx.getColors(); + sha1= createShape(); + sha1.beginShape(POINTS); + for (LXPoint p : model.points) { + stroke(simulationColors[p.index]); + //pointColor(simulationColors[p.index]); + gl2.glPointColor=100; + sha1.vertex(p.x, p.y, p.z); + } + sha1.endShape();*/ + float[] temp = new float[nvert * 7]; + for (LXPoint p : model.points) { + // position + temp[p.index * 7 + 0] = p.x; + temp[p.index * 7 + 1] = p.y; + temp[p.index * 7 + 2] = p.z; + + // color + temp[p.index * 7 + 3] = 0.0; + temp[p.index * 7 + 4] = 0.0; + temp[p.index * 7 + 5] = 0.0; + temp[p.index * 7 + 6] = 1.0; + } + + vertData = allocateDirectFloatBuffer(nvert * 7); + vertData.rewind(); + vertData.put(temp); + vertData.position(0); + vboName = allocateDirectIntBuffer(1); + initVBO(); + } void onDraw(UI ui) { + if(!initted) + { + initted=true; + initme(); + } color[] simulationColors = lx.getColors(); String displayMode = uiCrossfader.getDisplayMode(); if (displayMode == "A") { @@ -23,21 +83,18 @@ class UICubesLayer extends UICameraComponent { long simulationStart = System.nanoTime(); if (simulationOn) { + hint(DISABLE_DEPTH_TEST); drawSimulation(simulationColors); + hint(ENABLE_DEPTH_TEST); } 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(); + camera(); 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); @@ -61,22 +118,72 @@ class UICubesLayer extends UICameraComponent { for (Cube c : model.cubes) { drawCube(c); } - + noFill(); - strokeWeight(2); - beginShape(POINTS); + //strokeWeight(2); + int count=0; + + ///magic: + + pgl = beginPGL(); + + + sh.bind(); + + vertLoc = pgl.getAttribLocation(sh.glProgram, "vertex"); + colorLoc = pgl.getAttribLocation(sh.glProgram, "color"); + + pgl.bindBuffer(PGL.ARRAY_BUFFER, vboName.get(0)); + pgl.enableVertexAttribArray(vertLoc); + pgl.enableVertexAttribArray(colorLoc); + + pgl.vertexAttribPointer(vertLoc, 3, PGL.FLOAT, false, 7 * SIZEOF_FLOAT, 0); + pgl.vertexAttribPointer(colorLoc, 4, PGL.FLOAT, false, 7 * SIZEOF_FLOAT, 3 * SIZEOF_FLOAT); + javax.media.opengl.GL2 gl2 = (javax.media.opengl.GL2) ((PJOGL)pgl).gl; + gl2.glPointSize(2f); + pgl.drawArrays(PGL.POINTS, 0, nvert); + + pgl.disableVertexAttribArray(vertLoc); + pgl.disableVertexAttribArray(colorLoc); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); + + sh.unbind(); + endPGL(); + createGeometry(simulationColors); + pgl.bindBuffer(PGL.ARRAY_BUFFER, vboName.get(0)); + pgl.bufferData(PGL.ARRAY_BUFFER, nvert * 7 * SIZEOF_FLOAT, vertData, PGL.STATIC_DRAW); + } + + void createGeometry(color[] simulationColors) { for (LXPoint p : model.points) { - stroke(simulationColors[p.index]); - vertex(p.x, p.y, p.z); - } - endShape(); + vertData.put(p.index * 7 + 3, ((simulationColors[p.index] >> 16) & 0xFF)/255.0); + vertData.put(p.index * 7 + 4, ((simulationColors[p.index] >> 8) & 0xFF)/255.0); + vertData.put(p.index * 7 + 5, (simulationColors[p.index]& 0xFF)/255.0); + } } +void initVBO() { + + pgl = beginPGL(); + pgl.genBuffers(1, vboName); + pgl.bindBuffer(PGL.ARRAY_BUFFER, vboName.get(0)); + pgl.bufferData(PGL.ARRAY_BUFFER, nvert * 7 * SIZEOF_FLOAT, vertData, PGL.DYNAMIC_DRAW); + pgl.bindBuffer(PGL.ARRAY_BUFFER, 0); + endPGL(); +} + +IntBuffer allocateDirectIntBuffer(int n) { + return ByteBuffer.allocateDirect(n * SIZEOF_INT).order(ByteOrder.nativeOrder()).asIntBuffer(); +} + +FloatBuffer allocateDirectFloatBuffer(int n) { + return ByteBuffer.allocateDirect(n * SIZEOF_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer(); +} 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); + // 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) { diff --git a/code/HeronLX.jar b/code/HeronLX.jar index 7c388a7..6b6d7c9 100755 Binary files a/code/HeronLX.jar and b/code/HeronLX.jar differ diff --git a/frag.glsl b/frag.glsl new file mode 100644 index 0000000..be233b9 --- /dev/null +++ b/frag.glsl @@ -0,0 +1,4 @@ +varying vec4 vertColor; +void main() { + gl_FragColor = vertColor; +} \ No newline at end of file diff --git a/libraries/HeronLX.jar b/libraries/HeronLX.jar new file mode 100755 index 0000000..7c388a7 Binary files /dev/null and b/libraries/HeronLX.jar differ diff --git a/libraries/JGraphT.jar b/libraries/JGraphT.jar new file mode 100644 index 0000000..1db92e6 Binary files /dev/null and b/libraries/JGraphT.jar differ diff --git a/libraries/ScreenShot.dll b/libraries/ScreenShot.dll new file mode 100755 index 0000000..68a6c99 Binary files /dev/null and b/libraries/ScreenShot.dll differ diff --git a/libraries/ScreenShot.jar b/libraries/ScreenShot.jar new file mode 100755 index 0000000..c75b8de Binary files /dev/null and b/libraries/ScreenShot.jar differ diff --git a/libraries/rwmidi.jar b/libraries/rwmidi.jar new file mode 100755 index 0000000..4788ff6 Binary files /dev/null and b/libraries/rwmidi.jar differ diff --git a/libraries/toxiclibscore.jar b/libraries/toxiclibscore.jar new file mode 100755 index 0000000..18fbbfe Binary files /dev/null and b/libraries/toxiclibscore.jar differ diff --git a/sketch.properties b/sketch.properties new file mode 100644 index 0000000..6550104 --- /dev/null +++ b/sketch.properties @@ -0,0 +1,2 @@ +mode.id=com.martinleopold.mode.debug.DebugMode +mode=Debug diff --git a/vert.glsl b/vert.glsl new file mode 100644 index 0000000..0b58f60 --- /dev/null +++ b/vert.glsl @@ -0,0 +1,11 @@ +uniform mat4 transform; +attribute vec4 vertex; +attribute vec4 color; +varying vec4 vertColor; +attribute float pointsize; +void main() { + gl_Position = transform * vertex; + vertColor = color; + gl_PointSize = 100.0; +} +