Commit 57954e91 authored by Philip A Levis's avatar Philip A Levis
Browse files

Merge branch 'dev/engine-moses' into 'master'

Fix wing builder? Add pattern, logo, statement and more doc

See merge request !29
parents dd6a295c 00ffa5ea
......@@ -77,6 +77,7 @@
| 74 | | Omar Palacios Orbe Sr | Omar Palacios: Wisdom, Courage, Power | royal_crest |
| 75 | | Viraga Perera | Viraga Perera: MS EE '20 | Perera_Icon |
| 76 | | Erik Kevin Van | Erik Van: Community Building Engineer | erik_icon |
| ?? | | Moses Swai | Moses Swai: BS'18\MS'20 ME, "Irie! Hakuna Matata" | moses_logo |
......
{
"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
package engine;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import model.FlightModel;
......@@ -58,56 +56,88 @@ 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 *****/
/**
* Returns the FlightModel used to create the LXModel
*
* @return The FlightModel
*/
public FlightModel getModel() {
return model;
}
/**
* Returns an array with all the flyer configurations
* This array can be used to save the current flyer states
* to a .json file using the IO class
*
* @return A FlyerConfig array
*/
public FlyerConfig[] getFlyerConfigs() {
return model.getFlyerConfigs();
}
/**
* Returns the number of patterns in each channel.
* This assumes that every channel has the same patterns
*
* @return The number of patterns
*/
public int numPatterns() {
return this.patterns.size();
}
/**
* Returns the number of channels in the LXMixerEngine
* NOTE: This does not count the master channel
*
* @return The number of channels
*/
public int numChannels() {
return this.lx.engine.mixer.channels.size();
}
/**
* Returns the LXMixerEngine object in the LXEngine
*
* @return A list of LXAbstractChannel
*/
public LXMixerEngine getMixerEngine() {
return lx.engine.mixer;
}
/**
* Returns the loaded channels in the LX engine.
* NOTE: This does not include the master channel
*
* @return A list of LXAbstractChannel
*/
List<LXAbstractChannel> getChannels() {
return lx.engine.mixer.channels;
}
/**
* Returns the IO class object for saving and loading
* flyer configurations and playlist
*
* @return The IO class object
*/
public IO getIO(){
return io;
}
......@@ -225,15 +255,18 @@ public abstract class FlightEngine implements FlightPlaylist {
}
}
/* Adds patterns to the pattern list passed as parameter.
* This pattern is useful because each channel has its own
* list of patterns, since each instance of a pattern might
* have different settings.
*/
// PRIVATE FUNCTIONS
/* Adds patterns to the pattern list passed as parameter.
* This pattern is useful because each channel has its own
* list of patterns, since each instance of a pattern might
* have different settings.
*/
private void addPatterns(ArrayList<LXPattern> patterns) {
patterns.add(new ColorWheel(lx));
patterns.add(new ColorWave(lx));
patterns.add(new ColorSweep(lx));
patterns.add(new ColorWall(lx));
patterns.add(new ColorWave(lx));
patterns.add(new ColorWheel(lx));
patterns.add(new RaspberryTrip(lx));
}
......@@ -263,7 +296,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));
......
......@@ -176,9 +176,68 @@ 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, 100);
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();
}
}
/**
* Simular to ColorWave except it propogates a singular color. There are
* Similar to ColorWave except it propogates a single color. There are
* four controls: the speed of the wave, the polar direction of the wave (0
* degrees is bottom to top), the color and the length of the wave. The
* wing saturation is set to 100 and the brightness is dictated by the a
......@@ -227,3 +286,4 @@ class ColorWall extends FlightPattern {
}
}
}
......@@ -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