Import the projection libraries and add TestProjectionPattern to illustrate usage
authorMark Slee <mcslee@Mark-Slees-MacBook-Pro.local>
Sun, 2 Jun 2013 03:55:53 +0000 (22:55 -0500)
committerMark Slee <mcslee@Mark-Slees-MacBook-Pro.local>
Sun, 2 Jun 2013 03:55:53 +0000 (22:55 -0500)
MarkSlee.pde
SugarCubes.pde
TestPatterns.pde
_Internals.pde
code/GLucose.jar

index b0bae2ff6454e45fc506815a65309fd8ef8835fd..97df3a0cff8d25f0064ca649ba284a695a5d5cd9 100644 (file)
@@ -583,3 +583,4 @@ class ShiftingPlane extends SCPattern {
     }
   }
 }
+
index 9b1f51e3306b7f8d03d108e1834c6a139d070a83..5504001bf88d3834f2d82b3b40f12340c35b00cf 100644 (file)
@@ -40,6 +40,8 @@ LXPattern[] patterns(GLucose glucose) {
 //    new TestXPattern(glucose),
 //    new TestYPattern(glucose),
 //    new TestZPattern(glucose),
+//    new TestProjectionPattern(glucose),
+
   };
 }
 
index 82aeea4e160daea4938dc249e307935a2120337a..516c3e4796cd0ac7fd03da5011155ce364cea358 100644 (file)
@@ -59,3 +59,36 @@ class TestZPattern extends SCPattern {
     }
   }
 }
+
+class TestProjectionPattern extends SCPattern {
+  
+  final Projection projection;
+  final SawLFO angle = new SawLFO(0, TWO_PI, 9000);
+  final SinLFO yPos = new SinLFO(-20, 40, 5000);
+  
+  TestProjectionPattern(GLucose glucose) {
+    super(glucose);
+    projection = new Projection(model);
+    addModulator(angle).trigger();
+    addModulator(yPos).trigger();
+  }
+  
+  public void run(int deltaMs) {
+    // Note: logically, you typically apply the transformations in reverse order
+    projection.reset(model)
+      .translate(-model.xMax/2., -model.yMax/2. + yPos.getValuef(), -model.zMax/2.)
+      .rotate(angle.getValuef(), 1, 0, 0)
+      .scale(1, 1.5, 1);
+
+    for (Coord c : projection) {
+      float d = sqrt(c.x*c.x + c.y*c.y + c.z*c.z); // distance from origin
+      // d = abs(d-60) + max(0, abs(c.z) - 20); // life saver / ring thing
+      d = max(0, abs(c.y) - 10 + .3*abs(c.z) + .08*abs(c.x)); // plane / spear thing
+      colors[c.index] = color(
+        (lx.getBaseHuef() + .6*abs(c.x) + abs(c.z)) % 360,
+        100,
+        constrain(140 - 10*d, 0, 100)
+      );
+    }
+  } 
+}
index a45805287f6eb8d042b62f02f3c1302c5c5b4ea4..7fe320911ea6709f5287e3a89f33ca7106edbfd0 100644 (file)
@@ -7,14 +7,15 @@
 import glucose.*;
 import glucose.control.*;
 import glucose.effect.*;
+import glucose.model.*;
 import glucose.pattern.*;
+import glucose.transform.*;
 import glucose.transition.*;
-import glucose.model.*;
 import heronarts.lx.*;
 import heronarts.lx.control.*;
 import heronarts.lx.effect.*;
-import heronarts.lx.pattern.*;
 import heronarts.lx.modulator.*;
+import heronarts.lx.pattern.*;
 import heronarts.lx.transition.*;
 import ddf.minim.*;
 import ddf.minim.analysis.*;
index 6b9970869157de0ebfe012bdf458387745751680..ecd95efeb9945f9c40f5b0ed98dcfbc5ad7ba43e 100644 (file)
Binary files a/code/GLucose.jar and b/code/GLucose.jar differ