Commit b55adcef authored by Philip Levis's avatar Philip Levis
Browse files

Commenting the main FlightGUI.pde sketch.

parent 2edd891b
/** Top-level Processing sketch for running the FLIGHT GUI. To run
* this, load it in Processing. Other sketches contain supporting code.
*
* @author Philip Levis <pal@cs.stanford.edu>
*/
import heronarts.lx.*;
import heronarts.lx.audio.*;
import heronarts.lx.color.LXColor;
......@@ -60,46 +66,60 @@ private static int WIDTH = 1280;
private static int HEIGHT = 800;
private static boolean FULLSCREEN = false;
void settings() {
size(WIDTH, HEIGHT, P3D);
}
// Starts wings as Red and bodies as Blue, why not.
void initializeModel() {
try {
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));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
/**
* Required by Processing. Sets up the graphics context/window size
* and tells Processing to use a 3D optimized graphics engine.
*/
void settings() { size(WIDTH, HEIGHT, P3D); }
/**
* Given an array of FlyerConfigs, builds the LXModel with flyers,
* wings, and lights. Initializes the wings and bodies to red
* and blue as defaults.
*/
void initializeModel(FlyerConfig[] flyers) {
model = new Model(flyers).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));
}
}
/**
* Loads the Flyer configuration JSON file
* for their positions and metadata, creates the data model from this
* information, and creates an LXStudio instance. This method is required
* and called by Processing.
*/
void setup() {
frameRate(90);
System.out.println("Starting LXStudio; initialized Fractal Flyer data model from " + Config.FLYER_CONFIG_FILE);
IO io = new IO(sketchPath());
flyerConfigurations = io.loadConfigFile(Config.FLYER_CONFIG_FILE);
initializeModel();
initializeModel(flyerConfigurations);
lx = new LXStudio(this, model);
}
/**
* Creates the ProcessingEngine that triggers Patterns and generally
* controls FLIGHT. This method is required and called by Processing.
*/
void initializeUI(LXStudio lx, LXStudio.UI ui) {
pengine = new ProcessingEngine(sketchPath(), model, lx);
lx.engine.setThreaded(true);
//lx.engine.addLoopTask(new BlackPinkTest(lx));
}
/**
* Creates the FLIGHT GUI. This method is required and called by
* Processing.
*/
public void onUIReady(LXStudio lx, LXStudio.UI ui) {
System.out.println("Creating UI.");
FlightGui.this.flyerHighlighter = new FlyerHighlighter(lx, flyerConfigurations);
......
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