diff options
| author | Tim Redfern <tim@getdrop.com> | 2018-04-24 21:28:56 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2018-04-24 21:28:56 +0100 |
| commit | 880f710768391dc3a3399fc1896447a9e6c34fa4 (patch) | |
| tree | 8856fe5d8eb847396a72ead3d9c3a49418cc0feb /osctest/src/ofApp.cpp | |
| parent | 60e218550dd4f584da2f6f74ffc755f5f34c20a7 (diff) | |
osctest for projection sync
Diffstat (limited to 'osctest/src/ofApp.cpp')
| -rw-r--r-- | osctest/src/ofApp.cpp | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/osctest/src/ofApp.cpp b/osctest/src/ofApp.cpp new file mode 100644 index 0000000..918480e --- /dev/null +++ b/osctest/src/ofApp.cpp @@ -0,0 +1,133 @@ +#include "ofApp.h" + + + +//-------------------------------------------------------------- +void ofApp::setup(){ + ofSetVerticalSync(true); + + + gui.setup(""); // most of the time you don't need a name but don't forget to call setup + + gui.add(enable.set("enable", true)); + gui.add(duration.set("duration", 1.0f,0.0f,10.0f)); + gui.add(spawnProbability.set("spawn", 0.1f)); + + + bHide = false; + +} + +//-------------------------------------------------------------- +void ofApp::exit(){ + +} + + +//-------------------------------------------------------------- +void ofApp::update(){ + if (ofRandom(1.0f)<(spawnProbability/ofGetFrameRate())){ + tracers.push_back(tracer()); + ofLog() << "new tracer: "<<tracers[tracers.size()-1].colour; + } + // open an outgoing connection to HOST:PORT + sender.setup(HOST, PORT); +} + +//-------------------------------------------------------------- +void ofApp::draw(){ + ofBackground(ofColor::black); + + ofxOscBundle bundle; + + auto t=tracers.begin(); + while (t!=tracers.end()){ + if (ofGetElapsedTimef()-t->born>duration){ + tracers.erase(t); + } + else { + if (enable){ + ofxOscMessage m; + m.setAddress("/xyrgb"); + m.addFloatArg(t->pos.x); + m.addFloatArg(t->pos.y); + m.addIntArg(t->colour.r); + m.addIntArg(t->colour.g); + m.addIntArg(t->colour.b); + bundle.addMessage(m); + t->draw(); + } + t++; + } + } + + sender.sendBundle(bundle); + + + if( !bHide ){ + gui.draw(); + } +} + +//-------------------------------------------------------------- +void ofApp::keyPressed(int key){ + if( key == 'h' ){ + bHide = !bHide; + } + if(key == 's') { + gui.saveToFile("settings.xml"); + } + if(key == 'l') { + gui.loadFromFile("settings.xml"); + } + +} + +//-------------------------------------------------------------- +void ofApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseDragged(int x, int y, int button){ +} + +//-------------------------------------------------------------- +void ofApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseEntered(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseExited(int x, int y){ + +} + +//-------------------------------------------------------------- +void ofApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void ofApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void ofApp::dragEvent(ofDragInfo dragInfo){ + +} |
