From: Mark Slee Date: Sun, 2 Jun 2013 03:55:53 +0000 (-0500) Subject: Import the projection libraries and add TestProjectionPattern to illustrate usage X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f3f5a87685d1a5be6a9f838efdeb946fdc7688d2;p=SugarCubes.git Import the projection libraries and add TestProjectionPattern to illustrate usage --- diff --git a/MarkSlee.pde b/MarkSlee.pde index b0bae2f..97df3a0 100644 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@ -583,3 +583,4 @@ class ShiftingPlane extends SCPattern { } } } + diff --git a/SugarCubes.pde b/SugarCubes.pde index 9b1f51e..5504001 100644 --- a/SugarCubes.pde +++ b/SugarCubes.pde @@ -40,6 +40,8 @@ LXPattern[] patterns(GLucose glucose) { // new TestXPattern(glucose), // new TestYPattern(glucose), // new TestZPattern(glucose), +// new TestProjectionPattern(glucose), + }; } diff --git a/TestPatterns.pde b/TestPatterns.pde index 82aeea4..516c3e4 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -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) + ); + } + } +} diff --git a/_Internals.pde b/_Internals.pde index a458052..7fe3209 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -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.*; diff --git a/code/GLucose.jar b/code/GLucose.jar index 6b99708..ecd95ef 100644 Binary files a/code/GLucose.jar and b/code/GLucose.jar differ