Commit 98030847 authored by Moses Swai's avatar Moses Swai
Browse files

Add ColorSweep pattern; Fix bug in WingModel??

parent 23c8ea2b
{
"id": 62,
"class": "heronarts.lx.clip.LXChannelClip",
"modulationColor": -6881536,
"internal": {},
"parameters": {
"label": "Clip-1",
"running": false,
"trigger": false,
"length": 3535.0,
"loop": false
},
"children": {},
"index": 0,
"parameterLanes": [
{
"laneType": "pattern",
"events": [
{
"cursor": 0.0,
"patternIndex": 0
}
]
},
{
"laneType": "midiNote",
"events": []
},
{
"laneType": "parameter",
"events": [
{
"cursor": 545.0,
"normalized": 0.8988888888888888
},
{
"cursor": 721.0,
"normalized": 0.8987878787878788
},
{
"cursor": 891.0,
"normalized": 0.8986868686868686
},
{
"cursor": 1066.0,
"normalized": 0.8985858585858586
},
{
"cursor": 1241.0,
"normalized": 0.8984848484848484
},
{
"cursor": 1416.0,
"normalized": 0.8983838383838384
},
{
"cursor": 1590.0,
"normalized": 0.8982828282828282
},
{
"cursor": 1758.0,
"normalized": 0.8981818181818182
},
{
"cursor": 1938.0,
"normalized": 0.898080808080808
},
{
"cursor": 2122.0,
"normalized": 0.897979797979798
}
],
"componentId": 56,
"parameterPath": "SPEE"
}
]
}
\ No newline at end of file
......@@ -58,28 +58,18 @@ public abstract class FlightEngine implements FlightPlaylist {
// on the state of the FlightModel.
private Generator generator;
// List of clips of behavior of each channel (one per channel)
// TODO: do we need this? -pal
private List<LXClip> clips;
public FlightEngine(String projectPath, FlightModel model, LXStudio lx) {
this.projectPath = projectPath;
this.io = new IO(projectPath);
this.model = model;
this.lx = lx;
this.patterns = new ArrayList<LXPattern>();
this.clips = new ArrayList<LXClip>();
this.channels = new ArrayList<LXChannel>();
/* All engine configuration */
configureGeneratorOutput();
configureChannels();
/* For testing */
// recordPlaylist();
// loadPlaylist("data/playlist.json");
// playbackPlaylist();
}
/***** PUBLIC FUNCTIONS *****/
......@@ -233,6 +223,7 @@ public abstract class FlightEngine implements FlightPlaylist {
patterns.add(new ColorWheel(lx));
patterns.add(new ColorWave(lx));
patterns.add(new RaspberryTrip(lx));
patterns.add(new ColorSweep(lx));
}
/* Create an array with a new instance of each available Pattern. */
......@@ -261,7 +252,7 @@ public abstract class FlightEngine implements FlightPlaylist {
} else {
channel.fader.setValue(0);
}
clips.add(channel.addClip());
channel.addClip();
}
mixer.setFocusedChannel(mixer.getChannel(0));
mixer.selectChannel(mixer.getChannel(0));
......
......@@ -175,3 +175,64 @@ class ColorWave extends FlightPattern {
}
}
}
/**
* Makes a color sweep across FLIGHT, starting from front facing apex of the
* building going all the way to the back. There are three controls: the speed
* of the sweep, the range of fliers alight up by the sweep and the hue of the
* sweep. The sweep is tries to resemble a wave done by fans in sports stadiums.
* The wing are set to open up as the sweep goes outwards and close as it contracts
* back to the apex.
* @author Moses Swai
*/
class ColorSweep extends FlightPattern {
float max_x = Geometry.FRONT_WINDOW_WIDTH;
float max_z = Geometry.Z_ROOM;
float max_distance = (float)Math.sqrt((max_x * max_x) + (max_z * max_z));
final BoundedParameter period = new BoundedParameter("PERIOD", 10000, 1000, 50000);
final BoundedParameter range = new BoundedParameter("RANGE", 5, 0, 10);
final BoundedParameter hue = new BoundedParameter("HUE", 100, 0, 360);
final TriangleLFO position = new TriangleLFO(0, max_distance, period);
float prev_position = position.getValuef();
ColorSweep(LX lx) {
super(lx);
addParameter("ColorSweep_PERIOD", period);
addParameter("ColorSweep_RANGE", range);
addParameter("ColorSweep_HUE", hue);
addModulator(position).start();
}
@Override
public void run(double deltaMs) {
for (FlyerModel flyer: model.getFlyers()) {
float x = flyer.getX();
float z = flyer.getZ();
float distance = (float)Math.sqrt((x * x) + (z * z));
if (position.getValuef() < distance+range.getValuef() && position.getValuef() > distance-range.getValuef() ) {
for (LightSamplePointModel point : model.getFlyerLights(flyer.getIndex())) {
setColor(point, LX.hsb(hue.getValuef(), 100, 100));
}
int skew;
if (prev_position < position.getValuef()) {
skew = -60;
} else {
skew = 60;
}
setSkew(flyer.getLeftWing(), skew);
setSkew(flyer.getRightWing(), skew);
} else {
for (LightSamplePointModel point : model.getFlyerLights(flyer.getIndex())) {
setColor(point, LX.hsb(0, 0, 0));
}
}
}
prev_position = position.getValuef();
}
}
......@@ -26,13 +26,14 @@ public class WingModel extends LXModel implements Wing {
this.lightPoints = wingModelBuilder.lightPoints;
this.flyerIndex = wingModelBuilder.flyerIndex;
this.isRight = wingModelBuilder.isRight;
this.index = getIndex();
this.index = wingModelBuilder.index;
this.skew = 90;
}
private static class WingModelBuilder extends LXModelBuilder {
private final int flyerIndex;
private final int index;
private final boolean isRight;
private final LightSamplePointModel[] lightPoints = new LightSamplePointModel[NUM_LIGHT_POINTS_PER_WING];
......@@ -44,6 +45,7 @@ public class WingModel extends LXModel implements Wing {
this.lightPoints[0] = new LightSamplePointModel(LightSamplePoint.LightCorners.HEAD, wingIndex, flyerIndex);
this.lightPoints[1] = new LightSamplePointModel(LightSamplePoint.LightCorners.SIDE, wingIndex, flyerIndex);
this.lightPoints[2] = new LightSamplePointModel(LightSamplePoint.LightCorners.TAIL, wingIndex, flyerIndex);
this.index = wingIndex;
// REVIEW(mcslee): you can set it later and update the model, but you might want to specify X/Y/Z position for these now
// which will depend upon composition of the overall flyer position with the wing position as well
// Add points to the model
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment