diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-03-28 00:43:07 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-03-28 00:43:07 +0100 |
| commit | 11850d1ded455e135cfa42aa1598b89be9544807 (patch) | |
| tree | 7ee41d76618c4843c659c42ca2620d6ae1974689 | |
| parent | ec078a99e2924c1709242f981651409f7ae9e940 (diff) | |
for strongbow demo
| -rw-r--r-- | addons.make | 6 | ||||
| -rw-r--r-- | bin/data/settings.xml | 26 | ||||
| -rw-r--r-- | config.make | 4 | ||||
| -rw-r--r-- | map4.layout | 18 | ||||
| -rw-r--r-- | src/testApp.cpp | 102 | ||||
| -rw-r--r-- | src/testApp.h | 28 |
6 files changed, 155 insertions, 29 deletions
diff --git a/addons.make b/addons.make index 89b6ef6..022bded 100644 --- a/addons.make +++ b/addons.make @@ -1,4 +1,8 @@ ofxOpenCv ofx3DModelLoader ofxXmlSettings - +ofxThread +ofxAvahiCore +ofxAvahiClient +ofxOsc +ofxNetwork diff --git a/bin/data/settings.xml b/bin/data/settings.xml index 86e3759..ba48808 100644 --- a/bin/data/settings.xml +++ b/bin/data/settings.xml @@ -10,33 +10,39 @@ <settings file="black.mov" /> </clip> <clip> - <settings file="strongbow/Still_image.mov" /> + <settings file="strongbow/plain_bottle.mov" /> </clip> <clip> - <settings file="strongbow/archer_bottle.mov" /> + <settings file="strongbow/rotate_shatter.mov" /> </clip> <clip> - <settings file="strongbow/ad_inside_bottle.mov" /> + <settings file="strongbow/Strongbow_pulse.mov" /> </clip> <clip> - <settings file="strongbow/golden_lights_inside_bottle.mov" /> + <settings file="strongbow/ad_in_bottle.mov" /> </clip> <clip> - <settings file="strongbow/gold_blocks_inside_bottle.mov" /> + <settings file="strongbow/grid.mov" /> </clip> <clip> - <settings file="strongbow/timelapse_inside_bottle.mov" /> + <settings file="strongbow/balls_in_bottle.mov" /> </clip> <clip> - <settings file="strongbow/bars_inside_bottle.mov" /> + <settings file="strongbow/pulse_scan.mov" /> </clip> <clip> - <settings file="strongbow/balls_inside_bottle.mov" /> + <settings file="strongbow/tron_gold.mov" /> </clip> <clip> - <settings file="strongbow/archer final.mov" /> + <settings file="strongbow/gold_bars.mov" /> </clip> <clip> - <settings file="strongbow/logo_rotate_new.mov" /> + <settings file="strongbow/Strongbow_rings.mov" /> + </clip> + <clip> + <settings file="strongbow/cube_wave.mov" /> + </clip> + <clip> + <settings file="strongbow/timelapse.mov" /> </clip> </map4> diff --git a/config.make b/config.make index 23d8351..322e619 100644 --- a/config.make +++ b/config.make @@ -10,7 +10,7 @@ OF_ROOT = ../of_preRelease_v007_linux/ # for example search paths like: # USER_CFLAGS = -I src/objects -USER_CFLAGS = +USER_CFLAGS = -I ../../../addons -I ../../../addons/ofxAvahiCore/libs/avahi/include # USER_LDFLAGS allows to pass custom flags to the linker @@ -23,7 +23,7 @@ USER_LDFLAGS = # use this to add system libraries for example: # USER_LIBS = -lpango -USER_LIBS = +USER_LIBS = -lavahi-core -lavahi-client # change this to add different compiler optimizations to your project diff --git a/map4.layout b/map4.layout index de269f0..197277a 100644 --- a/map4.layout +++ b/map4.layout @@ -4,14 +4,14 @@ <File name="../../../addons/ofx3DModelLoader/src/3DS/model3DS.h" open="0" top="0" tabpos="0"> <Cursor position="136" topLine="0" /> </File> - <File name="addons.make" open="1" top="0" tabpos="1"> + <File name="addons.make" open="0" top="0" tabpos="1"> <Cursor position="43" topLine="0" /> </File> <File name="bin/data/defaults.xml" open="0" top="0" tabpos="3"> <Cursor position="1033" topLine="0" /> </File> - <File name="bin/data/settings.xml" open="0" top="0" tabpos="11"> - <Cursor position="1063" topLine="0" /> + <File name="bin/data/settings.xml" open="1" top="0" tabpos="3"> + <Cursor position="676" topLine="0" /> </File> <File name="config.make" open="0" top="0" tabpos="3"> <Cursor position="548" topLine="0" /> @@ -22,20 +22,20 @@ <File name="src/keyVar.h" open="0" top="0" tabpos="8"> <Cursor position="0" topLine="0" /> </File> - <File name="src/main.cpp" open="1" top="0" tabpos="3"> + <File name="src/main.cpp" open="0" top="0" tabpos="3"> <Cursor position="833" topLine="0" /> </File> - <File name="src/mapUtils.cpp" open="1" top="0" tabpos="4"> + <File name="src/mapUtils.cpp" open="0" top="0" tabpos="4"> <Cursor position="5495" topLine="107" /> </File> <File name="src/mapUtils.h" open="0" top="0" tabpos="6"> <Cursor position="165" topLine="0" /> </File> - <File name="src/testApp.cpp" open="1" top="1" tabpos="2"> - <Cursor position="2116" topLine="39" /> + <File name="src/testApp.cpp" open="1" top="1" tabpos="1"> + <Cursor position="6590" topLine="230" /> </File> - <File name="src/testApp.h" open="1" top="0" tabpos="5"> - <Cursor position="1337" topLine="17" /> + <File name="src/testApp.h" open="1" top="0" tabpos="2"> + <Cursor position="795" topLine="60" /> </File> <File name="src/viewpoint.cpp" open="0" top="0" tabpos="4"> <Cursor position="566" topLine="0" /> diff --git a/src/testApp.cpp b/src/testApp.cpp index dff1f18..a7b90d1 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -66,6 +66,10 @@ void testApp::setup(){ ofAddListener(ard.EInitialized, this, &testApp::setupArduino); bSetupArduino = false; bSwitchArduino = false; + + //----------------avahi stuff + avahiService.start("ofMrmr","_mrmrsrvr._udp",1337); + oscReceiver.setup(1337); //default mrmr port } @@ -93,6 +97,9 @@ void testApp::update(){ } } updateArduino(); + + //----------------avahi stuff + ProcessMessages(); } //-------------------------------------------------------------- @@ -139,6 +146,81 @@ void testApp::updateArduino(){ } } +bool startswith(const char* _str1, const char* _start){ + for(int i=0;_start[i]>0;i++){ + if(_str1[i]!=_start[i]) + return false; + } + return true; +} + +void testApp::SendInterface(std::string targetIP, std::string interfaceString){ + + /* Example: + "/mrmrIB mrmr_clear_all\n"\ + "/mrmrIB tactilezone nil .1 1 10 1 2 1 9 _ 2\n"\ + "/mrmrIB textinputview nil .1 1 10 1 1 1 1 placeholder_text_for_textinput_field\n"*/ + + tcpClient.close(); //just open a fresh socket to do this one-time setup/send to the new client + tcpClient.setup(targetIP,31337); + + printf("Sending interface...\n"); + + int count = interfaceString.length(); + tcpClient.sendRawBytes(interfaceString.c_str(),count); //don't use send() as it appends [/TCP] tag, which screws up mrmr client +} + +void testApp::ProcessMessages(){ + + while( oscReceiver.hasWaitingMessages() ) + + + { + + // get the next message + ofxOscMessage m; + oscReceiver.getNextMessage( &m ); + std::string messageAddress = m.getAddress(); + + printf("Message: %s\n",messageAddress.c_str()); + + std::string rip = m.getRemoteIp(); + int rp = m.getRemotePort(); + std::string arg1; + + if(messageAddress.compare("/mrmr connect")==0){ + SendInterface(rip, + "/mrmrIB mrmr_clear_all\n"\ + "/mrmrIB titleview nil .1 1 10 1 1 1 1 StrongbowDemo 3"\ + "/mrmrIB pushbutton nil .1 2 10 1 6 1 1 < 11\n"\ + "/mrmrIB pushbutton nil .1 2 10 1 6 1 1 < 11\n"\ + "/mrmrIB pushbutton nil .1 2 10 2 6 1 1 > 11\n" + ); + } + else + { + int ls = messageAddress.find_last_of("/"); + int msg=-1; + + if(m.getNumArgs()) msg=m.getArgAsInt32( 0 ); + + if(startswith(messageAddress.c_str(),"/mrmr/pushbutton/1")) + { + printf("previous movie %i\n",msg); + if (msg) prevMovie(); + } + if(startswith(messageAddress.c_str(),"/mrmr/pushbutton/2")) + { + printf("next movie %i\n",msg); + if (msg) nextMovie(); + } + + } + } +} + + + //-------------------------------------------------------------- void testApp::draw(){ for (int i=0;i<numViews;i++) { @@ -237,16 +319,11 @@ void testApp::keyPressed(int key){ break; case ',': case '<': - whichClip--; - if (whichClip<1) whichClip=numClips-1; - transTime=ofGetElapsedTimef()+1.0; - transition=true; + prevMovie(); break; case '.': case '>': - whichClip=max(1,(whichClip+1)%numClips); - transTime=ofGetElapsedTimef()+1.0; - transition=true; + nextMovie(); break; case '/': light=!light; @@ -258,6 +335,17 @@ void testApp::keyPressed(int key){ break; } } +void testApp::prevMovie(){ + whichClip--; + if (whichClip<1) whichClip=numClips-1; + transTime=ofGetElapsedTimef()+1.0; + transition=true; +} +void testApp::nextMovie(){ + whichClip=max(1,(whichClip+1)%numClips); + transTime=ofGetElapsedTimef()+1.0; + transition=true; +} void testApp::doTransition(){ if (transition) { if (ofGetElapsedTimef()>transTime) { diff --git a/src/testApp.h b/src/testApp.h index 293b6fd..1bf2d7b 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -34,6 +34,14 @@ have to track how many frames each key has been pressed for #include "mapUtils.h" #include "viewpoint.h" +#define OF_ADDON_USING_OFXAVAHI + +//#include "ofxAvahiCoreBrowser.h" +#include "ofxAvahiClient.h" + +#include "ofxOsc.h" +#include "ofxNetwork.h" + class testApp : public ofBaseApp{ public: @@ -57,6 +65,9 @@ class testApp : public ofBaseApp{ void doTransition(); float transTime; bool transition; + + void prevMovie(); + void nextMovie(); string model_name; float model_x; @@ -95,5 +106,22 @@ class testApp : public ofBaseApp{ ofArduino ard; bool bSetupArduino; // flag variable for setting up arduino once int bSwitchArduino; + + //----------------avahi stuff + + ofxAvahiClientService avahiService; + + ofxTCPClient tcpClient; + ofxOscReceiver oscReceiver; + + void SendInterface(std::string targetIP, std::string interfaceString); + + bool hasWaitingMessages(){ + return oscReceiver.hasWaitingMessages(); + } + void getNextMessage(ofxOscMessage* m){ + oscReceiver.getNextMessage(m); + } + void ProcessMessages(); }; |
