Commit 7fa1c7a6 authored by Philip Levis's avatar Philip Levis
Browse files

Merge branch 'dev/pal' of code.stanford.edu:plevis/ee185 into dev/pal

parents c0a99386 b27e4cf9
......@@ -3,10 +3,17 @@ class UIFlightDrawer extends UI3dComponent implements GeometryConstants {
final float[] VBAR_OFFSETS;
final float[] HBAR_OFFSETS;
final float[] BACK_WALL_OFFSETS;
FlightModel model;
<<<<<<< HEAD:software/FlightGui/Drawing.pde
UIFlightDrawer() {
=======
UIFlightDisplay(FlightModel model) {
>>>>>>> b27e4cf91ccedb8556428b0d6ff1aa22be3844c7:software/FlightGui/UIDrawer.pde
super();
this.model = model;
VBAR_OFFSETS = new float[GeometryConstants.FRONT_WINDOW_VBAR_SPACINGS.length];
float xPos = 0.0;
for (int i = 0; i < GeometryConstants.FRONT_WINDOW_VBAR_SPACINGS.length; i++) {
......@@ -48,9 +55,6 @@ class UIFlightDrawer extends UI3dComponent implements GeometryConstants {
// drawing it, then popping the tranformation. This allows the
// draw code to just operate in a normalized coordinate space. -pal
for (Flyer flyer : model.getFlyers()) {
int c = flyer.getBodyLightPoint().getColor();
pg.fill(c);
pg.pushMatrix();
float x = flyer.getX();
float y = flyer.getY();
......@@ -78,8 +82,8 @@ class UIFlightDrawer extends UI3dComponent implements GeometryConstants {
pg.endShape(CLOSE);
// Left wing
LightSamplePoint[] leftLights = flyer.getLeftWing().getLightPoints();
pg.fill(leftLights[0].getColor()); // Just use point 0 for the wing for now
List<LightSamplePoint> leftLights = model.getFlyerLeftWingLights(flyer.getIndex());
pg.fill(leftLights.get(0).getColor()); // Just use point 0 for the wing for now
pg.beginShape();
pg.vertex(4.01, 0, 4.96);
pg.vertex(9.12, 0, 11.17);
......@@ -87,8 +91,8 @@ class UIFlightDrawer extends UI3dComponent implements GeometryConstants {
pg.endShape(CLOSE);
// Right wing
LightSamplePoint[] rightLights = flyer.getRightWing().getLightPoints();
pg.fill(rightLights[0].getColor()); // Just use point 0 for the wing for now
List<LightSamplePoint> rightLights = model.getFlyerRightWingLights(flyer.getIndex());
pg.fill(rightLights.get(0).getColor()); // Just use point 0 for the wing for now
pg.beginShape();
pg.vertex(4.01, 0, -4.96);
pg.vertex(9.12, 0, -11.17);
......@@ -96,8 +100,8 @@ class UIFlightDrawer extends UI3dComponent implements GeometryConstants {
pg.endShape(CLOSE);
// Body shell
LightSamplePoint light = flyer.getBodyLightPoint();
pg.fill(light.getColor());
LightSamplePoint bodyLight = model.getFlyerBodyLight(flyer.getIndex());
pg.fill(bodyLight.getColor());
pg.beginShape();
pg.vertex(0, 0, 0);
......@@ -126,11 +130,11 @@ class UIFlightDrawer extends UI3dComponent implements GeometryConstants {
private void computeFlyerLightsAndWings() {
//Wing[] wings = (Wing[]) model.getAllWings().toArray();
for (LightSamplePoint l: model.getLightsOfAllWings()) {
for (LightSamplePoint l: model.getAllWingsLights()) {
//l.setColor(LXColor.RED);
}
for (LightSamplePoint l: model.getLightsOfAllBodies()) {
for (LightSamplePoint l: model.getAllBodyLights()) {
//l.setColor(LXColor.BLUE);
}
......
import heronarts.lx.*;
import heronarts.lx.audio.*;
import heronarts.lx.color.LXColor;
import heronarts.lx.effect.*;
import heronarts.lx.model.*;
import heronarts.lx.output.*;
import heronarts.lx.parameter.*;
import heronarts.lx.pattern.*;
import heronarts.lx.studio.LXStudio;
import heronarts.lx.transform.*;
import heronarts.lx.modulator.*;
......@@ -46,14 +48,12 @@ UI3dContext viewContext;
FlyerHighlighter flyerHighlighter;
class ProcessingEngine extends FlightEngine {
ProcessingEngine(String projectPath, FlightModel model, LXStudio lx) {
super(projectPath, model, lx);
}
}
// Derived from Mark Slee's LXStudioApp example
private static final String WINDOW_TITLE = "FLIGHT Graphical UI";
private static int WIDTH = 1280;
......@@ -67,17 +67,17 @@ void settings() {
// Starts wings as Red and bodies as Blue, why not.
void initializeModel() {
model = new Model(flyerConfigurations).getFlightModel();
List<LightSamplePoint> wingLights = model.getLightsOfAllWings();
for (LightSamplePoint light: wingLights) {
light.setColor(LXColor.hsb(0, 0.5, 0.8));
}
List<LightSamplePoint> bodyLights = model.getLightsOfAllBodies();
for (LightSamplePoint light: bodyLights) {
light.setColor(LXColor.hsb(0.7, 0.5, 0.8));
}
model = new Model(flyerConfigurations).getFlightModel();
List<LightSamplePoint> wingLights = model.getAllWingsLights();
for (LightSamplePoint light: wingLights) {
light.setColor(LXColor.hsb(0, 0.5, 0.8));
}
List<LightSamplePoint> bodyLights = model.getAllBodyLights();
for (LightSamplePoint light: bodyLights) {
light.setColor(LXColor.hsb(0.7, 0.5, 0.8));
}
}
......@@ -87,20 +87,20 @@ void setup() {
IO io = new IO(sketchPath());
flyerConfigurations = io.loadConfigFile(Config.FLYER_CONFIG_FILE);
initializeModel();
lx = new LXStudio(this, model);
lx = new LXStudio(this, model);
}
void initializeUI(LXStudio lx, LXStudio.UI ui) {
pengine = new ProcessingEngine(sketchPath(), model, lx);
lx.engine.setThreaded(true);
lx.engine.addLoopTask(new FadeTest(lx));
lx.engine.addLoopTask(new BlackPinkTest(lx));
}
public void onUIReady(LXStudio lx, LXStudio.UI ui) {
System.out.println("Creating UI.");
FlightGui.this.flyerHighlighter = new FlyerHighlighter(lx, flyerConfigurations);
lx.addEffect(flyerHighlighter);
configureUI(ui);
System.out.println("Creating UI.");
FlightGui.this.flyerHighlighter = new FlyerHighlighter(lx, flyerConfigurations);
lx.addEffect(flyerHighlighter);
configureUI(ui);
}
void configureUI(LXStudio.UI ui) {
......@@ -144,21 +144,19 @@ void configureUI(LXStudio.UI ui) {
// Adds the control panel for selecting and moving Flyers
ui.addLayer(viewContext);
ui.addLayer(new UIFlyerConfiguration(ui));
}
@Override
public void draw() {
//background(#222222);
// The actual model and such are drawn in their own
// draw methods, e.g. UIFlightDisplay.onDraw.
//background(#222222);
// The actual model and such are drawn in their own
// draw methods, e.g. UIFlightDisplay.onDraw.
}
void keyPressed() {
switch (key) {
case 'a':
System.out.println("Pressed a");
break;
case 'a':
System.out.println("Pressed a");
break;
}
}
import java.util.List;
class UIFlyerConfiguration extends UIWindow {
final static int WIDTH = 140;
final static int HEIGHT = 360;
......@@ -6,13 +8,15 @@ class UIFlyerConfiguration extends UIWindow {
private UIButton enableButton;
private UIIntegerBox flyerSelect;
private UISlider hangDistanceSlider; // All faces
private UISlider tiltSlider; // All faces
private UISlider directionSlider; // All faces
private UISlider xSlider; // Front window: x along row
private UIToggleSet yToggle; // Front window: which row
private UISlider positionSlider; // Spirals: point along spiral
private UIToggleSet pipeToggle; // Ceiling: which pipe
private UISlider mountPointSlider; // Ceiling: were on pipe
private UIToggleSet faceToggle;
private UILabel name;
private UILabel text;
......@@ -21,6 +25,8 @@ class UIFlyerConfiguration extends UIWindow {
String face = faceToggle.getValue();
// Every mounting point has a hang distance
hangDistanceSlider.setVisible(true);
tiltSlider.setVisible(true);
directionSlider.setVisible(true);
// Other measurements are face-dependent; only make relevant
// ones visible.
......@@ -29,7 +35,7 @@ class UIFlyerConfiguration extends UIWindow {
pipeToggle.setVisible(false);
positionSlider.setVisible(false);
mountPointSlider.setVisible(false);
if (face.equals("C")) {
pipeToggle.setVisible(true);
mountPointSlider.setVisible(true);
......@@ -43,48 +49,51 @@ class UIFlyerConfiguration extends UIWindow {
} else {
System.err.println("Unrecognized face: " + face + "; disable all controls.");
}
}
UIFlyerConfiguration(UI ui) {
super(ui, "LAYOUT TOOL",
BORDER, FlightGui.this.height - (HEIGHT + BORDER),
WIDTH, HEIGHT);
makeEnableButton();
makeFlyerSelect();
makeFaceToggle();
makeTiltSlider();
makeDirectionSlider();
makeHangLengthSlider();
makeXSlider();
makeYToggle();
makeHangLengthSlider();
makePositionSlider();
makePipeToggle();
makeMountingSlider();
// makeSaveButton();
name = new UILabel(0, 0, 0, 16);
name.setLabel("?");
text = new UILabel(0, 0, 0, 16);
text.setLabel("?");
float yPos = TITLE_LABEL_HEIGHT;
yPos += ROW_HEIGHT;
yPos = labelRow(yPos, "FLYER #", flyerSelect);
yPos = labelRow(yPos, "NAME", name);
yPos = labelRow(yPos, "TEXT", text);
yPos = labelRow(yPos, "FACE", faceToggle);
yPos = labelRow(yPos, "HANG", hangDistanceSlider);
yPos = labelRow(yPos, "TILT", tiltSlider);
yPos = labelRow(yPos, "DIR", directionSlider);
yPos = labelRow(yPos, "X", xSlider);
yPos = labelRow(yPos, "Y", yToggle);
yPos = labelRow(yPos, "POS", positionSlider);
yPos = labelRow(yPos, "PIPE", pipeToggle);
yPos = labelRow(yPos, "MOUNT", mountPointSlider);
new UIButton(4, yPos, this.width-8, 20) {
void onToggle(boolean active) {
if (active) {
......@@ -97,11 +106,11 @@ class UIFlyerConfiguration extends UIWindow {
}
}
}.setMomentary(true).setLabel("Save Changes").addToContainer(this);
setFlyer();
updateEditableParameters();
}
private void makeEnableButton() {
this.enableButton = new UIButton(4, TITLE_LABEL_HEIGHT, width-8, 20) {
public void onToggle(boolean enabled) {
......@@ -132,7 +141,7 @@ class UIFlyerConfiguration extends UIWindow {
};
flyerHighlighter.flyerIndex.addListener(selectListener);
}
private void makeFaceToggle() {
this.faceToggle = new UIToggleSet() {
protected void onToggle(String value) {
......@@ -141,7 +150,7 @@ class UIFlyerConfiguration extends UIWindow {
flyerHighlighter.reloadModel();
}
};
// We have to convert to intern() because of a bug in ToggleSet
// that compares with == rather than .equals(); if you don't
// use .intern(), then strings don't match. -pal
......@@ -152,7 +161,7 @@ class UIFlyerConfiguration extends UIWindow {
}
this.faceToggle.setOptions(options);
}
private void makeHangLengthSlider() {
BoundedParameter hang = new BoundedParameter("Hang", 0, 8 * GeometryConstants.FEET);
this.hangDistanceSlider = new UISlider(0, 0, 0, 16) {
......@@ -163,6 +172,27 @@ class UIFlyerConfiguration extends UIWindow {
};
this.hangDistanceSlider.setParameter(hang);
}
private void makeTiltSlider() {
BoundedParameter tilt = new BoundedParameter("Tilt", 0, 1);
this.tiltSlider = new UISlider(0, 0, 0, 16) {
public void onParameterChanged(LXParameter parameter) {
flyerHighlighter.getConfig().tilt = parameter.getValuef();
flyerHighlighter.reloadModel();
}
};
this.tiltSlider.setParameter(tilt);
}
private void makeDirectionSlider() {
BoundedParameter direction = new BoundedParameter("Rotation", 0, 1);
this.directionSlider = new UISlider(0, 0, 0, 16) {
public void onParameterChanged(LXParameter parameter) {
flyerHighlighter.getConfig().rotation = parameter.getValuef();
flyerHighlighter.reloadModel();
}
};
this.directionSlider.setParameter(direction);
}
private void makeXSlider() {
BoundedParameter x = new BoundedParameter("X", 0, GeometryConstants.FRONT_WINDOW_WIDTH);
......@@ -197,7 +227,7 @@ class UIFlyerConfiguration extends UIWindow {
this.positionSlider.setParameter(pos);
}
private void makeMountingSlider() {
BoundedParameter mount = new BoundedParameter("Mount", 0, 0, 1);
this.mountPointSlider = new UISlider(0, 0, 0, 16) {
......@@ -208,7 +238,7 @@ class UIFlyerConfiguration extends UIWindow {
};
this.mountPointSlider.setParameter(mount);
}
private void makePipeToggle() {
this.pipeToggle = new UIToggleSet() {
protected void onToggle(String str) {
......@@ -219,7 +249,7 @@ class UIFlyerConfiguration extends UIWindow {
String[] pipeOptions = {"0".intern(), "1".intern(), "2".intern(), "3".intern(), "4".intern(), "5".intern(), "6".intern(), "7".intern()};
pipeToggle.setOptions(pipeOptions);
}
float labelRow(float yPos, String label, UI2dComponent obj) {
new UILabel(4, yPos, 50, 20)
.setLabel(label)
......@@ -231,7 +261,7 @@ class UIFlyerConfiguration extends UIWindow {
yPos += ROW_HEIGHT;
return yPos;
}
void setFlyer() {
FlyerConfig config = flyerConfigurations[flyerHighlighter.flyerIndex.getValuei()];
xSlider.getParameter().setValue(config.faceConfig().x);
......@@ -242,4 +272,3 @@ class UIFlyerConfiguration extends UIWindow {
text.setLabel(config.metadata().text);
}
}
File mode changed from 100644 to 100755
......@@ -3,5 +3,4 @@ final class Config {
public static final String FLYER_CONFIG_FILE = "data/flyers.json";
public static final String OUTPUT_NAMES_FILE = "data/outputs.json";
public static final String[] FACE_NAMES = {"C", "F", "I", "E"};
}
import java.util.List;
interface Flight extends GeometryConstants {
/*
* The naming scheme for the pattern getter functions are as follows:
* get [required]
* all flyers or one flyer (All vs Flyer) [required]
* part specifier if applicable (LeftWing(s), RightWing(s), Wings, Body) [optional]
* light specifier if applicable (PositionIndexed) [optional]
* Light/Lights
*/
abstract interface Flight extends GeometryConstants {
/**
* for movement pattern
* pattern getters for all flyers
*/
List<Wing> getLeftWings();
List<Wing> getRightWings();
/* ------------- all flyers, motion ------------- */
List<Wing> getAllWings();
List<Wing> getAllLeftWings();
List<Wing> getAllRightWings();
/**
* for light pattern
*/
List<LightSamplePoint> getLightsOfLeftWings();
List<LightSamplePoint> getLightsOfRightWings();
List<LightSamplePoint> getLightsOfAllWings();
List<LightSamplePoint> getHeadLightOfLeftWings();
List<LightSamplePoint> getHeadLightOfRightWings();
/* ------------- all flyers, lights ------------- */
List<LightSamplePoint> getAllLights();
List<LightSamplePoint> getHeadLightOfAllWings();
List<LightSamplePoint> getAllBodyLights();
List<LightSamplePoint> getAllWingsLights();
List<LightSamplePoint> getAllWingsPositionIndexedLights(int positionIndex); // head
List<LightSamplePoint> getSideLightOfLeftWings();
// left wings
List<LightSamplePoint> getAllLeftWingLights();
List<LightSamplePoint> getAllLeftWingPositionIndexedLights(int positionIndex);
List<LightSamplePoint> getSideLightOfRightWings();
// right wings
List<LightSamplePoint> getAllRightWingLights();
List<LightSamplePoint> getAllRightWingPositionIndexedLights(int positionIndex);
List<LightSamplePoint> getSideLightOfAllWings();
List<LightSamplePoint> getTailLightOfLeftWings();
/**
* pattern getters for individual flyers
*/
/* ------------- one flyer, motion ------------- */
Wing getFlyerLeftWing(int flyerIndex);
Wing getFlyerRightWing(int flyerIndex);
List<Wing> getFlyerWings(int flyerIndex);
List<LightSamplePoint> getTailLightOfRightWings();
/* ------------- one flyer, lights ------------- */
List<LightSamplePoint> getFlyerLights(int flyerIndex);
List<LightSamplePoint> getTailLightOfAllWings();
LightSamplePoint getFlyerBodyLight(int flyerIndex);
List<LightSamplePoint> getFlyerWingsLights(int flyerIndex);
List<LightSamplePoint> getFlyerWingsPositionIndexedLights(int flyerIndex, int positionIndex);
List<LightSamplePoint> getLightsOfAllBodies();
List<LightSamplePoint> getFlyerLeftWingLights(int flyerIndex);
LightSamplePoint getFlyerLeftWingPositionIndexedLights(int flyerIndex, int positionIndex);
List<LightSamplePoint> getAllLights();
List<LightSamplePoint> getFlyerRightWingLights(int flyerIndex);
LightSamplePoint getFlyerRightWingPositionIndexedLights(int flyerIndex, int positionIndex);
FlyerConfig[] getFlyerConfigs();
/**
* flyer config getters
*/
Flyer getFlyer(int i);
Flyer[] getFlyers();
/**
* This defines the positions of the flyers, which are
* index,
* x (left to right), y (front to back), z (bottom to top),
* rotation in degrees, and tilt (3 options)
*/
/**
* This defines the positions of the flyers, which are
* index,
* x (left to right), y (front to back), z (bottom to top),
* rotation in degrees, and tilt (3 options)
*/
FlyerConfig[] getFlyerConfigs();
List<Flyer> getFlyers();
}
\ No newline at end of file
interface Flyer extends GeometryConstants {
public final static int PIXELS_PER_BODY =
LightSamplePoint.LightCorners.BODY.numPixels;
import java.util.List;
public final static int PIXELS_PER_FLYER =
NUM_WINGS_PER_FLYER *
(LightSamplePoint.LightCorners.HEAD.numPixels +
LightSamplePoint.LightCorners.SIDE.numPixels +
LightSamplePoint.LightCorners.TAIL.numPixels) +
import heronarts.lx.model.LXModel;
import heronarts.lx.model.LXPoint;
abstract interface Flyer extends GeometryConstants {
public final static int PIXELS_PER_BODY =
LightSamplePoint.LightCorners.BODY.numPixels;
int getIndex();
......@@ -21,16 +19,18 @@ interface Flyer extends GeometryConstants {
float getTilt();
Wing[] getWings();
LXModel[] getWings();
Wing getLeftWing();
Wing getRightWing();
LightSamplePoint getBodyLightPoint();
LightSamplePoint[] getLightPoints();
LXPoint getBodyLightPoint();
List<? extends LXPoint> getLightPoints();
FlyerConfig getConfig();
}
class FlyerConfig {
......@@ -49,6 +49,7 @@ class FlyerConfig {
float mountPoint;
float hangDistance;
@Override
public String toString() {
String s = "Face: \"" + face + "\"\n";
s += "x: " + x + "\n";
......@@ -59,7 +60,7 @@ class FlyerConfig {
s += "hangDistance: " + hangDistance + "\n";
return s;
}
}
static class FlyerMetadata {
......@@ -69,6 +70,7 @@ class FlyerConfig {
String department;
int year;
@Override
public String toString() {
String s = "Name: " + name + "\n";
s += "Text: " + text + "\n";
......@@ -87,6 +89,7 @@ class FlyerConfig {
return metadata;
}
@Override
public String toString() {
String s = "Index: " + index + "\n";
s += metadata.toString();
......
import java.util.List;
import heronarts.lx.LX;
import heronarts.lx.LXLayer;
import heronarts.lx.color.LXColor;
import heronarts.lx.effect.LXEffect;
import heronarts.lx.modulator.SinLFO;
import heronarts.lx.parameter.BooleanParameter;
import heronarts.lx.parameter.DiscreteParameter;
import heronarts.lx.parameter.LXParameter;
......@@ -31,7 +27,7 @@ class FlyerHighlighter extends Effect {
addModulator(strobe).start();
addLayer(new HighlightLayer());
}
FlyerConfig getConfig() {
return flyerConfigurations[flyerIndex.getValuei()];
}
......@@ -39,7 +35,7 @@ class FlyerHighlighter extends Effect {
Flyer getFlyer() {
return model.getFlyer(flyerIndex.getValuei());
}
void reloadModel() {
lx.setModel(new FlightModel(flyerConfigurations));
}
......@@ -47,10 +43,10 @@ class FlyerHighlighter extends Effect {
void trigger() {
strobe.trigger();
}
void highlight() {
if (isEnabled()) {