├── .gitignore ├── README.md ├── Week_01 └── Code │ ├── GroupPrinter │ ├── GroupPrinter.ino │ └── README.md │ ├── PinwheelProcessing │ ├── PinwheelProcessing.pde │ └── data │ │ └── spacebrew.txt │ ├── Randomizer_Output_OF │ ├── Project.xcconfig │ ├── README.md │ ├── Randomizer.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── Randomizer Debug.xcscheme │ │ │ └── Randomizer Release.xcscheme │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ ├── Arial.ttf │ │ │ ├── assign.txt │ │ │ ├── spacebrew.txt │ │ │ └── students.txt │ ├── openFrameworks-Info.plist │ └── src │ │ ├── ContestantDisplay.cpp │ │ ├── ContestantDisplay.h │ │ ├── Group.cpp │ │ ├── Group.h │ │ ├── Lights.cpp │ │ ├── Lights.h │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h │ ├── Randomizer_Output_P5 │ ├── ContestantDisplay.pde │ ├── Group.pde │ ├── Lights.pde │ ├── README.md │ ├── Randomizer_Output_P5.pde │ ├── data │ │ ├── assign.txt │ │ ├── spacebrew.txt │ │ └── students.txt │ └── sketch.properties │ └── SBStringSender │ └── SBStringSender.pde ├── Week_02 └── Code │ ├── FlashScreen │ └── FlashScreen.pde │ └── FlashScreenJS │ ├── css │ ├── reset.css │ └── style.css │ ├── index.html │ ├── js │ ├── jquery-1.9.0.min.js │ ├── sb-1.0.1.js │ └── sb-1.0.1.min.js │ └── server.py ├── Week_04 ├── Code_Completed │ ├── Example_01_tspsSpacebrew │ │ ├── Project.xcconfig │ │ ├── addons.make │ │ ├── bin │ │ │ └── data │ │ │ │ └── .gitkeep │ │ ├── openFrameworks-Info.plist │ │ ├── src │ │ │ ├── main.cpp │ │ │ ├── testApp.cpp │ │ │ └── testApp.h │ │ └── tspsSpacebrew.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── tspsSpacebrew Debug.xcscheme │ │ │ └── tspsSpacebrew Release.xcscheme │ ├── Example_02_tsps_peekaboo │ │ ├── Project.xcconfig │ │ ├── addons.make │ │ ├── bin │ │ │ └── data │ │ │ │ ├── .gitkeep │ │ │ │ └── DINPro-Medium.otf │ │ ├── openFrameworks-Info.plist │ │ ├── src │ │ │ ├── main.cpp │ │ │ ├── testApp.cpp │ │ │ └── testApp.h │ │ └── tsps_peekaboo.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── tsps_peekaboo Debug.xcscheme │ │ │ └── tsps_peekaboo Release.xcscheme │ └── Example_03_tsps_trails │ │ ├── Project.xcconfig │ │ ├── addons.make │ │ ├── bin │ │ └── data │ │ │ └── .gitkeep │ │ ├── openFrameworks-Info.plist │ │ ├── src │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h │ │ └── tsps_trails.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ └── xcschemes │ │ ├── tsps_trails Debug.xcscheme │ │ └── tsps_trails Release.xcscheme ├── Code_Empty │ ├── Example_01_tspsSpacebrew │ │ ├── Project.xcconfig │ │ ├── addons.make │ │ ├── bin │ │ │ └── data │ │ │ │ └── .gitkeep │ │ ├── openFrameworks-Info.plist │ │ ├── src │ │ │ ├── main.cpp │ │ │ ├── testApp.cpp │ │ │ └── testApp.h │ │ └── tspsSpacebrew.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── tspsSpacebrew Debug.xcscheme │ │ │ └── tspsSpacebrew Release.xcscheme │ ├── Example_02_tsps_peekaboo │ │ ├── Project.xcconfig │ │ ├── addons.make │ │ ├── bin │ │ │ └── data │ │ │ │ ├── .gitkeep │ │ │ │ └── DINPro-Medium.otf │ │ ├── openFrameworks-Info.plist │ │ ├── src │ │ │ ├── main.cpp │ │ │ ├── testApp.cpp │ │ │ └── testApp.h │ │ └── tsps_peekaboo.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── tsps_peekaboo Debug.xcscheme │ │ │ └── tsps_peekaboo Release.xcscheme │ └── Example_03_tsps_trails │ │ ├── Project.xcconfig │ │ ├── addons.make │ │ ├── bin │ │ └── data │ │ │ └── .gitkeep │ │ ├── openFrameworks-Info.plist │ │ ├── src │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h │ │ └── tsps_trails.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ └── xcschemes │ │ ├── tsps_trails Debug.xcscheme │ │ └── tsps_trails Release.xcscheme └── README.md ├── Week_05 ├── README.md └── projectionMappingExamples │ ├── ofxMapamok_basic │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ ├── mapamok.xml │ │ │ ├── model.dae │ │ │ ├── shader.frag │ │ │ ├── shader.vert │ │ │ └── video.xml │ ├── example_canvas.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── example_canvas Debug.xcscheme │ │ │ └── example_canvas Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h │ ├── ofxMapamok_spacebrew │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ ├── LABgeometriconeface7 │ │ │ └── texture.png │ │ │ ├── mapamok.xml │ │ │ ├── model.dae │ │ │ ├── shader.frag │ │ │ ├── shader.vert │ │ │ └── video.xml │ ├── ofxMapamok_spacebrew.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── ofxMapamok_spacebrew Debug.xcscheme │ │ │ └── ofxMapamok_spacebrew Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ │ ├── addons │ │ └── ofxGui │ │ │ └── src │ │ │ ├── ofOscParameter.h │ │ │ ├── ofParameter.h │ │ │ ├── ofxBaseGui.cpp │ │ │ ├── ofxBaseGui.h │ │ │ ├── ofxButton.cpp │ │ │ ├── ofxButton.h │ │ │ ├── ofxGui.h │ │ │ ├── ofxLabel.cpp │ │ │ ├── ofxLabel.h │ │ │ ├── ofxPanel.cpp │ │ │ ├── ofxPanel.h │ │ │ ├── ofxSlider.cpp │ │ │ ├── ofxSlider.h │ │ │ ├── ofxToggle.cpp │ │ │ └── ofxToggle.h │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h │ ├── ofxSPM_basic │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ │ └── data │ │ │ └── .gitkeep │ ├── ofxSPM_basic.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── ofxSPM_basic Debug.xcscheme │ │ │ └── ofxSPM_basic Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h │ └── ofxSPM_box │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ ├── data │ │ └── .gitkeep │ ├── mapsettings0.txt │ ├── mapsettings1.txt │ └── mapsettings2.txt │ ├── ofxSPM_box.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── ofxSPM_box Debug.xcscheme │ │ └── ofxSPM_box Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ ├── main.cpp │ ├── testApp.cpp │ └── testApp.h ├── Week_08 ├── README.md ├── node-spacebrew │ ├── README.md │ ├── app.js │ ├── package.json │ ├── public │ │ └── stylesheets │ │ │ └── style.css │ ├── routes │ │ ├── index.js │ │ └── user.js │ ├── sb-1.0.3.js │ └── views │ │ └── index.ejs ├── spacebrew-scrape │ ├── .gitignore │ ├── README.md │ ├── spacebrew-casual.py │ └── spacebrewInterface │ │ ├── __init__.py │ │ └── spacebrew.py ├── spacebrew-scrape2 │ ├── .gitignore │ ├── README.md │ ├── spacebrew-casual.py │ ├── spacebrewInterface │ │ ├── __init__.py │ │ └── spacebrew.py │ ├── untitled.sublime-project │ └── untitled.sublime-workspace └── spacebrew-twitter │ ├── README.md │ ├── app.js │ ├── package.json │ ├── public │ └── stylesheets │ │ └── style.css │ ├── routes │ ├── index.js │ └── user.js │ ├── sb-1.0.3.js │ └── views │ └── index.ejs ├── Week_09 ├── itunes-control │ ├── README.md │ ├── app.js │ └── package.json ├── simple-say │ ├── README.md │ ├── app.js │ └── package.json ├── twilio-test │ ├── README.md │ ├── app.js │ ├── package.json │ ├── public │ │ └── stylesheets │ │ │ └── style.css │ ├── response.xml │ ├── sb-1.0.3.js │ ├── twilio-test.sublime-project │ ├── twilio-test.sublime-workspace │ └── views │ │ └── index.ejs └── youtube-upload │ ├── app.js │ └── package.json └── Week_10 ├── Week_10_OF ├── SpacebrewText │ ├── Project.xcconfig │ ├── SpacebrewText.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── SpacebrewText Debug.xcscheme │ │ │ └── SpacebrewText Release.xcscheme │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ ├── Serif Neu.ttf │ │ │ └── planet_kosmos.ttf │ ├── openFrameworks-Info.plist │ └── src │ │ ├── main.cpp │ │ ├── ofxExtrudedText.cpp │ │ ├── ofxExtrudedText.h │ │ ├── testApp.cpp │ │ └── testApp.h ├── extrude01 │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ └── planet_kosmos.ttf │ ├── extrude01.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── extrude Debug.xcscheme │ │ │ └── extrude Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ │ ├── Letter.cpp │ │ ├── Letter.h │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h ├── extrude02 │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ └── planet_kosmos.ttf │ ├── extrude02.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── extrude Debug.xcscheme │ │ │ └── extrude Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ │ ├── Letter.cpp │ │ ├── Letter.h │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h ├── extrude03 │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ └── planet_kosmos.ttf │ ├── extrude03.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── extrude Debug.xcscheme │ │ │ └── extrude Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ │ ├── Letter.cpp │ │ ├── Letter.h │ │ ├── main.cpp │ │ ├── testApp.cpp │ │ └── testApp.h └── font │ ├── Project.xcconfig │ ├── addons.make │ ├── bin │ └── data │ │ ├── .gitkeep │ │ └── planet_kosmos.ttf │ ├── font.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ ├── extrude Debug.xcscheme │ │ └── extrude Release.xcscheme │ ├── openFrameworks-Info.plist │ └── src │ ├── main.cpp │ ├── testApp.cpp │ └── testApp.h ├── sb-example ├── app.js └── package.json ├── sb-tweeter ├── app.js └── package.json └── viner ├── app.js └── vine.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | Icon 5 | application.* 6 | 7 | # XCode noise + OS X apps 8 | *.app 9 | DerivedData 10 | build 11 | xcuserdata 12 | *.xcworkspace 13 | 14 | # Thumbnails 15 | ._* 16 | 17 | # Files that might appear on external disk 18 | .Spotlight-V100 19 | .Trashes 20 | 21 | # Compiled Object files 22 | *.slo 23 | *.lo 24 | *.o 25 | 26 | # Compiled Dynamic libraries 27 | *.so 28 | *.dylib 29 | 30 | # Compiled Static libraries 31 | *.lai 32 | *.la 33 | *.a 34 | 35 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ____ __ ___ __ 2 | /\ _`\ /\ \__ __ /\_ \ /'\_/`\ /\ \ __ 3 | \ \,\L\_\ _____ __ \ \ ,_\/\_\ __ \//\ \ /\ \ __ \_\ \/\_\ __ 4 | \/_\__ \ /\ '__`\ /'__`\ \ \ \/\/\ \ /'__`\ \ \ \ \ \ \__\ \ /'__`\ /'_` \/\ \ /'__`\ 5 | /\ \L\ \ \ \L\ \/\ \L\.\_\ \ \_\ \ \/\ \L\.\_ \_\ \_ \ \ \_/\ \/\ __//\ \L\ \ \ \/\ \L\.\_ 6 | \ `\____\ \ ,__/\ \__/.\_\\ \__\\ \_\ \__/.\_\/\____\ \ \_\\ \_\ \____\ \___,_\ \_\ \__/.\_\ 7 | \/_____/\ \ \/ \/__/\/_/ \/__/ \/_/\/__/\/_/\/____/ \/_/ \/_/\/____/\/__,_ /\/_/\/__/\/_/ 8 | \ \_\ 9 | \/_/ 10 | 11 | 12 | * Brett Renfer 13 | * Jeff Crouse 14 | * [syllbus](http://itp.nyu.edu/syllabus/SpatialMedia-Spring2013.pdf) -------------------------------------------------------------------------------- /Week_01/Code/GroupPrinter/README.md: -------------------------------------------------------------------------------- 1 | # Group Printer 2 | 3 | 4 | 5 | 6 | ### Description 7 | 8 | This code is meant to be run on a Arduino Uno with an Ethernet shield connected to a [thermal printer](http://www.adafruit.com/products/597). 9 | 10 | ![Mini Thermal Printer](http://www.adafruit.com/images/medium/thermalprinter_MED.jpg) 11 | 12 | It accepts string (from Spacebrew) that look like this: 13 | 14 | One;Two;Three 15 | 16 | and prints 17 | 18 | ![receipt](http://4u.jeffcrouse.info/spatialmedia/receipt.png) 19 | 20 | 21 | ### Spacebrew info 22 | 23 | - **Name**: GroupPrinter 24 | - **Server**: sandbox.spacebrew.cc 25 | - **Subscriptions**: 26 | - Printer 27 | - **Publishers** 28 | - none 29 | 30 | 31 | ### Setup 32 | 33 | - green = 5 34 | - yellow = 6 35 | - red = gnd 36 | 37 | 38 | 39 | ### Required Libraries 40 | 41 | Put into ~/Documents/Arduino/libraries 42 | 43 | - Adafruit_Thermal: [Adafruit-Thermal-Printer-Library](https://github.com/adafruit/Adafruit-Thermal-Printer-Library) 44 | - WebsocketClient: [ArduinoWebsocketClient](https://github.com/labatrockwell/ArduinoWebsocketClient) 45 | - Spacebrew: [spacebrew-arduino-library](https://github.com/labatrockwell/spacebrew-arduino-library) -------------------------------------------------------------------------------- /Week_01/Code/PinwheelProcessing/PinwheelProcessing.pde: -------------------------------------------------------------------------------- 1 | import spacebrew.*; 2 | 3 | String server="localhost"; 4 | String name="Pinwheel"; 5 | String description ="This sketch sends a boolean true when someone is blowing into the pinwheel, and a false when someone stops"; 6 | import processing.serial.*; 7 | 8 | Serial myPort; // Create object from Serial class 9 | int serialState = 0; 10 | int lastRead = 0; 11 | 12 | Spacebrew spacebrew; 13 | 14 | boolean bReading = false; 15 | 16 | void setup() { 17 | frameRate(240); 18 | size(600, 400); 19 | 20 | // load from spacebrew.txt 21 | String spacebrewConfig[] = loadStrings("spacebrew.txt"); 22 | if ( spacebrewConfig != null && spacebrewConfig.length > 0 ){ 23 | server = spacebrewConfig[0]; 24 | } 25 | 26 | println("connect "+server); 27 | 28 | spacebrew = new Spacebrew( this ); 29 | 30 | // add each thing you publish and subscribe to 31 | spacebrew.addPublish( "pinwheel", false ); 32 | 33 | // connect! 34 | spacebrew.connect("ws://"+server+":9000", name, description ); 35 | 36 | // connect to serial 37 | println(Serial.list()); 38 | myPort = new Serial(this, Serial.list()[4], 57600); 39 | //myPort.bufferUntil('\n'); 40 | } 41 | 42 | void draw() { 43 | background( 255 ); 44 | fill(20); 45 | textSize(30); 46 | if ( bReading ){ 47 | text("Spinning!", 20, 320); 48 | } else { 49 | text("Spin the pinwheel!", 20, 320); 50 | } 51 | 52 | if(myPort.available() > 0) { 53 | serialState = myPort.read(); 54 | if (!bReading){ 55 | spacebrew.send("pinwheel", true); 56 | bReading = true; 57 | println("spin"); 58 | } 59 | lastRead = millis(); 60 | } 61 | 62 | // haven't gotten a read in a 100 millis? 63 | if ( millis() - lastRead > 100 && bReading){ 64 | println("stopped"); 65 | spacebrew.send("pinwheel", false); 66 | bReading = false; 67 | } 68 | } 69 | 70 | void onRangeMessage( String name, int value ){ 71 | println("got int message "+name +" : "+ value); 72 | } 73 | 74 | void onBooleanMessage( String name, boolean value ){ 75 | println("got bool message "+name +" : "+ value); 76 | } 77 | 78 | void onStringMessage( String name, String value ){ 79 | println("got string message "+name +" : "+ value); 80 | } 81 | -------------------------------------------------------------------------------- /Week_01/Code/PinwheelProcessing/data/spacebrew.txt: -------------------------------------------------------------------------------- 1 | localhost -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/README.md: -------------------------------------------------------------------------------- 1 | # Group Randomizer 2 | 3 | 4 | 5 | 6 | ### Description 7 | 8 | This sketch allows us to randomly create groups + assign them to something. It expects 2 text files in the data folder: 9 | - students.txt: newline separated list of students preceded with a group size (the first line) 10 | - assign.txt: newline separated list of what to assign 11 | - spacebrew.txt: (optional) location of spacebrew server (e.g. localhost or sandbox.spacebrew.cc) 12 | 13 | It accepts a boolean switch to start and stop randomization and sends out groups when finished separated by a ";" (see receipt printer sketch) 14 | 15 | ### Spacebrew info 16 | 17 | - **Name**: Randomizer 18 | - **Server**: sandbox.spacebrew.cc 19 | - **Subscriptions**: 20 | - randomize 21 | - **Publishers** 22 | - selectedGroup 23 | 24 | 25 | ### Setup 26 | Copy this whole folder (Randomizer_Output_OF) into openFrameworks/apps/SpatialMedia 27 | 28 | ### Required Libraries 29 | 30 | Clone into openFrameworks/addons 31 | 32 | * Spacebrew: 33 | * [ofxSpacebrew](https://github.com/labatrockwell/ofxSpacebrew) 34 | * [ofxLibwebsockets](https://github.com/labatrockwell/ofxLibwebsockets) -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/Randomizer.xcodeproj/xcshareddata/xcschemes/Randomizer Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/Randomizer.xcodeproj/xcshareddata/xcschemes/Randomizer Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/addons.make: -------------------------------------------------------------------------------- 1 | ofxXmlSettings 2 | ofxLibwebsockets 3 | ofxSpacebrew 4 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_01/Code/Randomizer_Output_OF/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/bin/data/Arial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_01/Code/Randomizer_Output_OF/bin/data/Arial.ttf -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/bin/data/assign.txt: -------------------------------------------------------------------------------- 1 | Ace Hotel Lobby 2 | Uniqlo 5th Ave 3 | Museum of Natural History Lobby / Atrium 4 | Staten Island Ferry Terminal 5 | Grand Central - Main hall 6 | WTC Memorial 7 | High Line Park 8 | Brooklyn superhero supply 9 | Williamsburg bridge 10 | B & H 11 | Strand Books 1st floor 12 | Whole Foods Union Square 1st Floor 13 | General Assembly 14 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/bin/data/spacebrew.txt: -------------------------------------------------------------------------------- 1 | sandbox.spacebrew.cc -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/bin/data/students.txt: -------------------------------------------------------------------------------- 1 | 2 2 | Ryan Bartley 3 | Shilpan Bhagat 4 | Allison Burtch 5 | John Capogna 6 | Chiu-Hao Chen 7 | Carl Jamilkowski 8 | Ge Ma 9 | Ju Young Park 10 | Yuliya Parshina 11 | Zhenzhen Qi 12 | Tianran Qian 13 | Andrew Sigler 14 | Heather Velez 15 | Xinran Wang 16 | Fang-Yu Yang 17 | Omer Shapira -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/ContestantDisplay.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ContestantDisplay.cpp 3 | // Randomizer 4 | // 5 | // Created by BRenfer on 1/27/13. 6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #include "ContestantDisplay.h" 10 | 11 | ContestantDisplay::ContestantDisplay( string _font, int fontSize ){ 12 | smallFont.loadFont( _font, fontSize ); 13 | font.loadFont( _font, 70 ); 14 | dims.set( ofGetWidth()/2, ofGetHeight()/2, ofGetWidth() * 3/4, 160); 15 | alpha = 0; 16 | bActive = false; 17 | }; 18 | 19 | void ContestantDisplay::draw(){ 20 | if ( bActive && ofGetElapsedTimeMillis() - activated > activeDelay ){ 21 | alpha += 10; 22 | if ( alpha > 255 ){ 23 | alpha = 255; 24 | } 25 | } else { 26 | alpha *= .75; 27 | if ( alpha < 0 ) alpha = 0; 28 | } 29 | ofPushStyle();{ 30 | ofSetRectMode(OF_RECTMODE_CENTER); 31 | ofSetColor(0, alpha * .5); 32 | ofRect(dims.x, dims.y, ofGetWidth(), ofGetHeight()); 33 | ofSetColor(fillColor, alpha); 34 | ofRect(dims); 35 | ofSetColor(0, alpha); 36 | 37 | float fontY = (dims.y - dims.height/2) + 10 + smallFont.getSize(); 38 | smallFont.drawString("Next Up:", dims.x - dims.width/2 + 10, fontY ); 39 | fontY += font.getSize() + 20; 40 | font.drawString(current, dims.x - dims.width/2 + 10, fontY ); 41 | }; ofPopStyle(); 42 | }; 43 | 44 | void ContestantDisplay::activate( string _current, int delay ){ 45 | activated = ofGetElapsedTimeMillis(); 46 | activeDelay = delay; 47 | bActive = true; 48 | current = _current; 49 | } 50 | 51 | void ContestantDisplay::deactivate(){ 52 | bActive = false; 53 | } 54 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/ContestantDisplay.h: -------------------------------------------------------------------------------- 1 | // 2 | // ContestantDisplay.h 3 | // Randomizer 4 | // 5 | // Created by BRenfer on 1/27/13. 6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #pragma once 10 | 11 | #include "ofMain.h" 12 | 13 | class ContestantDisplay 14 | { 15 | public: 16 | ofColor fillColor; 17 | float alpha; 18 | string current; 19 | ofTrueTypeFont font, smallFont; 20 | ofRectangle dims; 21 | 22 | ContestantDisplay(){}; 23 | ContestantDisplay( string _font, int fontSize ); 24 | void draw(); 25 | void activate( string _current, int delay = 0 ); 26 | void deactivate(); 27 | 28 | private: 29 | 30 | int activeDelay, activated; 31 | bool bActive; 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/Group.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Group.cpp 3 | // Randomizer 4 | // 5 | // Created by BRenfer on 1/20/13. 6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #include "Group.h" 10 | 11 | 12 | Group::Group( int _x, int _y, int _w, int _h ){ 13 | studentOne = ""; 14 | studentTwo = ""; 15 | assignment = ""; 16 | studentOneSelected = false; 17 | studentTwoSelected = false; 18 | 19 | drawX = _x; 20 | drawY = _y; 21 | w = _w; 22 | h = _h; 23 | 24 | font = NULL; 25 | } 26 | 27 | void Group::setFont( ofTrueTypeFont * _font ){ 28 | font = _font; 29 | } 30 | 31 | void Group::draw(){ 32 | int x = drawX; 33 | int y = drawY; 34 | 35 | ofSetColor(10,50,11); 36 | font->drawString( assignment, x,y); 37 | y += 10; 38 | 39 | if ( studentOneSelected ) ofSetColor(255); 40 | else ofSetColor(130,159,180); 41 | ofRect(x,y,w,h/2); 42 | 43 | ofSetColor(0); 44 | font->drawString(studentOne, x + 4, y+font->getSize()+ 4); 45 | 46 | y += h/2; 47 | 48 | if ( studentTwoSelected ) ofSetColor(255); 49 | else ofSetColor(45,86,117); 50 | ofRect(x,y,w,h/2); 51 | 52 | ofSetColor(0); 53 | font->drawString(studentTwo, x+ 4, y+font->getSize()+ 4); 54 | }; -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/Group.h: -------------------------------------------------------------------------------- 1 | // 2 | // Group.h 3 | // Randomizer 4 | // 5 | // Created by BRenfer on 1/20/13. 6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #pragma once 10 | 11 | #include "ofMain.h" 12 | 13 | class Group 14 | { 15 | 16 | private: 17 | int drawX,drawY,w,h; 18 | ofTrueTypeFont * font; 19 | 20 | public: 21 | 22 | string studentOne; 23 | string studentTwo; 24 | string assignment; 25 | bool studentOneSelected; 26 | bool studentTwoSelected; 27 | 28 | Group( int _x, int _y, int _w, int _h ); 29 | void setFont( ofTrueTypeFont * font ); 30 | void draw(); 31 | }; 32 | 33 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/Lights.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Lights.cpp 3 | // Randomizer 4 | // 5 | // Created by BRenfer on 1/20/13. 6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #include "Lights.h" 10 | 11 | Lights::Lights(){ 12 | } 13 | 14 | Lights::Lights( int x, int y, int w, int h, int r){ 15 | bActive = false; 16 | whichLight = 1; 17 | ofSetCircleResolution(100); 18 | 19 | int index=0; 20 | // top 21 | for (int i=0; i < 10; i++ ){ 22 | ofVec2f p = ofVec2f(ofLerp( (float) x + r*2, (float)x + r + (w-r),(float)i/10.0f), y); 23 | points.push_back(p); 24 | index++; 25 | } 26 | 27 | // right 28 | for (int i=0; i < 8; i++ ){ 29 | ofVec2f p = ofVec2f(x + w, ofLerp( (float) y + r*2, (float) y + r + (h-r),(float)i/8.0f) ); 30 | points.push_back(p); 31 | index++; 32 | } 33 | 34 | // bottom 35 | for (int i=0; i < 11; i++ ){ 36 | ofVec2f p = ofVec2f(ofLerp( (float)x + r + (w-r), (float) x + r*2, (float)i/10.0f), y + h); 37 | points.push_back(p); 38 | index++; 39 | } 40 | 41 | // left 42 | for (int i=0; i < 8; i++ ){ 43 | ofVec2f p = ofVec2f(x, ofLerp((float) y + r + (h-r), (float) y + r *2, (float)i/8.0f)); 44 | points.push_back(p); 45 | index++; 46 | } 47 | } 48 | 49 | void Lights::draw(){ 50 | // draw lights 51 | for (int i=0; i= 4 ) whichLight = 1; 61 | } 62 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/Lights.h: -------------------------------------------------------------------------------- 1 | // 2 | // Lights.h 3 | // Randomizer 4 | // 5 | // Created by BRenfer on 1/20/13. 6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #pragma once 10 | #include "ofMain.h" 11 | 12 | class Lights 13 | { 14 | private: 15 | vector points; // vector of "lights" 16 | float whichLight; // which lights are lighting up 17 | 18 | public: 19 | bool bActive; 20 | 21 | Lights(); 22 | Lights( int x, int y, int w, int h, int r); 23 | void draw(); 24 | }; 25 | 26 | 27 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_OF/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | // include custom classes 6 | #include "ContestantDisplay.h" 7 | #include "Group.h" 8 | #include "Lights.h" 9 | 10 | // include ofxSpacebrew 11 | #include "ofxSpacebrew.h" 12 | 13 | class testApp : public ofBaseApp{ 14 | 15 | public: 16 | void setup(); 17 | void update(); 18 | void draw(); 19 | 20 | // catcher for Spacebrew events 21 | void onMessage( Spacebrew::Message & m ); 22 | 23 | void randomize(); 24 | void drawBackground(); 25 | string selectContestant(); 26 | 27 | Spacebrew::Connection spacebrewConnection; 28 | 29 | // array of students 30 | vector students; 31 | vector groups; 32 | 33 | bool bGroupsPicked; 34 | int groupSize; 35 | int numGroups = 0; 36 | 37 | // array of assignments 38 | vector assignments; 39 | 40 | // "up next" 41 | ContestantDisplay contestant; 42 | 43 | // visual stuff 44 | ofTrueTypeFont arial; 45 | 46 | int fontSize; 47 | int squareWidth; 48 | int squareHeight; 49 | int padding; 50 | 51 | // randomize! 52 | bool bRandomizing; 53 | int currentIndex; 54 | float floatIndex; 55 | float speed; 56 | ofVec2f pos; 57 | Lights lights; 58 | 59 | void mousePressed(int x, int y, int button); 60 | void mouseReleased(int x, int y, int button); 61 | 62 | // default OF stuff 63 | void keyPressed (int key); 64 | void keyReleased(int key); 65 | void mouseMoved(int x, int y ); 66 | void mouseDragged(int x, int y, int button); 67 | void windowResized(int w, int h); 68 | void dragEvent(ofDragInfo dragInfo); 69 | void gotMessage(ofMessage msg); 70 | 71 | // helper shim for quickly porting from P5 72 | static vector loadStrings( string file ){ 73 | static vector ret; 74 | ret.clear(); 75 | 76 | ofBuffer temp = ofFile( file ).readToBuffer(); 77 | while ( !temp.isLastLine() ){ 78 | ret.push_back( temp.getNextLine() ); 79 | cout< 255 ){ 23 | alpha = 255; 24 | } 25 | } else { 26 | alpha *= .75; 27 | if ( alpha < 0 ) alpha = 0; 28 | } 29 | rectMode(CENTER); 30 | fill(0, alpha * .5); 31 | rect(pos.x, pos.y, width, height); 32 | fill(fillColor, alpha); 33 | rect(pos.x, pos.y, dims.x, dims.y); 34 | rectMode(CORNER); 35 | fill(0, alpha); 36 | textFont(smallFont); 37 | float fontY = (pos.y - dims.y/2) + 10 + smallFont.getSize(); 38 | text("Next Up:", pos.x - dims.x/2 + 10, fontY ); 39 | fontY += font.getSize(); 40 | textFont(font); 41 | text(current, pos.x - dims.x/2 + 10, fontY ); 42 | fill(255); 43 | }; 44 | 45 | void activate( String _current ){ 46 | bActive = true; 47 | current = _current; 48 | } 49 | 50 | void deactivate(){ 51 | bActive = false; 52 | } 53 | 54 | }; 55 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_P5/Group.pde: -------------------------------------------------------------------------------- 1 | class Group { 2 | 3 | String studentOne = ""; 4 | String studentTwo = ""; 5 | String assignment = ""; 6 | boolean studentOneSelected = false; 7 | boolean studentTwoSelected = false; 8 | 9 | private int drawX,drawY,w,h; 10 | 11 | Group( int _x, int _y, int _w, int _h ){ 12 | drawX = _x; 13 | drawY = _y; 14 | w = _w; 15 | h = _h; 16 | } 17 | 18 | void draw(){ 19 | int x = drawX; 20 | int y = drawY; 21 | 22 | fill(10,50,11); 23 | text( assignment, x,y); 24 | y += 10; 25 | 26 | if ( studentOneSelected ) fill(255); 27 | else fill(130,159,180); 28 | rect(x,y,w,h/2); 29 | 30 | fill(0); 31 | text(studentOne, x + 4, y+fontSize+ 2); 32 | 33 | y += h/2; 34 | 35 | if ( studentTwoSelected ) fill(255); 36 | else fill(45,86,117); 37 | rect(x,y,w,h/2); 38 | 39 | fill(0); 40 | text(studentTwo, x+ 4, y+fontSize+ 2); 41 | }; 42 | 43 | }; 44 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_P5/Lights.pde: -------------------------------------------------------------------------------- 1 | class Lights { 2 | private PVector points[]; // vector of "lights" 3 | private float whichLight = 1; // which lights are lighting up 4 | boolean bActive = false; 5 | 6 | Lights( int x, int y, int w, int h, int r){ 7 | points = new PVector[37]; 8 | 9 | int index=0; 10 | // top 11 | for (int i=0; i < 10; i++ ){ 12 | PVector p = new PVector(lerp( (float) x + r*2, (float)x + r + (w-r),(float)i/10.0f), y); 13 | points[index] = p; 14 | index++; 15 | } 16 | 17 | // right 18 | for (int i=0; i < 8; i++ ){ 19 | PVector p = new PVector(x + w, lerp( (float) y + r*2, (float) y + r + (h-r),(float)i/8.0f) ); 20 | points[index] = p; 21 | index++; 22 | } 23 | 24 | // bottom 25 | for (int i=0; i < 11; i++ ){ 26 | PVector p = new PVector(lerp( (float)x + r + (w-r), (float) x + r*2, (float)i/10.0f), y + h); 27 | points[index] = p; 28 | index++; 29 | } 30 | 31 | // left 32 | for (int i=0; i < 8; i++ ){ 33 | PVector p = new PVector(x, lerp((float) y + r + (h-r), (float) y + r *2, (float)i/8.0f)); 34 | points[index] = p; 35 | index++; 36 | } 37 | } 38 | 39 | void draw(){ 40 | // draw lights 41 | for (int i=0; i= 4 ) whichLight = 1; 51 | } 52 | }; 53 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_P5/README.md: -------------------------------------------------------------------------------- 1 | # Group Randomizer 2 | 3 | 4 | 5 | 6 | ### Description 7 | 8 | This sketch allows us to randomly create groups + assign them to something. It expects 2 text files in the data folder: 9 | - students.txt: newline separated list of students preceded with a group size (the first line) 10 | - assign.txt: newline separated list of what to assign 11 | - spacebrew.txt: (optional) location of spacebrew server (e.g. localhost or sandbox.spacebrew.cc) 12 | 13 | It accepts a boolean switch to start and stop randomization and sends out groups when finished separated by a ";" (see receipt printer sketch) 14 | 15 | ### Spacebrew info 16 | 17 | - **Name**: Randomizer 18 | - **Server**: sandbox.spacebrew.cc 19 | - **Subscriptions**: 20 | - randomize 21 | - **Publishers** 22 | - selectedGroup 23 | 24 | 25 | ### Required Libraries 26 | 27 | Put into ~/Documents/Processing/libraries 28 | 29 | - Spacebrew: [spacebrew-processing-library](https://github.com/labatrockwell/spacebrew-processing-library.git) -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_P5/data/assign.txt: -------------------------------------------------------------------------------- 1 | Ace Hotel Lobby 2 | Uniqlo 5th Ave 3 | Museum of Natural History Lobby / Atrium 4 | Staten Island Ferry Terminal 5 | Grand Central - Main hall 6 | WTC Memorial 7 | High Line Park 8 | Brooklyn superhero supply 9 | Williamsburg bridge 10 | B & H 11 | Strand Books 1st floor 12 | Whole Foods Union Square 1st Floor 13 | General Assembly 14 | -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_P5/data/spacebrew.txt: -------------------------------------------------------------------------------- 1 | localhost -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_P5/data/students.txt: -------------------------------------------------------------------------------- 1 | 2 2 | Ryan Bartley 3 | Shilpan Bhagat 4 | Allison Burtch 5 | John Capogna 6 | Chiu-Hao Chen 7 | Carl Jamilkowski 8 | Ge Ma 9 | Ju Young Park 10 | Yuliya Parshina 11 | Zhenzhen Qi 12 | Tianran Qian 13 | Andrew Sigler 14 | Heather Velez 15 | Xinran Wang 16 | Fang-Yu Yang 17 | Omer Shapira -------------------------------------------------------------------------------- /Week_01/Code/Randomizer_Output_P5/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /Week_01/Code/SBStringSender/SBStringSender.pde: -------------------------------------------------------------------------------- 1 | import spacebrew.*; 2 | 3 | String server="sandbox.spacebrew.cc"; 4 | String name="givemeabettername"; 5 | String description ="This is an example client which .... It also listens to..."; 6 | 7 | Spacebrew c; 8 | 9 | void setup() { 10 | size(600, 400); 11 | 12 | c = new Spacebrew( this ); 13 | 14 | // add each thing you publish to 15 | c.addPublish( "sendGroup", "foo" ); 16 | 17 | // add each thing you subscribe to 18 | // spacebrewConnection.addSubscribe( "color", "range" ); 19 | 20 | // connect! 21 | c.connect("ws://"+server+":9000", name, description ); 22 | 23 | } 24 | 25 | void draw() { 26 | 27 | } 28 | 29 | void mousePressed() { 30 | c.send( "sendGroup", "one;two;three"); 31 | } 32 | 33 | 34 | 35 | void onRangeMessage( String name, int value ){ 36 | println("got int message "+name +" : "+ value); 37 | // // check name by using equals 38 | // if (name.equals("color") == true) { 39 | // currentColor = value; 40 | // } 41 | } 42 | 43 | void onBooleanMessage( String name, boolean value ){ 44 | println("got bool message "+name +" : "+ value); 45 | } 46 | 47 | void onStringMessage( String name, String value ){ 48 | println("got string message "+name +" : "+ value); 49 | } 50 | -------------------------------------------------------------------------------- /Week_02/Code/FlashScreen/FlashScreen.pde: -------------------------------------------------------------------------------- 1 | import spacebrew.*; 2 | 3 | String server="sandbox.spacebrew.cc"; 4 | String name="FlashScreen"; 5 | String description ="This example flashes the screen white after a random delay when it receives any message."; 6 | 7 | Spacebrew spacebrewConnection; 8 | 9 | int messageReceived = 0; 10 | int delay = 0; 11 | boolean bNeedToFlash = false; 12 | 13 | void setup() { 14 | size(1920, 1080); 15 | 16 | spacebrewConnection = new Spacebrew( this ); 17 | 18 | // add each thing you subscribe to 19 | spacebrewConnection.addSubscribe( "flash", "boolean" ); 20 | 21 | // connect! 22 | spacebrewConnection.connect("ws://"+server+":9000", name, description ); 23 | 24 | } 25 | 26 | void draw() { 27 | background(0); 28 | if ( millis() - messageReceived > delay && bNeedToFlash ){ 29 | background(255); 30 | bNeedToFlash = false; 31 | } 32 | } 33 | 34 | void onBooleanMessage( String name, boolean value ){ 35 | bNeedToFlash = true; 36 | messageReceived = millis(); 37 | delay = (int) random(0,1000); 38 | } 39 | -------------------------------------------------------------------------------- /Week_02/Code/FlashScreenJS/css/reset.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | width: 100%; 3 | height: 100%; 4 | border: 0px; 5 | padding: 0px; 6 | margin: 0px; 7 | background-color: gray; 8 | overflow:hidden; 9 | font-family: Helvetica; 10 | } 11 | html, body { 12 | /*cursor:none;*/ 13 | } -------------------------------------------------------------------------------- /Week_02/Code/FlashScreenJS/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color:#000; 3 | } -------------------------------------------------------------------------------- /Week_02/Code/FlashScreenJS/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Spacebrew Flashing Screen 5 | 6 | 7 | 8 | 9 | 10 | 11 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /Week_02/Code/FlashScreenJS/server.py: -------------------------------------------------------------------------------- 1 | """ 2 | Serves files out of its current directory. 3 | Doesn't handle POST requests. 4 | """ 5 | import SocketServer 6 | import SimpleHTTPServer 7 | 8 | PORT = 8000 9 | 10 | #sketch 11 | numClients=0 12 | 13 | class CustomHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): 14 | 15 | def __init__(self, request, client_address, server): 16 | SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self, request, client_address, server) 17 | 18 | def do_GET(self): 19 | if self.path=='/': 20 | global numClients 21 | numClients+=1 22 | print numClients 23 | self.send_response(302) 24 | self.send_header("Location", '/index.html?name=Flash'+str(numClients)) 25 | self.end_headers() 26 | return 27 | else: 28 | #serve files, and directory listings by following self.path from 29 | #current working directory 30 | SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) 31 | 32 | httpd = SocketServer.ThreadingTCPServer(('localhost', PORT),CustomHandler) 33 | 34 | print "serving at port", PORT 35 | httpd.serve_forever() -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_01_tspsSpacebrew/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_01_tspsSpacebrew/addons.make: -------------------------------------------------------------------------------- 1 | ofxLibwebsockets 2 | ofxSpacebrew 3 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_01_tspsSpacebrew/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_04/Code_Completed/Example_01_tspsSpacebrew/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_01_tspsSpacebrew/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_01_tspsSpacebrew/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_01_tspsSpacebrew/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | // create spacebrew connection + say you're listening to a range called "count" 6 | connection.connect(); 7 | connection.addSubscribe("count", "range"); 8 | 9 | // tell spacebrew you are listening to this connection 10 | Spacebrew::addListener(this, connection); 11 | 12 | countRange = 0; 13 | 14 | // set the background to black and make the circles high resolution 15 | ofBackground(0); 16 | ofSetCircleResolution(30); 17 | } 18 | 19 | //-------------------------------------------------------------- 20 | void testApp::update(){ 21 | 22 | } 23 | 24 | //-------------------------------------------------------------- 25 | void testApp::draw(){ 26 | // draw circles based on count 27 | for ( int i=0; i 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_02_tsps_peekaboo/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_02_tsps_peekaboo/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | using namespace ofxTSPS; 4 | 5 | //-------------------------------------------------------------- 6 | void testApp::setup(){ 7 | ofBackground(0); 8 | 9 | // state state to "i've never seen a face" 10 | state = NEVER_SEEN; 11 | 12 | // setup TSPS receiver 13 | tspsReceiver.connect(12000); 14 | 15 | // load an amazing font 16 | font.loadFont("DINPro-Medium.otf", 30); 17 | ofSetRectMode(OF_RECTMODE_CENTER); 18 | } 19 | 20 | //-------------------------------------------------------------- 21 | void testApp::update(){ 22 | // see if there any people with faces 23 | 24 | vector people = tspsReceiver.getPeople(); 25 | 26 | // store last state 27 | FaceState lastState = state; 28 | 29 | // reset state to "lost face" 30 | if ( state == SAW_FACE ) state = LOST_FACE; 31 | 32 | for (int i=0; ihasHaarRect() ){ 34 | state = SAW_FACE; 35 | 36 | // if this is a new face, randomize the background 37 | if ( lastState != SAW_FACE ){ 38 | background.set(ofRandom(255), ofRandom(255), ofRandom(255)); 39 | } 40 | } 41 | } 42 | 43 | } 44 | 45 | //-------------------------------------------------------------- 46 | void testApp::draw(){ 47 | 48 | string toDraw = ""; 49 | 50 | if ( state == SAW_FACE ){ 51 | ofBackground(background); 52 | toDraw = "PEEK-A-BOO!"; 53 | } else if ( state == LOST_FACE ){ 54 | ofBackground(0); 55 | toDraw = "Where'd you go?"; 56 | } else if ( state == NEVER_SEEN ){ 57 | ofBackground(0); 58 | toDraw = "I wish I had a friend ;("; 59 | } 60 | 61 | // centering fonts is kind of annoying 62 | ofRectangle bounds = font.getStringBoundingBox(toDraw, 0, 0); 63 | ofPoint position( ofGetWidth() / 2.0f, ofGetHeight() / 2.0f ); 64 | position.x -= bounds.width / 2.0f; 65 | 66 | font.drawString(toDraw, position.x, position.y); 67 | } -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_02_tsps_peekaboo/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | #include "ofxTSPSReceiver.h" 6 | 7 | // enumerate possible face states 8 | 9 | enum FaceState { 10 | NEVER_SEEN, 11 | SAW_FACE, 12 | LOST_FACE 13 | }; 14 | 15 | class testApp : public ofBaseApp{ 16 | 17 | public: 18 | void setup(); 19 | void update(); 20 | void draw(); 21 | 22 | // set up TSPS Receiver 23 | ofxTSPS::Receiver tspsReceiver; 24 | 25 | // declare current FaceState 26 | FaceState state; 27 | 28 | // load a font for displaying feedback 29 | ofTrueTypeFont font; 30 | 31 | // ofColor for randomizing background 32 | ofColor background; 33 | }; 34 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/addons.make: -------------------------------------------------------------------------------- 1 | ofxOsc 2 | ofxTSPSReceiver 3 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_04/Code_Completed/Example_03_tsps_trails/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | // connect to tsps 6 | tspsReceiver.connect(12000); 7 | 8 | // turn off ofBackgroundAuto so it's more like processing 9 | ofSetBackgroundAuto(false); 10 | ofBackground(0); 11 | 12 | // enable alpha blending for trail effect 13 | ofEnableAlphaBlending(); 14 | ofSetFrameRate(60); 15 | ofSetCircleResolution(60); 16 | } 17 | 18 | //-------------------------------------------------------------- 19 | void testApp::update(){ 20 | } 21 | 22 | //-------------------------------------------------------------- 23 | void testApp::draw(){ 24 | // clear background slightly 25 | ofEnableBlendMode(OF_BLENDMODE_MULTIPLY); 26 | ofSetColor(0,10); 27 | ofRect(0,0,ofGetWidth(), ofGetHeight()); 28 | ofEnableBlendMode(OF_BLENDMODE_ADD); 29 | 30 | // get TSPS people 31 | vector people = tspsReceiver.getPeople(); 32 | 33 | // loop through people 34 | for (int i=0; ipid ) == 0){ 39 | // if not, create a new color 40 | // make the alpha low for the blend mode 41 | colors[ people[i]->pid ] = ofColor( ofRandom(255), ofRandom(255), ofRandom(255), 50); 42 | } 43 | 44 | // set color from map 45 | ofSetColor( colors[ people[i]->pid ]); 46 | 47 | // values in tsps people are normalized, so fetch them and multiply them by window size 48 | ofPoint centroid = people[i]->centroid; 49 | centroid.x *= ofGetWidth(); 50 | centroid.y *= ofGetHeight(); 51 | 52 | float width = people[i]->boundingRect.width; 53 | width *= ofGetWidth() / 2.0f; 54 | 55 | // draw the circle! 56 | ofCircle(centroid, width); 57 | } 58 | } -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | // include ofxTSPSReceiver 6 | #include "ofxTSPSReceiver.h" 7 | 8 | class testApp : public ofBaseApp{ 9 | 10 | public: 11 | void setup(); 12 | void update(); 13 | void draw(); 14 | 15 | // create TSPS Receiver object 16 | ofxTSPS::Receiver tspsReceiver; 17 | 18 | // create map of people IDs (int) to colors (ofColor) 19 | map colors; 20 | }; 21 | -------------------------------------------------------------------------------- /Week_04/Code_Completed/Example_03_tsps_trails/tsps_trails.xcodeproj/xcshareddata/xcschemes/tsps_trails Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_01_tspsSpacebrew/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_01_tspsSpacebrew/addons.make: -------------------------------------------------------------------------------- 1 | ofxLibwebsockets 2 | ofxSpacebrew 3 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_01_tspsSpacebrew/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_04/Code_Empty/Example_01_tspsSpacebrew/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_01_tspsSpacebrew/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_01_tspsSpacebrew/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_01_tspsSpacebrew/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | // create spacebrew connection + say you're listening to a range called "count" 6 | 7 | // tell spacebrew class you are an app that's listening to this connection 8 | 9 | // initialize your count variable 10 | 11 | // set the background to black and make the circles high resolution 12 | } 13 | 14 | //-------------------------------------------------------------- 15 | void testApp::update(){ 16 | 17 | } 18 | 19 | //-------------------------------------------------------------- 20 | void testApp::draw(){ 21 | // draw circles based on count 22 | 23 | // draw text based on the count 24 | } 25 | 26 | //-------------------------------------------------------------- 27 | // Add Spacebrew message catcher here! 28 | // if message name is "count", set your count variable 29 | 30 | //-------------------------------------------------------------- 31 | void testApp::keyPressed(int key){} 32 | 33 | //-------------------------------------------------------------- 34 | void testApp::keyReleased(int key){} 35 | 36 | //-------------------------------------------------------------- 37 | void testApp::mouseMoved(int x, int y ){} 38 | 39 | //-------------------------------------------------------------- 40 | void testApp::mouseDragged(int x, int y, int button){} 41 | 42 | //-------------------------------------------------------------- 43 | void testApp::mousePressed(int x, int y, int button){} 44 | 45 | //-------------------------------------------------------------- 46 | void testApp::mouseReleased(int x, int y, int button){} 47 | 48 | //-------------------------------------------------------------- 49 | void testApp::windowResized(int w, int h){} 50 | 51 | //-------------------------------------------------------------- 52 | void testApp::gotMessage(ofMessage msg){} 53 | 54 | //-------------------------------------------------------------- 55 | void testApp::dragEvent(ofDragInfo dragInfo){} -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_01_tspsSpacebrew/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | // include spacebrew addon 6 | 7 | class testApp : public ofBaseApp{ 8 | 9 | public: 10 | void setup(); 11 | void update(); 12 | void draw(); 13 | 14 | void keyPressed (int key); 15 | void keyReleased(int key); 16 | void mouseMoved(int x, int y ); 17 | void mouseDragged(int x, int y, int button); 18 | void mousePressed(int x, int y, int button); 19 | void mouseReleased(int x, int y, int button); 20 | void windowResized(int w, int h); 21 | void dragEvent(ofDragInfo dragInfo); 22 | void gotMessage(ofMessage msg); 23 | 24 | // add spacebrew connection object + message catcher function 25 | 26 | // add variable that will be updated by spacebrew 27 | }; 28 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/addons.make: -------------------------------------------------------------------------------- 1 | ofxOsc 2 | ofxTSPSReceiver 3 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_04/Code_Empty/Example_02_tsps_peekaboo/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/bin/data/DINPro-Medium.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_04/Code_Empty/Example_02_tsps_peekaboo/bin/data/DINPro-Medium.otf -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | ofBackground(0); 6 | 7 | // state state to "i've never seen a face" 8 | 9 | // setup TSPS receiver 10 | 11 | // load an amazing font 12 | } 13 | 14 | //-------------------------------------------------------------- 15 | void testApp::update(){ 16 | // see if there any people with faces 17 | // first, get the vector of current people 18 | 19 | // store last state for reference below 20 | 21 | // reset state to "lost face" IF it's on "saw face" 22 | // why? makes it easy: if not set to "saw face" below, it will 23 | // automatically say "we lost the face!" 24 | 25 | // loop through people 26 | 27 | // if they have a haar rectangle, we saw a face! 28 | 29 | // if this is a new face, randomize the background variable 30 | } 31 | 32 | //-------------------------------------------------------------- 33 | void testApp::draw(){ 34 | // check what state we're in, and set a variable for what text 35 | // we want to draw 36 | 37 | // if we saw a face, set the background to our background variable, 38 | // and say "peek-a-boo!" 39 | 40 | // if we lost the face, say "where did you go??" 41 | 42 | // say something if we have never seen a face 43 | 44 | // figure out where we want to draw our text (centered seems good) 45 | 46 | // draw our text 47 | } -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_02_tsps_peekaboo/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | // include TSPS receiver 6 | 7 | // enumerate possible face states, including "never seen", "saw face", and "lost face" 8 | 9 | class testApp : public ofBaseApp{ 10 | 11 | public: 12 | void setup(); 13 | void update(); 14 | void draw(); 15 | 16 | // set up TSPS Receiver 17 | 18 | // declare current face state 19 | 20 | // load a font for displaying feedback 21 | 22 | // ofColor for randomizing background 23 | }; 24 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/addons.make: -------------------------------------------------------------------------------- 1 | ofxOsc 2 | ofxTSPSReceiver 3 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_04/Code_Empty/Example_03_tsps_trails/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | // connect to tsps 6 | 7 | // turn off ofBackgroundAuto so it's more like processing 8 | 9 | // enable alpha blending for trail effect, set framerate, and make circles high res 10 | } 11 | 12 | //-------------------------------------------------------------- 13 | void testApp::update(){ 14 | } 15 | 16 | //-------------------------------------------------------------- 17 | void testApp::draw(){ 18 | // clear background slightly 19 | 20 | // get TSPS people vector 21 | 22 | // loop through people 23 | 24 | // is there a color for this person's ID (pid)? 25 | // maps: check for a value with count( key ) 26 | // if map.count(key) == 0, it doesn't exist (yet) 27 | 28 | // if not, create a new color 29 | 30 | // set color from map 31 | 32 | // values in tsps people are normalized, so fetch them and multiply them by window size 33 | // use the centroid (center) and bounding box to draw 34 | 35 | // draw the circle! 36 | 37 | } -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | // include ofxTSPSReceiver 6 | 7 | class testApp : public ofBaseApp{ 8 | 9 | public: 10 | void setup(); 11 | void update(); 12 | void draw(); 13 | 14 | // create TSPS Receiver object 15 | 16 | // create std::map of people IDs (int) to colors (ofColor) 17 | // map reference: http://www.cplusplus.com/reference/map/map/ 18 | }; 19 | -------------------------------------------------------------------------------- /Week_04/Code_Empty/Example_03_tsps_trails/tsps_trails.xcodeproj/xcshareddata/xcschemes/tsps_trails Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Week_04/README.md: -------------------------------------------------------------------------------- 1 | Week 4 Examples 2 | =========== 3 | 4 | Setting up 5 | ---------- 6 | * Make sure you have the following repositories inside of openFrameworks/addons 7 | * [ofxSpacebrew](https://github.com/labatrockwell/ofxSpacebrew) 8 | * [ofxLibwebsockets](https://github.com/labatrockwell/ofxLibwebsockets) 9 | * [ofxCv](https://github.com/kylemcdonald/ofxCv) 10 | * [ofxTSPSReceiver](https://github.com/labatrockwell/ofxTSPSReceiver) 11 | * Download TSPS and Examples 12 | * [TSPS](http://sourceforge.net/projects/tsps/files/TSPS-1.3.4/tsps_mac_1.3.4.zip/download) 13 | * [Examples](http://sourceforge.net/projects/tsps/files/TSPS-1.3.4/examples_1.3.4.zip/download) 14 | * Create a Spatial Media folder inside openFrameworks/ 15 | * Copy the folders "Code_Completed" and "Code_Empty" into openFrameworks/SpatialMedia 16 | -------------------------------------------------------------------------------- /Week_05/README.md: -------------------------------------------------------------------------------- 1 | Week 5 Examples 2 | =========== 3 | 4 | Setting up 5 | ---------- 6 | * Make sure you have the following repositories inside of openFrameworks/addons 7 | * [ofxSpacebrew](https://github.com/labatrockwell/ofxSpacebrew) 8 | * [ofxLibwebsockets](https://github.com/labatrockwell/ofxLibwebsockets) 9 | * [ofxCv](https://github.com/kylemcdonald/ofxCv) 10 | * [ofxMapamok](https://github.com/natxopedreira/ofxMapamok) 11 | * [ofxSimpleProjectionMapper](https://github.com/robotconscience/ofxSimpleProjectionMapper.git) 12 | * Create a Spatial Media folder inside openFrameworks/ if you haven't already 13 | * Copy the folder "projectionMappingExamples" into openFrameworks/SpatialMedia 14 | 15 | The Examples 16 | ---------- 17 | * ofxSPM_basic 18 | * Very basic quad-warping projection mapping 19 | * Deceptively simple: this is often all you need to do! 20 | * Example shows how to draw to an ofFbo and render it to an ofxSimpleProjectionMapper instance 21 | * ofxSPM_box 22 | * This example shows how to set up multiple ofxSPM instances (and multiple FBOs) to map onto a primitive ( a box in this case) 23 | * ofxMapamok_basic 24 | * This is almost exactly the same as the example that comes with ofxMapamok (just a few more comments + on-screen help). 25 | * Allows you to map a video camera feed onto a Sketchup-generated model 26 | * ofxMapamok_spacebrew 27 | * This is a more advanced example that connects a gradient and 3D light to Spacebrew 28 | * This example also includes ofxGui, which is included with the dev version of openFrameworks 29 | * ofxGui allows you to create simple user interfaces to control variables 30 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/addons.make: -------------------------------------------------------------------------------- 1 | ofxAssimpModelLoader 2 | ofxOpenCv 3 | ofxXmlSettings 4 | ofxCv 5 | ofxMapamok 6 | ofxProCamToolkit 7 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_05/projectionMappingExamples/ofxMapamok_basic/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/bin/data/mapamok.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.000000000 4 | 0.000000000 5 | 1024.000000000 6 | 768.000000000 7 | 8 | 9 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/bin/data/shader.frag: -------------------------------------------------------------------------------- 1 | #define PI (3.1415926536) 2 | #define TWO_PI (6.2831853072) 3 | 4 | uniform sampler2DRect tex0; 5 | uniform float elapsedTime; 6 | varying vec3 position, normal; 7 | varying float randomOffset; 8 | 9 | const vec4 on = vec4(1.); 10 | const vec4 off = vec4(vec3(0.), 1.); 11 | 12 | void main() { 13 | //gl_FragColor = texture2DRect(tex0, position.xy*10.0); 14 | 15 | float stages = 6.; 16 | float stage = mod(elapsedTime * .6, stages); 17 | if(stage < 1.) { 18 | // diagonal stripes 19 | const float speed = 50.; 20 | const float scale = 50.; 21 | gl_FragColor = 22 | (mod((position.x + position.y + position.z) + (elapsedTime * speed), scale) > scale / 2.) ? 23 | on : off; 24 | } else if(stage < 2.) { 25 | // crazy color bounce 26 | gl_FragColor = vec4(mod(elapsedTime + position / 100., 1.) * sin(mod(elapsedTime * 4., TWO_PI)), 1.); 27 | } else if(stage < 3.) { 28 | // fast rising stripes 29 | if(normal.z == 0.) { 30 | const float speed = 200.; 31 | const float scale = 50.; 32 | gl_FragColor = 33 | (mod((-position.z) + (elapsedTime * speed), scale) < (scale / 2.)) ? 34 | on : off; 35 | } else { 36 | gl_FragColor = off; 37 | } 38 | } else if(stage < 5.) { 39 | // crazy triangles, grid lines 40 | float speed = 10.; 41 | float scale = 50.0; 42 | float cutoff = .9; 43 | vec3 cur = mod(position + speed * elapsedTime, scale) / scale; 44 | cur *= 1. - abs(normal); 45 | if(stage < 4.) { 46 | gl_FragColor = ((cur.x + cur.y + cur.z) < cutoff) ? off : on; 47 | } else { 48 | gl_FragColor = (max(max(cur.x, cur.y), cur.z) < cutoff) ? off : on; 49 | } 50 | } else if(stage < 6.) { 51 | // moving outlines 52 | const float speed = 100.; 53 | const float scale = 6000.; 54 | float localTime = 5. * randomOffset + elapsedTime; 55 | gl_FragColor = 56 | (mod((-position.x - position.y + position.z) + (localTime * speed), scale) > scale / 2.) ? 57 | on : off; 58 | } else if(stage < 7.) { 59 | // spinning (outline or face) 60 | vec2 divider = vec2(cos(elapsedTime), sin(elapsedTime)); 61 | float side = (position.x * divider.y) - (position.y * divider.x); 62 | gl_FragColor = abs(side) < 100. + 280. * sin(elapsedTime * 1.) ? on : off; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/bin/data/shader.vert: -------------------------------------------------------------------------------- 1 | varying vec3 position, normal; 2 | varying float randomOffset; 3 | 4 | float rand(vec2 co){ 5 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); 6 | } 7 | 8 | void main() { 9 | gl_FrontColor = gl_Color; 10 | gl_TexCoord[0] = gl_MultiTexCoord0; 11 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 12 | position = gl_Vertex.xyz; 13 | normal = gl_Normal.xyz; 14 | randomOffset = rand(gl_Vertex.xy + gl_Vertex.yz); 15 | } 16 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/bin/data/video.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.000000000 4 | 0.000000000 5 | 893.000000000 6 | 778.000000000 7 | 8 | 9 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | #ifdef TARGET_OSX 10 | window.setGlutDisplayString("rgba double samples>=8 depth"); 11 | #endif 12 | ofSetupOpenGL(&window, 640*2 +2,768, OF_WINDOW); // <-------- setup the GL context 13 | 14 | // this kicks off the running of my app 15 | // can be OF_WINDOW or OF_FULLSCREEN 16 | // pass in width and height too: 17 | ofRunApp( new testApp()); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_basic/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | #include "ofxMapamok.h" 6 | #include "ofxSmartViewPort.h" 7 | 8 | class testApp : public ofBaseApp{ 9 | public: 10 | void setup(); 11 | void update(); 12 | void draw(); 13 | 14 | void keyPressed(int key); 15 | void mousePressed(int x, int y, int button); 16 | void mouseReleased(int x, int y, int button); 17 | 18 | // create mapamok object 19 | ofxMapaMok mapamoko; 20 | 21 | // grab video from your webcam 22 | ofVideoGrabber video; 23 | 24 | // ofxMapamok util that allows you to do some 25 | // simple cropping on your video 26 | ofxSmartViewPort videoViewPort; 27 | 28 | // the all-powerful canvas that you'll draw to! 29 | ofFbo canvas; 30 | 31 | int textWidth; 32 | int textHeight; 33 | 34 | bool bCanvasMode; 35 | bool bShowHelp; 36 | }; 37 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/addons.make: -------------------------------------------------------------------------------- 1 | ofxAssimpModelLoader 2 | ofxOpenCv 3 | ofxXmlSettings 4 | ofxCv 5 | ofxLibwebsockets 6 | ofxMapamok 7 | ofxProCamToolkit 8 | ofxSpacebrew 9 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/LABgeometriconeface7/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/LABgeometriconeface7/texture.png -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/mapamok.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.000000000 4 | 0.000000000 5 | 1024.000000000 6 | 768.000000000 7 | 8 | 9 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/shader.frag: -------------------------------------------------------------------------------- 1 | #define PI (3.1415926536) 2 | #define TWO_PI (6.2831853072) 3 | 4 | uniform sampler2DRect tex0; 5 | uniform float elapsedTime; 6 | varying vec3 position, normal; 7 | varying float randomOffset; 8 | 9 | const vec4 on = vec4(1.); 10 | const vec4 off = vec4(vec3(0.), 1.); 11 | 12 | void main() { 13 | //gl_FragColor = texture2DRect(tex0, position.xy*10.0); 14 | 15 | float stages = 6.; 16 | float stage = mod(elapsedTime * .6, stages); 17 | if(stage < 1.) { 18 | // diagonal stripes 19 | const float speed = 50.; 20 | const float scale = 50.; 21 | gl_FragColor = 22 | (mod((position.x + position.y + position.z) + (elapsedTime * speed), scale) > scale / 2.) ? 23 | on : off; 24 | } else if(stage < 2.) { 25 | // crazy color bounce 26 | gl_FragColor = vec4(mod(elapsedTime + position / 100., 1.) * sin(mod(elapsedTime * 4., TWO_PI)), 1.); 27 | } else if(stage < 3.) { 28 | // fast rising stripes 29 | if(normal.z == 0.) { 30 | const float speed = 200.; 31 | const float scale = 50.; 32 | gl_FragColor = 33 | (mod((-position.z) + (elapsedTime * speed), scale) < (scale / 2.)) ? 34 | on : off; 35 | } else { 36 | gl_FragColor = off; 37 | } 38 | } else if(stage < 5.) { 39 | // crazy triangles, grid lines 40 | float speed = 10.; 41 | float scale = 50.0; 42 | float cutoff = .9; 43 | vec3 cur = mod(position + speed * elapsedTime, scale) / scale; 44 | cur *= 1. - abs(normal); 45 | if(stage < 4.) { 46 | gl_FragColor = ((cur.x + cur.y + cur.z) < cutoff) ? off : on; 47 | } else { 48 | gl_FragColor = (max(max(cur.x, cur.y), cur.z) < cutoff) ? off : on; 49 | } 50 | } else if(stage < 6.) { 51 | // moving outlines 52 | const float speed = 100.; 53 | const float scale = 6000.; 54 | float localTime = 5. * randomOffset + elapsedTime; 55 | gl_FragColor = 56 | (mod((-position.x - position.y + position.z) + (localTime * speed), scale) > scale / 2.) ? 57 | on : off; 58 | } else if(stage < 7.) { 59 | // spinning (outline or face) 60 | vec2 divider = vec2(cos(elapsedTime), sin(elapsedTime)); 61 | float side = (position.x * divider.y) - (position.y * divider.x); 62 | gl_FragColor = abs(side) < 100. + 280. * sin(elapsedTime * 1.) ? on : off; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/shader.vert: -------------------------------------------------------------------------------- 1 | varying vec3 position, normal; 2 | varying float randomOffset; 3 | 4 | float rand(vec2 co){ 5 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); 6 | } 7 | 8 | void main() { 9 | gl_FrontColor = gl_Color; 10 | gl_TexCoord[0] = gl_MultiTexCoord0; 11 | gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 12 | position = gl_Vertex.xyz; 13 | normal = gl_Normal.xyz; 14 | randomOffset = rand(gl_Vertex.xy + gl_Vertex.yz); 15 | } 16 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/bin/data/video.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.000000000 4 | 0.000000000 5 | 1023.000000000 6 | 767.000000000 7 | 8 | 9 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofOscParameter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ofOscParameter.h 3 | * 4 | * Created on: 14/02/2012 5 | * Author: arturo 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "ofParameter.h" 11 | #include "ofxOsc.h" 12 | #include "ofThread.h" 13 | 14 | template 15 | class ofOscParameter: public ofParameter{ 16 | public: 17 | ofOscParameter(); 18 | ofOscParameter(ParameterType v); 19 | ofOscParameter(string name, ParameterType v); 20 | 21 | ParameterType getValue(); 22 | void setValue(ParameterType v); 23 | 24 | static void setup(string remotehost, int remoteport, int localport); 25 | 26 | private: 27 | class OscUpdater: public ofThread{ 28 | public: 29 | void setup(string remotehost, int remoteport, int localport){ 30 | oscSender.setup(remotehost,remoteport); 31 | oscReceiver.setup(localport); 32 | startThread(true,false); 33 | } 34 | 35 | void threadedFunction(){ 36 | 37 | } 38 | 39 | private: 40 | ofxOscSender oscSender; 41 | ofxOscReceiver oscReceiver; 42 | map 43 | }; 44 | 45 | static OscUpdater oscUpdater; 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxBaseGui.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxBaseGui.h" 2 | 3 | const ofColor 4 | ofxBaseGui::headerBackgroundColor(64), 5 | ofxBaseGui::backgroundColor(0), 6 | ofxBaseGui::textColor(255), 7 | ofxBaseGui::fillColor(128); 8 | 9 | const int ofxBaseGui::textPadding = 4; 10 | const int ofxBaseGui::defaultWidth = 200; 11 | const int ofxBaseGui::defaultHeight = 16; 12 | 13 | ofxBaseGui::ofxBaseGui(){ 14 | bGuiActive = false; 15 | currentFrame = 0; 16 | } 17 | 18 | ofxBaseGui::~ofxBaseGui(){ 19 | ofUnregisterMouseEvents(this); 20 | } 21 | 22 | void ofxBaseGui::saveToFile(string filename) { 23 | ofxXmlSettings xml; 24 | xml.loadFile(filename); 25 | saveToXml(xml); 26 | xml.saveFile(filename); 27 | } 28 | 29 | void ofxBaseGui::loadFromFile(string filename) { 30 | ofxXmlSettings xml; 31 | xml.loadFile(filename); 32 | loadFromXml(xml); 33 | } 34 | 35 | string ofxBaseGui::getName(){ 36 | return name; 37 | } 38 | 39 | void ofxBaseGui::setName(string _name){ 40 | name = _name; 41 | } 42 | 43 | void ofxBaseGui::setPosition(ofPoint p){ 44 | setPosition(p.x,p.y); 45 | } 46 | 47 | void ofxBaseGui::setPosition(float x, float y){ 48 | b.x = x; 49 | b.y = y; 50 | } 51 | 52 | void ofxBaseGui::setSize(float w, float h){ 53 | b.width = w; 54 | b.height = h; 55 | } 56 | 57 | void ofxBaseGui::setShape(ofRectangle r){ 58 | b = r; 59 | } 60 | 61 | void ofxBaseGui::setShape(float x, float y, float w, float h){ 62 | b.set(x,y,w,h); 63 | } 64 | 65 | ofPoint ofxBaseGui::getPosition(){ 66 | return ofPoint(b.x,b.y); 67 | } 68 | 69 | ofRectangle ofxBaseGui::getShape(){ 70 | return b; 71 | } 72 | 73 | float ofxBaseGui::getWidth(){ 74 | return b.width; 75 | } 76 | 77 | float ofxBaseGui::getHeight(){ 78 | return b.height; 79 | } 80 | 81 | string ofxBaseGui::saveStencilToHex(ofImage& img) { 82 | stringstream strm; 83 | int width = img.getWidth(); 84 | int height = img.getHeight(); 85 | int n = width * height; 86 | unsigned char cur = 0; 87 | int shift = 0; 88 | strm << "{"; 89 | for(int i = 0; i < n;) { 90 | if(img.getPixels()[i * 4 + 3] > 0) { 91 | cur |= 1 << shift; 92 | } 93 | i++; 94 | if(i % 8 == 0) { 95 | strm << "0x" << hex << (unsigned int) cur; 96 | cur = 0; 97 | shift = 0; 98 | if(i < n) { 99 | strm << ","; 100 | } 101 | } else { 102 | shift++; 103 | } 104 | } 105 | strm << "}"; 106 | return strm.str(); 107 | } 108 | 109 | void ofxBaseGui::loadStencilFromHex(ofImage& img, unsigned char* data) { 110 | int width = img.getWidth(); 111 | int height = img.getHeight(); 112 | int i = 0; 113 | ofColor on(255, 255); 114 | ofColor off(255, 0); 115 | for(int y = 0; y < height; y++) { 116 | for(int x = 0; x < width; x++) { 117 | int shift = i % 8; 118 | int offset = i / 8; 119 | bool cur = (data[offset] >> shift) & 1; 120 | img.setColor(x, y, cur ? on : off); 121 | i++; 122 | } 123 | } 124 | img.update(); 125 | } 126 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxBaseGui.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofxXmlSettings.h" 4 | #include "ofConstants.h" 5 | #include "ofRectangle.h" 6 | #include "ofImage.h" 7 | #include "ofEvents.h" 8 | 9 | 10 | class ofxBaseGui{ 11 | public: 12 | ofxBaseGui(); 13 | 14 | virtual ~ofxBaseGui(); 15 | 16 | virtual void mouseMoved(ofMouseEventArgs & args) = 0; 17 | virtual void mousePressed(ofMouseEventArgs & args) = 0; 18 | virtual void mouseDragged(ofMouseEventArgs & args) = 0; 19 | virtual void mouseReleased(ofMouseEventArgs & args) = 0; 20 | 21 | virtual void setValue(float mx, float my, bool bCheckBounds) = 0; 22 | virtual void draw() = 0; 23 | 24 | void saveToFile(string filename); 25 | void loadFromFile(string filename); 26 | 27 | virtual void saveToXml(ofxXmlSettings& xml) = 0; 28 | virtual void loadFromXml(ofxXmlSettings& xml) = 0; 29 | 30 | string getName(); 31 | void setName(string name); 32 | 33 | void setPosition(ofPoint p); 34 | void setPosition(float x, float y); 35 | void setSize(float w, float h); 36 | void setShape(ofRectangle r); 37 | void setShape(float x, float y, float w, float h); 38 | 39 | ofPoint getPosition(); 40 | ofRectangle getShape(); 41 | float getWidth(); 42 | float getHeight(); 43 | 44 | protected: 45 | string name; 46 | unsigned long currentFrame; 47 | ofRectangle b; 48 | bool bGuiActive; 49 | 50 | static const ofColor headerBackgroundColor; 51 | static const ofColor backgroundColor; 52 | static const ofColor textColor; 53 | static const ofColor fillColor; 54 | 55 | static const int textPadding; 56 | static const int defaultWidth; 57 | static const int defaultHeight; 58 | 59 | static string saveStencilToHex(ofImage& img); 60 | static void loadStencilFromHex(ofImage& img, unsigned char* data) ; 61 | }; 62 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxButton.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxButton.h" 2 | 3 | ofxButton* ofxButton::setup(string toggleName, float width, float height){ 4 | name = toggleName; 5 | b.x = 0; 6 | b.y = 0; 7 | b.width = width; 8 | b.height = height; 9 | currentFrame = 0; 10 | bGuiActive = false; 11 | value = false; 12 | checkboxRect.set(1, 1, b.height - 2, b.height - 2); 13 | 14 | ofRegisterMouseEvents(this); 15 | return this; 16 | } 17 | 18 | void ofxButton::mouseReleased(ofMouseEventArgs & args){ 19 | setValue(args.x, args.y, false); 20 | bGuiActive = false; 21 | } 22 | 23 | 24 | 25 | void ofxButton::mouseMoved(ofMouseEventArgs & args){ 26 | ofxToggle::mouseMoved(args); 27 | } 28 | 29 | void ofxButton::mousePressed(ofMouseEventArgs & args){ 30 | ofxToggle::mousePressed(args); 31 | } 32 | 33 | void ofxButton::mouseDragged(ofMouseEventArgs & args){ 34 | ofxToggle::mouseDragged(args); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxButton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofxToggle.h" 4 | #include "ofParameter.h" 5 | 6 | class ofxButton : public ofxToggle{ 7 | friend class ofPanel; 8 | 9 | public: 10 | 11 | ofxButton* setup(string toggleName, float width = defaultWidth, float height = defaultHeight); 12 | 13 | virtual void mouseReleased(ofMouseEventArgs & args); 14 | virtual void mouseMoved(ofMouseEventArgs & args); 15 | virtual void mousePressed(ofMouseEventArgs & args); 16 | virtual void mouseDragged(ofMouseEventArgs & args); 17 | 18 | 19 | virtual void saveToXml(ofxXmlSettings& xml) {} // does't make sense to save buttons; 20 | virtual void loadFromXml(ofxXmlSettings& xml) {} 21 | 22 | }; 23 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxGui.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofxToggle.h" 4 | #include "ofxSlider.h" 5 | #include "ofxPanel.h" 6 | #include "ofxButton.h" 7 | #include "ofxLabel.h" 8 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxLabel.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxLabel.h" 2 | #include "ofGraphics.h" 3 | 4 | ofxLabel* ofxLabel::setup(string labelName, ofxParameter _label, float width, float height) { 5 | name = labelName; 6 | label = _label; 7 | b.width = width; 8 | b.height = height; 9 | return this; 10 | } 11 | 12 | ofxLabel* ofxLabel::setup(string labelName, string _label, float width, float height) { 13 | name = labelName; 14 | label = _label; 15 | b.width = width; 16 | b.height = height; 17 | return this; 18 | } 19 | 20 | void ofxLabel::draw() { 21 | currentFrame = ofGetFrameNum(); 22 | 23 | ofPushStyle(); 24 | ofPushMatrix(); 25 | 26 | ofSetColor(backgroundColor); 27 | ofRect(b); 28 | 29 | ofTranslate(b.x, b.y); 30 | ofSetColor(textColor); 31 | ofTranslate(0, b.height / 2 + 4); 32 | ofDrawBitmapString(label, textPadding, 0); 33 | 34 | ofPopMatrix(); 35 | ofPopStyle(); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxLabel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofParameter.h" 4 | #include "ofxBaseGui.h" 5 | 6 | class ofxLabel: public ofxBaseGui { 7 | public: 8 | ofxLabel(){} 9 | virtual ~ofxLabel() {} 10 | // We need a string version here as literals are not getting converted to 11 | // ofxParameter. For status.setup("Status", "") we get: 12 | // error: no matching function for call to ‘ofxLabel::setup(const char [7], const char [1])’ 13 | // note: no known conversion for argument 2 from ‘const char [1]’ to ‘ofxParameter >’ 14 | ofxLabel * setup(string labelName, string _label, float width = defaultWidth, float height = defaultHeight); 15 | ofxLabel * setup(string labelName, ofxParameter _label, float width = defaultWidth, float height = defaultHeight); 16 | 17 | // Abstract methods we must implement, but have no need for! 18 | virtual void mouseMoved(ofMouseEventArgs & args){} 19 | virtual void mousePressed(ofMouseEventArgs & args){} 20 | virtual void mouseDragged(ofMouseEventArgs & args){} 21 | virtual void mouseReleased(ofMouseEventArgs & args){} 22 | virtual void saveToXml(ofxXmlSettings& xml){} 23 | virtual void loadFromXml(ofxXmlSettings& xml){} 24 | virtual void setValue(float mx, float my, bool bCheckBounds){} 25 | 26 | void draw(); 27 | 28 | template 29 | void addListener(ListenerClass * listener, void ( ListenerClass::*method )(string&)){ 30 | label.addListener(listener,method); 31 | } 32 | 33 | template 34 | void removeListener(ListenerClass * listener, void ( ListenerClass::*method )(string&)){ 35 | label.removeListener(listener,method); 36 | } 37 | 38 | string operator=(string v) { label = v; return v; } 39 | operator string & () { return label; } 40 | 41 | protected: 42 | ofxParameter label; 43 | }; 44 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxPanel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofxBaseGui.h" 4 | #include "ofConstants.h" 5 | #include "ofxXmlSettings.h" 6 | #include "ofxSlider.h" 7 | #include "ofxButton.h" 8 | #include "ofxToggle.h" 9 | #include "ofRectangle.h" 10 | #include "ofImage.h" 11 | 12 | 13 | class ofxPanel : public ofxBaseGui{ 14 | public: 15 | ofxPanel(); 16 | 17 | virtual ~ofxPanel(); 18 | 19 | ofxPanel * setup(string collectionName="", string _filename="settings.xml", float x = 10, float y = 10); 20 | 21 | virtual void saveToXml(ofxXmlSettings& xml); 22 | virtual void loadFromXml(ofxXmlSettings& xml); 23 | 24 | void add(ofxBaseGui * element); 25 | void add(ofxParameter & parameter); 26 | void add(ofxParameter & parameter); 27 | void add(ofxParameter & parameter); 28 | 29 | void clear(); 30 | 31 | virtual void mouseMoved(ofMouseEventArgs & args); 32 | virtual void mousePressed(ofMouseEventArgs & args); 33 | virtual void mouseDragged(ofMouseEventArgs & args); 34 | virtual void mouseReleased(ofMouseEventArgs & args); 35 | 36 | void draw(); 37 | 38 | vector getControlNames(); 39 | int getNumControls(); 40 | 41 | ofxIntSlider getIntSlider(string name); 42 | ofxFloatSlider getFloatSlider(string name); 43 | ofxToggle getToggle(string name); 44 | ofxButton getButton(string name); 45 | 46 | ofxBaseGui * getControl(string name); 47 | ofxBaseGui * getControl(int num); 48 | 49 | protected: 50 | void setValue(float mx, float my, bool bCheck); 51 | 52 | template 53 | ControlType getControlType(string name); 54 | 55 | private: 56 | ofPoint grabPt; 57 | bool bGrabbed; 58 | float spacing; 59 | float header; 60 | vector collection; 61 | 62 | string filename; 63 | ofRectangle loadBox, saveBox; 64 | static ofImage loadIcon, saveIcon; 65 | }; 66 | 67 | template 68 | ControlType ofxPanel::getControlType(string name){ 69 | ControlType * control = dynamic_cast(getControl(name)); 70 | if(control) return *control; 71 | else return ControlType(); 72 | } 73 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxSlider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofxBaseGui.h" 4 | #include "ofParameter.h" 5 | 6 | template 7 | class ofxSlider : public ofxBaseGui{ 8 | friend class ofPanel; 9 | 10 | public: 11 | ofxSlider(){} 12 | ofxSlider(string sliderName, ofxParameter _val, Type _min, Type _max, float width = defaultWidth, float height = defaultHeight); 13 | ofxSlider* setup(string sliderName, ofxParameter _val, Type _min, Type _max, float width = defaultWidth, float height = defaultHeight); 14 | 15 | virtual void mouseMoved(ofMouseEventArgs & args); 16 | virtual void mousePressed(ofMouseEventArgs & args); 17 | virtual void mouseDragged(ofMouseEventArgs & args); 18 | virtual void mouseReleased(ofMouseEventArgs & args); 19 | 20 | virtual void saveToXml(ofxXmlSettings& xml); 21 | virtual void loadFromXml(ofxXmlSettings& xml); 22 | 23 | template 24 | void addListener(ListenerClass * listener, void ( ListenerClass::*method )(Type&)){ 25 | value.addListener(listener,method); 26 | } 27 | 28 | template 29 | void removeListener(ListenerClass * listener, void ( ListenerClass::*method )(Type&)){ 30 | value.removeListener(listener,method); 31 | } 32 | 33 | 34 | double operator=(Type v); 35 | operator Type & (); 36 | 37 | void draw(); 38 | 39 | ofxParameter value; 40 | 41 | protected: 42 | Type min, max; 43 | 44 | void setValue(float mx, float my, bool bCheck); 45 | }; 46 | 47 | typedef ofxSlider ofxFloatSlider; 48 | typedef ofxSlider ofxIntSlider; 49 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxToggle.cpp: -------------------------------------------------------------------------------- 1 | #include "ofxToggle.h" 2 | #include "ofGraphics.h" 3 | 4 | ofxToggle::ofxToggle(string toggleName, ofxParameter _bVal, float width, float height){ 5 | setup(toggleName,_bVal,defaultWidth,height); 6 | } 7 | 8 | ofxToggle * ofxToggle::setup(string toggleName, ofxParameter _bVal, float width, float height){ 9 | name = toggleName; 10 | b.x = 0; 11 | b.y = 0; 12 | b.width = width; 13 | b.height = height; 14 | currentFrame = 0; 15 | bGuiActive = false; 16 | value = _bVal; 17 | checkboxRect.set(1, 1, b.height - 2, b.height - 2); 18 | 19 | ofRegisterMouseEvents(this); 20 | return this; 21 | } 22 | 23 | 24 | void ofxToggle::mouseMoved(ofMouseEventArgs & args){ 25 | } 26 | 27 | void ofxToggle::mousePressed(ofMouseEventArgs & args){ 28 | setValue(args.x, args.y, true); 29 | } 30 | 31 | void ofxToggle::mouseDragged(ofMouseEventArgs & args){ 32 | } 33 | 34 | void ofxToggle::mouseReleased(ofMouseEventArgs & args){ 35 | bGuiActive = false; 36 | } 37 | 38 | void ofxToggle::saveToXml(ofxXmlSettings& xml) { 39 | string xmlName = name; 40 | ofStringReplace(xmlName," ","_"); 41 | ofStringReplace(xmlName,",","_"); 42 | ofStringReplace(xmlName,"(","_"); 43 | ofStringReplace(xmlName,")","_"); 44 | ofStringReplace(xmlName,"/","_"); 45 | xml.setValue(xmlName, value); 46 | } 47 | 48 | void ofxToggle::loadFromXml(ofxXmlSettings& xml) { 49 | string xmlName = name; 50 | ofStringReplace(xmlName," ","_"); 51 | ofStringReplace(xmlName,",","_"); 52 | ofStringReplace(xmlName,"(","_"); 53 | ofStringReplace(xmlName,")","_"); 54 | ofStringReplace(xmlName,"/","_"); 55 | value = xml.getValue(xmlName, value); 56 | } 57 | 58 | void ofxToggle::draw(){ 59 | currentFrame = ofGetFrameNum(); 60 | 61 | ofPushStyle(); 62 | ofPushMatrix(); 63 | 64 | ofSetColor(backgroundColor); 65 | ofRect(b); 66 | 67 | ofTranslate(b.x, b.y); 68 | 69 | ofFill(); 70 | ofSetColor(fillColor); 71 | ofRect(checkboxRect); 72 | 73 | if( value ){ 74 | ofSetColor(textColor); 75 | ofLine(checkboxRect.x, checkboxRect.y, checkboxRect.x + checkboxRect.width, checkboxRect.y + checkboxRect.height); 76 | ofLine(checkboxRect.x, checkboxRect.y+ checkboxRect.height, checkboxRect.x + checkboxRect.width, checkboxRect.y); 77 | } else { 78 | ofSetColor(backgroundColor); 79 | ofRect(checkboxRect.x + 1, checkboxRect.y + 1, checkboxRect.width - 2, checkboxRect.height - 2); 80 | } 81 | 82 | ofSetColor(textColor); 83 | ofTranslate(0, b.height / 2 + 4); 84 | ofDrawBitmapString(name, textPadding + checkboxRect.width, 0); 85 | //string valStr = value ? "true" : "false"; 86 | //ofDrawBitmapString(valStr, b.width - textPadding - valStr.length() * 8, 0); 87 | 88 | ofPopMatrix(); 89 | ofPopStyle(); 90 | } 91 | 92 | bool ofxToggle::operator=(bool v){ 93 | value = v; 94 | return v; 95 | } 96 | 97 | ofxToggle::operator bool & (){ 98 | return value; 99 | } 100 | 101 | void ofxToggle::setValue(float mx, float my, bool bCheck){ 102 | 103 | if( ofGetFrameNum() - currentFrame > 1 ){ 104 | bGuiActive = false; 105 | return; 106 | } 107 | if( bCheck ){ 108 | ofRectangle checkRect = checkboxRect; 109 | checkRect.x += b.x; 110 | checkRect.y += b.y; 111 | 112 | if( checkRect.inside(mx, my) ){ 113 | bGuiActive = true; 114 | }else{ 115 | bGuiActive = false; 116 | 117 | } 118 | } 119 | if( bGuiActive ){ 120 | value = !value; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/addons/ofxGui/src/ofxToggle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofParameter.h" 4 | #include "ofxBaseGui.h" 5 | 6 | class ofxToggle : public ofxBaseGui{ 7 | public: 8 | ofxToggle(){}; 9 | ofxToggle(string toggleName, ofxParameter _bVal, float width = defaultWidth, float height = defaultHeight); 10 | ofxToggle * setup(string toggleName, ofxParameter _bVal, float width = defaultWidth, float height = defaultHeight); 11 | 12 | 13 | virtual void mouseMoved(ofMouseEventArgs & args); 14 | virtual void mousePressed(ofMouseEventArgs & args); 15 | virtual void mouseDragged(ofMouseEventArgs & args); 16 | virtual void mouseReleased(ofMouseEventArgs & args); 17 | 18 | virtual void saveToXml(ofxXmlSettings& xml) ; 19 | virtual void loadFromXml(ofxXmlSettings& xml); 20 | 21 | void draw(); 22 | 23 | template 24 | void addListener(ListenerClass * listener, void ( ListenerClass::*method )(bool&)){ 25 | value.addListener(listener,method); 26 | } 27 | 28 | template 29 | void removeListener(ListenerClass * listener, void ( ListenerClass::*method )(bool&)){ 30 | value.removeListener(listener,method); 31 | } 32 | 33 | 34 | bool operator=(bool v); 35 | operator bool & (); 36 | 37 | ofxParameter value; 38 | protected: 39 | ofRectangle checkboxRect; 40 | 41 | void setValue(float mx, float my, bool bCheck); 42 | 43 | }; 44 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | #ifdef TARGET_OSX 10 | window.setGlutDisplayString("rgba double samples>=8 depth"); 11 | #endif 12 | ofSetupOpenGL(&window, 640*2 +2,768, OF_FULLSCREEN); // <-------- setup the GL context 13 | 14 | // this kicks off the running of my app 15 | // can be OF_WINDOW or OF_FULLSCREEN 16 | // pass in width and height too: 17 | ofRunApp( new testApp()); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxMapamok_spacebrew/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | #include "ofxMapamok.h" 6 | #include "ofxSmartViewPort.h" 7 | 8 | #include "ofxSpacebrew.h" 9 | #include "ofxGui.h" 10 | 11 | class testApp : public ofBaseApp{ 12 | public: 13 | void setup(); 14 | void update(); 15 | void draw(); 16 | 17 | void keyPressed(int key); 18 | void mousePressed(int x, int y, int button); 19 | void mouseReleased(int x, int y, int button); 20 | void mouseDragged( int x, int y, int button); 21 | 22 | // spacebrew stuff 23 | Spacebrew::Connection spacebrew; 24 | void onMessage( Spacebrew::Message & m ); 25 | 26 | // mapamok stuff 27 | ofxMapaMok mapamoko; 28 | 29 | // light that will follow your mouse 30 | ofLight mouseLight; 31 | 32 | // the all-powerful canvas that you'll draw to! 33 | ofFbo canvas; 34 | 35 | int textWidth; 36 | int textHeight; 37 | 38 | bool bCanvasMode; 39 | bool bShowHelp; 40 | 41 | // vars to use with ofxGui 42 | bool bGuiHidden; 43 | ofxPanel gui; 44 | ofxFloatSlider scale, lerpSpeed; 45 | 46 | bool bCursorHidden; 47 | ofColor start,end; 48 | 49 | }; 50 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_basic/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_basic/addons.make: -------------------------------------------------------------------------------- 1 | ofxSimpleProjectionMapper 2 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_basic/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_05/projectionMappingExamples/ofxSPM_basic/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_basic/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_basic/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_basic/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | ofBackground(0); 6 | // this changes our drawing rate to match our screen's refresh rate 7 | ofSetVerticalSync(true); 8 | ofEnableAlphaBlending(); 9 | 10 | // allocate your FBO 11 | // you MUST do this before drawing to it! 12 | // we'll make ours the same res as our mapper (see below) 13 | canvas.allocate(800, 600); 14 | 15 | // you also need to clear out your FBO (we'll clear it to black) 16 | canvas.begin(); 17 | ofClear(0); 18 | canvas.end(); 19 | 20 | // initialize ofxSPM at a specific res (we'll say 800x600) 21 | mapper.initialize(800, 600); 22 | 23 | // try loading some settings 24 | mapper.load("mapsettings.txt"); 25 | 26 | // start off not drawing bounds; press 'd' for debug to show them 27 | bDrawBounds = false; 28 | } 29 | 30 | //-------------------------------------------------------------- 31 | void testApp::update(){ 32 | // update your mapper 33 | mapper.update(); 34 | } 35 | 36 | //-------------------------------------------------------------- 37 | void testApp::draw(){ 38 | // draw something to your canvas 39 | canvas.begin(); 40 | // fade out the bg a little 41 | ofSetColor(0,2); 42 | ofRect(0,0,canvas.getWidth(), canvas.getHeight()); 43 | ofSetColor(255); 44 | 45 | // we'll draw some little circles 46 | ofCircle(mouseX, mouseY, ofRandom(5,10)); 47 | canvas.end(); 48 | 49 | mapper.startMapping(); 50 | canvas.draw(0,0); 51 | mapper.stopMapping(); 52 | 53 | if ( bDrawBounds ){ 54 | mapper.drawBoundingBox(); 55 | } 56 | } 57 | 58 | //-------------------------------------------------------------- 59 | void testApp::keyPressed(int key){ 60 | if ( key == 's' ){ 61 | // save to a file 62 | mapper.save("mapsettings.txt"); 63 | } else if ( key == 'd' ){ 64 | bDrawBounds = !bDrawBounds; 65 | } else if ( key == 'f' ) { 66 | ofToggleFullscreen(); 67 | } 68 | } 69 | 70 | //-------------------------------------------------------------- 71 | void testApp::keyReleased(int key){} 72 | 73 | //-------------------------------------------------------------- 74 | void testApp::mouseMoved(int x, int y ){} 75 | 76 | //-------------------------------------------------------------- 77 | void testApp::mouseDragged(int x, int y, int button){ 78 | // pass along mouse events to mapper 79 | mapper.mouseDragged(x, y); 80 | } 81 | 82 | //-------------------------------------------------------------- 83 | void testApp::mousePressed(int x, int y, int button){ 84 | mapper.mousePressed(x, y); 85 | 86 | } 87 | 88 | //-------------------------------------------------------------- 89 | void testApp::mouseReleased(int x, int y, int button){ 90 | mapper.mouseReleased(x, y); 91 | } 92 | 93 | //-------------------------------------------------------------- 94 | void testApp::windowResized(int w, int h){} 95 | 96 | //-------------------------------------------------------------- 97 | void testApp::gotMessage(ofMessage msg){} 98 | 99 | //-------------------------------------------------------------- 100 | void testApp::dragEvent(ofDragInfo dragInfo){ } -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_basic/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | // include ofxSPM 6 | #include "ofxSimpleProjectionMapper.h" 7 | 8 | class testApp : public ofBaseApp{ 9 | 10 | public: 11 | void setup(); 12 | void update(); 13 | void draw(); 14 | 15 | void keyPressed (int key); 16 | void keyReleased(int key); 17 | void mouseMoved(int x, int y ); 18 | void mouseDragged(int x, int y, int button); 19 | void mousePressed(int x, int y, int button); 20 | void mouseReleased(int x, int y, int button); 21 | void windowResized(int w, int h); 22 | void dragEvent(ofDragInfo dragInfo); 23 | void gotMessage(ofMessage msg); 24 | 25 | // ofxSPM object 26 | ofxSimpleProjectionMapper mapper; 27 | 28 | // fbo to draw to 29 | ofFbo canvas; 30 | 31 | // do we want to show ofxSPM's bounding boxes? 32 | bool bDrawBounds; 33 | }; 34 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/addons.make: -------------------------------------------------------------------------------- 1 | ofxSimpleProjectionMapper 2 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_05/projectionMappingExamples/ofxSPM_box/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/bin/mapsettings0.txt: -------------------------------------------------------------------------------- 1 | 0.000000,0.000000,800.000000,0.000000,800.000000,600.000000,0.000000,600.000000, 2 | 487.000000,396.000000,941.000000,237.000000,933.000000,457.000000,492.000000,641.000000 -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/bin/mapsettings1.txt: -------------------------------------------------------------------------------- 1 | 0.000000,0.000000,800.000000,0.000000,800.000000,600.000000,0.000000,600.000000, 2 | 202.000000,319.000000,672.000000,203.000000,941.000000,237.000000,486.000000,396.000000 -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/bin/mapsettings2.txt: -------------------------------------------------------------------------------- 1 | 0.000000,0.000000,800.000000,0.000000,800.000000,600.000000,0.000000,600.000000, 2 | 206.000000,319.000000,487.000000,396.000000,490.000000,643.000000,211.000000,549.000000 -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_05/projectionMappingExamples/ofxSPM_box/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | // include ofxSPM 6 | #include "ofxSimpleProjectionMapper.h" 7 | 8 | class testApp : public ofBaseApp{ 9 | 10 | public: 11 | void setup(); 12 | void update(); 13 | void draw(); 14 | 15 | void keyPressed (int key); 16 | void keyReleased(int key); 17 | void mouseMoved(int x, int y ); 18 | void mouseDragged(int x, int y, int button); 19 | void mousePressed(int x, int y, int button); 20 | void mouseReleased(int x, int y, int button); 21 | void windowResized(int w, int h); 22 | void dragEvent(ofDragInfo dragInfo); 23 | void gotMessage(ofMessage msg); 24 | 25 | // array of ofxSPM objects 26 | ofxSimpleProjectionMapper mappers[3]; 27 | 28 | // fbos to draw to 29 | ofFbo canvas[3]; 30 | 31 | // do we want to show ofxSPM's bounding boxes? 32 | bool bDrawBounds; 33 | 34 | // force selecting just one box at a time 35 | int forceSelect; 36 | }; 37 | -------------------------------------------------------------------------------- /Week_08/node-spacebrew/README.md: -------------------------------------------------------------------------------- 1 | 2 | _____ _ 3 | / ____| | | _ 4 | | (___ _ __ __ _ ___ ___| |__ _ __ _____ __ _| |_ 5 | \___ \| '_ \ / _` |/ __/ _ \ '_ \| '__/ _ \ \ /\ / / |_ _| 6 | ____) | |_) | (_| | (_| __/ |_) | | | __/\ V V / |_| 7 | |_____/| .__/ \__,_|\___\___|_.__/|_| \___| \_/\_/ 8 | _ _ | | _ _ 9 | | \ | ||_| | | (_) _ 10 | | \| | ___ __| | ___ _ ___ _| |_ 11 | | . ` |/ _ \ / _` |/ _ \ | / __| |_ _| 12 | | |\ | (_) | (_| | __/_| \__ \ |_| 13 | |_|_\_|\___/ \__,_|\___(_) |___/ 14 | | ____| _/ | 15 | | |__ __ ___ __ _ __|__/ ___ ___ 16 | | __| \ \/ / '_ \| '__/ _ \/ __/ __| 17 | | |____ > <| |_) | | | __/\__ \__ \ 18 | |______/_/\_\ .__/|_| \___||___/___/ 19 | | | 20 | |_| 21 | 22 | 23 | This repository contains a super simple node.js application that creates a Spacebrew client with one publisher that sends a "tick" string every second. Why express and not just plain old node? That's a topic for another day. 24 | 25 | For learning's sake, the following instructions will re-create the app contained here. 26 | 27 | 1. Follow [the directions here](http://expressjs.com/guide.html#executable) to create a barebones Express app. Essentially it comes down to issuing the following commands: 28 | 29 | ``` 30 | npm install -g express 31 | express --sessions --ejs spacebrew-ticker 32 | ``` 33 | 34 | * Install the initial required modules by running the following command 35 | 36 | ``` 37 | cd spacebrew-ticker && npm install 38 | ``` 39 | 40 | * Install the 'ws' module (it is required by spacebrew) 41 | 42 | ``` 43 | npm install ws --save 44 | ``` 45 | 46 | * Get *sb-1.0.3.js* from the lib folder in https://github.com/Spacebrew/spacebrew.js and put it in the root folder of your app 47 | 48 | ``` 49 | curl -O https://raw.github.com/Spacebrew/spacebrew.js/master/library/sb-1.0.3.js 50 | ``` 51 | 52 | - Open app.js in tour favorite text editor and include Spacebrew by modifying the top of your app.js so that it looks like this: 53 | 54 | ``` 55 | var express = require('express') 56 | , routes = require('./routes') 57 | , user = require('./routes/user') 58 | , http = require('http') 59 | , path = require('path') 60 | , Spacebrew = require('./sb-1.0.3') 61 | 62 | ``` 63 | - Create a Spacebrew client. Provide a server, name, description 64 | 65 | ``` 66 | var sb = new Spacebrew.Spacebrew.Client( server, name, description ); 67 | ``` 68 | 69 | - Add publishers and/or subscribers as described in the examples at the [Spacebrew.js repo](https://github.com/Spacebrew/spacebrew.js). 70 | - Connect the mofo. 71 | 72 | ``` 73 | sb.connect(); 74 | ``` 75 | 76 | - Run your node app! 77 | 78 | ``` 79 | node app.js 80 | ``` 81 | 82 | - Head over to the [Spacebrew Sandbox](http://spacebrew.github.com/spacebrew/admin/admin.html?server=sandbox.spacebrew.cc) and see your app -------------------------------------------------------------------------------- /Week_08/node-spacebrew/app.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Module dependencies. 3 | */ 4 | 5 | var express = require('express') 6 | , routes = require('./routes') 7 | , user = require('./routes/user') 8 | , http = require('http') 9 | , path = require('path') 10 | , Spacebrew = require('./sb-1.0.3') 11 | 12 | 13 | var app = express(); 14 | 15 | app.configure(function(){ 16 | app.set('port', process.env.PORT || 3000); 17 | app.set('views', __dirname + '/views'); 18 | app.set('view engine', 'ejs'); 19 | app.use(express.favicon()); 20 | app.use(express.logger('dev')); 21 | app.use(express.bodyParser()); 22 | app.use(express.methodOverride()); 23 | app.use(express.cookieParser('your secret here')); 24 | app.use(express.session()); 25 | app.use(app.router); 26 | app.use(express.static(path.join(__dirname, 'public'))); 27 | }); 28 | 29 | app.configure('development', function(){ 30 | app.use(express.errorHandler()); 31 | }); 32 | 33 | app.get('/', routes.index); 34 | app.get('/users', user.list); 35 | 36 | http.createServer(app).listen(app.get('port'), function(){ 37 | console.log("Express server listening on port " + app.get('port')); 38 | }); 39 | 40 | 41 | // 42 | // Now start up the Spacebrew client 43 | // 44 | 45 | var server = "sandbox.spacebrew.cc"; 46 | var name = "Clock"; 47 | var description = "Jeff's Node test!"; 48 | var sb = new Spacebrew.Spacebrew.Client( server, name, description ); 49 | 50 | sb.addPublish("tick", "string", "The tick of a clock!"); // create the publication feed 51 | 52 | var i = 0; 53 | setInterval(function(){ 54 | var newString = "The time is now "+i; 55 | sb.send("tick", "string", newString); // send string to spacebrew 56 | i++; 57 | }, 1000); 58 | 59 | // connect to spacbrew 60 | sb.connect(); 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Week_08/node-spacebrew/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-spacebrew", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app" 7 | }, 8 | "dependencies": { 9 | "express": "3.1.0", 10 | "ejs": "*", 11 | "ws": "~0.4.25" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Week_08/node-spacebrew/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } -------------------------------------------------------------------------------- /Week_08/node-spacebrew/routes/index.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * GET home page. 4 | */ 5 | 6 | exports.index = function(req, res){ 7 | res.render('index', { title: 'Express' }); 8 | }; -------------------------------------------------------------------------------- /Week_08/node-spacebrew/routes/user.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * GET users listing. 4 | */ 5 | 6 | exports.list = function(req, res){ 7 | res.send("respond with a resource"); 8 | }; -------------------------------------------------------------------------------- /Week_08/node-spacebrew/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | 8 |

<%= title %>

9 |

Welcome to <%= title %>

10 | 11 | -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .DS_Store -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape/README.md: -------------------------------------------------------------------------------- 1 | 2 | ____ __ 3 | /\ _`\ /\ \ 4 | \ \,\L\_\ _____ __ ___ __\ \ \____ _ __ __ __ __ __ 5 | \/_\__ \ /\ '__`\ /'__`\ /'___\ /'__`\ \ '__`\/\`'__\/'__`\/\ \/\ \/\ \ 6 | /\ \L\ \ \ \L\ \/\ \L\.\_/\ \__//\ __/\ \ \L\ \ \ \//\ __/\ \ \_/ \_/ \ 7 | \ `\____\ \ ,__/\ \__/.\_\ \____\ \____\\ \_,__/\ \_\\ \____\\ \___x___/' 8 | \/_____/\ \ \/ \/__/\/_/\/____/\/____/ \/___/ \/_/ \/____/ \/__//__/ 9 | \ \_\ 10 | \/_/ 11 | ____ 12 | /\ _`\ 13 | \ \,\L\_\ ___ _ __ __ _____ __ _ __ 14 | \/_\__ \ /'___\/\`'__\/'__`\ /\ '__`\ /'__`\/\`'__\ 15 | /\ \L\ \/\ \__/\ \ \//\ \L\.\_\ \ \L\ \/\ __/\ \ \/ 16 | \ `\____\ \____\\ \_\\ \__/.\_\\ \ ,__/\ \____\\ \_\ 17 | \/_____/\/____/ \/_/ \/__/\/_/ \ \ \/ \/____/ \/_/ 18 | \ \_\ 19 | \/_/ 20 | 21 | This example shows a simple implementation of [pySpacebrew](https://github.com/Spacebrew/pySpacebrew) and the Python Package [lxml](http://lxml.de/), so you will need to install lxml first. You can do so using [the instructions here](http://lxml.de/installation.html), but it should be as easy as easy as running 22 | 23 | ``` 24 | pip install lxml 25 | ``` 26 | 27 | or 28 | 29 | ``` 30 | easy_install lxml 31 | ``` 32 | 33 | The app is supposed to scrape Craigslist pages and publish (via Spacebrew) new posting headings any time they appear. 34 | 35 | Start with: 36 | 37 | ``` 38 | python spacebrew-casual.py 39 | ``` 40 | 41 | Exit with Ctrl+c -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape/spacebrew-casual.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import time 4 | import locale 5 | from spacebrewInterface.spacebrew import Spacebrew 6 | from lxml.html import parse 7 | from lxml.cssselect import CSSSelector 8 | 9 | # configure the spacebrew client 10 | name = "Casual Scraper" 11 | server = "sandbox.spacebrew.cc" 12 | brew = Spacebrew(name, server=server) 13 | brew.addPublisher("tick", "string") 14 | # brew.addSubscriber("incoming", "string") 15 | 16 | # def handleString(value): 17 | # print(value) 18 | 19 | # brew.subscribe("incoming", handleString) 20 | 21 | try: 22 | print("Starting spacebrew"); 23 | brew.start() 24 | 25 | base_urls = [ 26 | "http://newyork.craigslist.org/cas/", 27 | "http://philadelphia.craigslist.org/cas/", 28 | "http://sfbay.craigslist.org/cas/"] 29 | links = [] 30 | while 1: 31 | for base_url in base_urls: 32 | print "scraping %s" % base_url 33 | doc = parse(base_url).getroot() 34 | for link in doc.cssselect('p.row a'): 35 | if link.get('href') not in links: 36 | brew.publish('tick', link.text_content()) 37 | links.append( link.get('href') ) 38 | print '%s: %s' % (len(links), link.get('href')) 39 | time.sleep(2.5) 40 | 41 | # Catch ctrl+c 42 | except (KeyboardInterrupt, SystemExit): 43 | print("Exiting!") 44 | 45 | # closing out the app and returning terminal to old settings 46 | finally: 47 | print("Stopping spacebrew"); 48 | brew.stop() 49 | 50 | -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape/spacebrewInterface/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['spacebrew'] 2 | -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape2/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .DS_Store -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape2/README.md: -------------------------------------------------------------------------------- 1 | 2 | ____ __ 3 | /\ _`\ /\ \ 4 | \ \,\L\_\ _____ __ ___ __\ \ \____ _ __ __ __ __ __ 5 | \/_\__ \ /\ '__`\ /'__`\ /'___\ /'__`\ \ '__`\/\`'__\/'__`\/\ \/\ \/\ \ 6 | /\ \L\ \ \ \L\ \/\ \L\.\_/\ \__//\ __/\ \ \L\ \ \ \//\ __/\ \ \_/ \_/ \ 7 | \ `\____\ \ ,__/\ \__/.\_\ \____\ \____\\ \_,__/\ \_\\ \____\\ \___x___/' 8 | \/_____/\ \ \/ \/__/\/_/\/____/\/____/ \/___/ \/_/ \/____/ \/__//__/ 9 | \ \_\ 10 | \/_/ 11 | ____ 12 | /\ _`\ 13 | \ \,\L\_\ ___ _ __ __ _____ __ _ __ 14 | \/_\__ \ /'___\/\`'__\/'__`\ /\ '__`\ /'__`\/\`'__\ 15 | /\ \L\ \/\ \__/\ \ \//\ \L\.\_\ \ \L\ \/\ __/\ \ \/ 16 | \ `\____\ \____\\ \_\\ \__/.\_\\ \ ,__/\ \____\\ \_\ 17 | \/_____/\/____/ \/_/ \/__/\/_/ \ \ \/ \/____/ \/_/ 18 | \ \_\ 19 | \/_/ 20 | 21 | This example shows a simple implementation of [pySpacebrew](https://github.com/Spacebrew/pySpacebrew) and the Python Package [lxml](http://lxml.de/), so you will need to install lxml first. You can do so using [the instructions here](http://lxml.de/installation.html), but it should be as easy as easy as running 22 | 23 | ``` 24 | pip install lxml 25 | ``` 26 | 27 | or 28 | 29 | ``` 30 | easy_install lxml 31 | ``` 32 | 33 | The app is supposed to scrape Craigslist pages and publish (via Spacebrew) new posting headings any time they appear. 34 | 35 | Start with: 36 | 37 | ``` 38 | python spacebrew-casual.py 39 | ``` 40 | 41 | Exit with Ctrl+c -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape2/spacebrew-casual.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import time 4 | import locale 5 | from spacebrewInterface.spacebrew import Spacebrew 6 | from lxml.html import parse 7 | from lxml.cssselect import CSSSelector 8 | 9 | # configure the spacebrew client 10 | name = "Casual Scraper" 11 | server = "sandbox.spacebrew.cc" 12 | brew = Spacebrew(name, server=server) 13 | brew.addPublisher("image", "string") 14 | print("Starting spacebrew"); 15 | brew.start() 16 | 17 | 18 | base_urls = [ 19 | "http://newyork.craigslist.org/search/aap?hasPic=1", 20 | "http://philadelphia.craigslist.org/search/aap?hasPic=1", 21 | "http://sfbay.craigslist.org/search/aap?hasPic=1"] 22 | history = [] 23 | try: 24 | while 1: 25 | for base_url in base_urls: 26 | print "scraping %s" % base_url 27 | doc = parse(base_url).getroot() 28 | links = doc.cssselect('span.pl a') 29 | if links: 30 | for link in links: 31 | subdoc_url = link.get('href') 32 | subdoc = parse(subdoc_url).getroot() 33 | images = subdoc.cssselect('img#iwi') 34 | print "\t%s %d images" % (subdoc_url, len(images)) 35 | for image in images: 36 | img_url = image.get('src') 37 | if img_url not in images: 38 | print "\t\t%s" % (img_url) 39 | brew.publish('image', img_url) 40 | history.append( img_url ) 41 | else: 42 | print "No links found on "+base_url 43 | 44 | print 'Sent %d images' % len(history) 45 | time.sleep(2.5) 46 | # Catch ctrl+c 47 | except (KeyboardInterrupt, SystemExit): 48 | print("Exiting!") 49 | 50 | # closing out the app and returning terminal to old settings 51 | finally: 52 | print("Stopping spacebrew"); 53 | brew.stop() 54 | 55 | -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape2/spacebrewInterface/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['spacebrew'] 2 | -------------------------------------------------------------------------------- /Week_08/spacebrew-scrape2/untitled.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": "/Users/jeff/Documents/SpatialMedia/Week_08/spacebrew-scrape2" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /Week_08/spacebrew-twitter/README.md: -------------------------------------------------------------------------------- 1 | ____ __ __ 2 | /\ _`\ /\ \ /\ \ 3 | \ \,\L\_\ _____ __ ___ __\ \ \____ _ __ __ __ __ __ \_\ \___ 4 | \/_\__ \ /\ '__`\ /'__`\ /'___\ /'__`\ \ '__`\/\`'__\/'__`\/\ \/\ \/\ \ /\___ __\ 5 | /\ \L\ \ \ \L\ \/\ \L\.\_/\ \__//\ __/\ \ \L\ \ \ \//\ __/\ \ \_/ \_/ \ \/__/\ \_/ 6 | \ `\____\ \ ,__/\ \__/.\_\ \____\ \____\\ \_,__/\ \_\\ \____\\ \___x___/' \ \_\ 7 | \/_____/\ \ \/ \/__/\/_/\/____/\/____/ \/___/ \/_/ \/____/ \/__//__/ \/_/ 8 | \ \_\ 9 | \/_/ 10 | ______ __ __ 11 | /\__ _\ __/\ \__/\ \__ 12 | \/_/\ \/ __ __ __/\_\ \ ,_\ \ ,_\ __ _ __ 13 | \ \ \/\ \/\ \/\ \/\ \ \ \/\ \ \/ /'__`\/\`'__\ 14 | \ \ \ \ \_/ \_/ \ \ \ \ \_\ \ \_/\ __/\ \ \/ 15 | \ \_\ \___x___/'\ \_\ \__\\ \__\ \____\\ \_\ 16 | \/_/\/__//__/ \/_/\/__/ \/__/\/____/ \/_/ 17 | 18 | 19 | 20 | This app is essentailly the same as node-spacebrew except it implements the [statuses/filter](https://dev.twitter.com/docs/api/1.1/post/statuses/filter) API method of the Twitter API using the [twittern](https://github.com/AvianFlu/ntwitter) nodejs module. -------------------------------------------------------------------------------- /Week_08/spacebrew-twitter/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var Spacebrew = require('spacebrew') 7 | , twitter = require('ntwitter') // https://github.com/AvianFlu/ntwitter 8 | 9 | 10 | var keywords = "I'm listening to"; 11 | 12 | // 13 | // 1. Start up the Spacebrew client 14 | // 15 | 16 | var server = "sandbox.spacebrew.cc"; 17 | var name = "Keyword Tweeter"; 18 | var description = "A stream of twets that contain the words '"+keywords+"'"; 19 | var sb = new Spacebrew.Client( server, name, description ); 20 | 21 | sb.addPublish("tweet", "string", "A single tweet"); // create the publication feed 22 | // connect to spacbrew 23 | sb.connect(); 24 | 25 | 26 | 27 | 28 | // 29 | // 2. Now set up Twitter and access the Twitter Stream API 30 | // 31 | 32 | // Configure Twitter 33 | var twit = new twitter({ 34 | consumer_key: 'CuJDkgecdDtVNVa3wrvtQ', 35 | consumer_secret: 't9zzya77qkm7UkFmgQ0rniCziT11PoaUEQCthYGezY', 36 | access_token_key: '761368-NJ95le3zIfMW5XbRXZrZeaFVjFZofEPT9UeQkRTq78', 37 | access_token_secret: 'kW6MCgVAy9ZV0uTYTc8RDAFY8INFOQIMKYU4ZBOUTM' 38 | }); 39 | 40 | 41 | // Start the twitter stream 42 | // https://dev.twitter.com/docs/api/1.1/post/statuses/filter 43 | var filters = { 'track':keywords }; 44 | twit.stream('statuses/filter', filters, function(stream) { 45 | stream.on('data', function (data) { 46 | console.log(data.text); 47 | if(sb._isConnected) { 48 | sb.send("tweet", "string", data.text); 49 | } 50 | }); 51 | }); 52 | 53 | 54 | /* 55 | // https://dev.twitter.com/docs/api/1.1/get/statuses/sample 56 | twit.stream('statuses/sample', function(stream) { 57 | stream.on('data', function (data) { 58 | console.log(data.text); 59 | console.log("\n\n\n------------------\n\n\n"); 60 | }); 61 | }); 62 | */ 63 | 64 | -------------------------------------------------------------------------------- /Week_08/spacebrew-twitter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app" 7 | }, 8 | "dependencies": { 9 | "express": "3.1.0", 10 | "ejs": "*", 11 | "ws": "~0.4.25", 12 | "ntwitter": "~0.5.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Week_08/spacebrew-twitter/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } -------------------------------------------------------------------------------- /Week_08/spacebrew-twitter/routes/index.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * GET home page. 4 | */ 5 | 6 | exports.index = function(req, res){ 7 | res.render('index', { title: 'Express' }); 8 | }; -------------------------------------------------------------------------------- /Week_08/spacebrew-twitter/routes/user.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * GET users listing. 4 | */ 5 | 6 | exports.list = function(req, res){ 7 | res.send("respond with a resource"); 8 | }; -------------------------------------------------------------------------------- /Week_08/spacebrew-twitter/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | 8 |

<%= title %>

9 |

Welcome to <%= title %>

10 | 11 | -------------------------------------------------------------------------------- /Week_09/itunes-control/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Make sure to install the required modules before trying to run this app. 6 | 7 | cd /path/to/itunes-control 8 | npm install -------------------------------------------------------------------------------- /Week_09/itunes-control/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var util = require('util') 7 | , spotify = require('spotify') 8 | , spotify_app = require('spotify-node-applescript') 9 | , Spacebrew = require('spacebrew') 10 | 11 | var now = new Date().getTime() 12 | var nextSongChange = now + (1000 * 10); 13 | 14 | 15 | var server = "sandbox.spacebrew.cc"; 16 | var name = "Jeff's Spotify"; 17 | var description = "This app controls the Spotify app the machine on which it is running. Send strings to influence the next song."; 18 | var sb = new Spacebrew.Client( server, name, description ); 19 | sb.addSubscribe("words", "string"); 20 | sb.onStringMessage = function( name, value ){ 21 | 22 | var now = new Date().getTime(); 23 | if(name=="words" && now > nextSongChange) { 24 | 25 | var matches = value.match(/"([^"]+)"/i); 26 | if(matches && matches.length>0) 27 | { 28 | console.log( "QUOTE: " + matches[1] ); 29 | spotify.search({ type: 'track', query: matches[1] }, function(err, data) { 30 | if ( err ) { 31 | console.log('Error occurred: ' + err); 32 | } else { 33 | var track = null; 34 | for(var i=0; i -1) break; 37 | } 38 | 39 | if(track!=null) { 40 | console.log(track); 41 | console.log( util.format('PLAYING: %s - %s %s %s', track.name, track.href, track.artists[0].name, track.popularity) ); 42 | spotify_app.playTrack(track.href, function(){ 43 | console.log("PLAYING!"); 44 | nextSongChange = now + (1000 * 10); 45 | }); 46 | } else { 47 | console.log("Couldn't find a song!"); 48 | } 49 | } 50 | }); 51 | } else console.log("No quoted string found in "+value); 52 | } 53 | } 54 | 55 | sb.connect(); 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Week_09/itunes-control/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app" 7 | }, 8 | "dependencies": { 9 | "spotify": "~0.2.0", 10 | "spotify-node-applescript": "~0.2.1", 11 | "spacebrew": "0.0.1" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Week_09/simple-say/README.md: -------------------------------------------------------------------------------- 1 | 2 | This node app will connect to Spacebrew and open a subscriber called "words". It will then wait for strings on the "words" channel. When it receives a string, it will extract any words between quotes and read them aloud using [the OSX "say" command](http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/say.1.html). 3 | 4 | Make sure to install the required modules before trying to run this app. 5 | 6 | cd /path/to/simple-say 7 | npm install -------------------------------------------------------------------------------- /Week_09/simple-say/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var Spacebrew = require('spacebrew') 7 | , util = require('util') 8 | , exec = require('child_process').exec 9 | 10 | // 11 | // Set up Spacebrew to accept strings ont he "words" channel 12 | // 13 | var server = "sandbox.spacebrew.cc"; 14 | var name = "Simple 'say' Subscriber"; 15 | var description = ""; 16 | var sb = new Spacebrew.Client( server, name, description ); 17 | sb.addSubscribe("words", "string"); 18 | sb.onStringMessage = onStringMessage; 19 | sb.connect(); 20 | 21 | 22 | // 23 | // What do we do when we get an incoming string? 24 | // 25 | var voices = ["Agnes", "Kathy", "Princess", "Vicki", "Victoria", "Bruce", "Fred", "Junior", "Ralph", "Zarvox", "Cellos"]; 26 | var speaking = false; 27 | function onStringMessage( name, value ){ 28 | if(name=="words" && !speaking) { 29 | 30 | var matches = value.match(/"([^"]+)"/i); 31 | if(matches) { 32 | var quote = matches[1]; 33 | console.log( quote ); 34 | var voice = voices[Math.floor(Math.random()*voices.length)]; 35 | //var cmd = util.format('say -v %s -r 200 "%s"', voice, quote); 36 | var cmd = "say -v "+voice+" -r 200 "+'"'+quote+'"'; 37 | console.log( cmd ); 38 | 39 | speaking = true; 40 | exec(cmd, function(err, stdout, stderr){ 41 | speaking = false; 42 | }); // exec 43 | } 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Week_09/simple-say/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app" 7 | }, 8 | "dependencies": { 9 | "spacebrew": "0.0.1" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Week_09/twilio-test/README.md: -------------------------------------------------------------------------------- 1 | 2 | _____ _ 3 | (_ _) _ (_ ) _ 4 | | | _ _ _ (_) | | (_) _ 5 | | |( ) ( ) ( )| | | | | | /'_`\ 6 | | || \_/ \_/ || | | | | |( (_) ) 7 | (_)`\___x___/'(_)(___)(_)`\___/' 8 | 9 | 10 | ___ _ _ 11 | ( _`\ ( ) _ ( ) 12 | | (_(_) _ _ | |_ ___ ___ _ __ (_)| |_ __ _ __ 13 | `\__ \ ( ) ( )| '_`\ /',__) /'___)( '__)| || '_`\ /'__`\( '__) 14 | ( )_) || (_) || |_) )\__, \( (___ | | | || |_) )( ___/| | 15 | `\____)`\___/'(_,__/'(____/`\____)(_) (_)(_,__/'`\____)(_) 16 | 17 | 18 | 19 | [Twilio](http://www.twilio.com/) is a web service that makes it possible to easily send SMS and voice calls. And (surprise) it has [pretty nice documentation for use within node.js](http://twilio.github.com/twilio-node/). But the first step is to [create an account](https://www.twilio.com/try-twilio). 20 | 21 | **IMPORTANT**: Don't read the docuemntation at [https://github.com/sjwalter/node-twilio](https://github.com/sjwalter/node-twilio)!!! It's outdated/incorrect. Instead, read [the documentation on the twilio site]](http://twilio.github.com/twilio-node/) 22 | 23 | ### Voice Calls 24 | 25 | You can easily tell Twilio to make a voice call from within your application. You need to provide 3 things: 26 | 1. 27 | 28 | // Step 1: 29 | // Learn about localtunnel! http://progrium.com/localtunnel/ 30 | // localtunnel -k ~/.ssh/id_rsa.pub 3000 31 | // http://twilio.github.com/twilio-node/#validateExpressRequest 32 | // https://www.twilio.com/user/account 33 | // VERBS: http://www.twilio.com/docs/api/twiml -------------------------------------------------------------------------------- /Week_09/twilio-test/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var express = require('express') 7 | , http = require('http') 8 | , path = require('path') 9 | , twilio = require('twilio') 10 | , Spacebrew = require('spacebrew') 11 | , WordPOS = require('wordpos') 12 | , wordpos = new WordPOS() 13 | 14 | 15 | var app = express(); 16 | 17 | app.configure(function(){ 18 | app.set('port', process.env.PORT || 3000); 19 | app.set('views', __dirname + '/views'); 20 | app.set('view engine', 'ejs'); 21 | app.use(express.favicon()); 22 | app.use(express.logger('dev')); 23 | app.use(express.bodyParser()); 24 | app.use(express.methodOverride()); 25 | app.use(express.cookieParser('your secret here')); 26 | app.use(express.session()); 27 | app.use(app.router); 28 | app.use(express.static(path.join(__dirname, 'public'))); 29 | }); 30 | 31 | app.configure('development', function(){ 32 | app.use(express.errorHandler()); 33 | }); 34 | 35 | //Twilio request authentication 36 | app.post('/twiml', function(req, res) { 37 | if (twilio.validateExpressRequest(req, 'ced5bbb0b7f9f5ffe416abe9ff6b4f0b')) { 38 | res.type('text/xml'); 39 | var twilioResponse = new twilio.TwimlResponse(); 40 | twilioResponse.say(phoneMessage, {voice:'woman', language:'en-gb'}); 41 | res.send(twilioResponse.toString()); 42 | } else { 43 | res.send('you are not twilio. Buzz off.'); 44 | } 45 | }); 46 | 47 | http.createServer(app).listen(app.get('port'), function(){ 48 | console.log("Express server listening on port " + app.get('port')); 49 | }); 50 | 51 | 52 | 53 | // 54 | // Set up Spacebrew to accept strings ont he "words" channel 55 | // 56 | var server = "sandbox.spacebrew.cc"; 57 | var name = "Twilio Voice Caller"; 58 | var description = ""; 59 | var sb = new Spacebrew.Client( server, name, description ); 60 | sb.addSubscribe("words", "string"); 61 | sb.onStringMessage = onStringMessage; 62 | sb.connect(); 63 | 64 | 65 | 66 | var client = require('twilio')(YOUR_TWILIO_TOKEN, YOUR_TWILIO_SECRET); 67 | var adjectives = []; 68 | var phoneMessage = ""; 69 | function onStringMessage(name, value) { 70 | if(name=="words") { 71 | wordpos.getAdjectives(value, function(result){ 72 | 73 | result.forEach(function(word){ 74 | if(word.length > 5) adjectives.push( word ) 75 | }); 76 | console.log( adjectives ); 77 | 78 | if(adjectives.length > 15) { 79 | //Place a phone call, and respond with TwiML instructions from the given URL 80 | client.makeCall({ 81 | to:'+16462465999', // Any number Twilio can call 82 | from: '+13473217570', // A number you bought from Twilio and can use for outbound communication 83 | url: 'http://4zsw.localtunnel.com/twiml' // A URL that produces an XML document (TwiML) which contains instructions for the call 84 | }, function(err, responseData) { 85 | console.log(responseData.from); 86 | }); 87 | phoneMessage = adjectives.join(' '); 88 | adjectives = []; 89 | } 90 | }); 91 | } 92 | } 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /Week_09/twilio-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app" 7 | }, 8 | "dependencies": { 9 | "express": "3.1.0", 10 | "ejs": "*", 11 | "twilio": "~1.1.0", 12 | "wordpos": "~0.1.6", 13 | "ws": "~0.4.25", 14 | "spacebrew": "0.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Week_09/twilio-test/public/stylesheets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 50px; 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; 4 | } 5 | 6 | a { 7 | color: #00B7FF; 8 | } -------------------------------------------------------------------------------- /Week_09/twilio-test/response.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Welcome to Twilio! 4 | 5 | Please let us know if we can help during your development. 6 | http://www.example.com/some_sound.mp3 7 | -------------------------------------------------------------------------------- /Week_09/twilio-test/twilio-test.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": "/Users/jeff/Documents/SpatialMedia/Week_09/twilio-test" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /Week_09/twilio-test/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%= title %> 5 | 6 | 7 | 8 |

<%= title %>

9 |

Welcome to <%= title %>

10 | 11 | -------------------------------------------------------------------------------- /Week_09/youtube-upload/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Module dependencies. 4 | */ 5 | 6 | var util = require('util') 7 | , fs = require('fs') 8 | , exec = require('child_process').exec 9 | , Spacebrew = require('spacebrew') 10 | , youtube = require('youtube') 11 | , crypto = require('crypto') 12 | 13 | // 14 | // Set up Spacebrew to accept strings ont he "words" channel 15 | // 16 | var server = "sandbox.spacebrew.cc"; 17 | var name = "Youtube Uploader"; 18 | var description = "Accepts URLS of images. Generates a video and eventually uploads it to YouTube"; 19 | var sb = new Spacebrew.Client( server, name, description ); 20 | sb.addSubscribe("image", "string"); 21 | sb.onStringMessage = onStringMessage; 22 | sb.connect(); 23 | 24 | 25 | function getExtension(filename) { 26 | var ext = path.extname(filename||'').split('.'); 27 | return ext[ext.length - 1]; 28 | } 29 | 30 | 31 | // 32 | // What do we do when we get an incoming string? 33 | // 34 | var work_dir = [__dirname, crypto.randomBytes(8).toString('hex')].join('/'); 35 | fs.mkdirSync(work_dir); 36 | var n = 0; 37 | 38 | function onStringMessage( name, value ){ 39 | if(name=="image" && getExtension(value)=="jpg") { 40 | 41 | var path = util.format('%s/%s.jpg', work_dir, String('00000'+n).slice(-5)); 42 | var file = fs.createWriteStream(path); 43 | var request = http.get(value, function(response) { 44 | response.pipe(file); 45 | 46 | if(n>30) { 47 | makeMovie(work_dir); 48 | work_dir = [__dirname, crypto.randomBytes(8).toString('hex')].join('/'); 49 | fs.mkdirSync( work_dir ); 50 | n = 0; 51 | } 52 | }); 53 | n++; 54 | } 55 | } 56 | 57 | 58 | function makeMovie( dirname ) { 59 | 60 | var cmd = 'convert *.jpg -resize 800x600^ -gravity Center -crop 800x600+0+0 +repage %05d.jpg && ffmpeg -r 25 -qscale 2 -i %05d.jpg output.mp4'; 61 | exec(cmd, {cwd: dirname}, function(error, stdout, stderr){ 62 | var path = dirname+"/output.mp4"; 63 | 64 | if(error) { 65 | console.log(error); 66 | } else if(!fs.existsSync(path)) { 67 | console.log(path+" not generated!"); 68 | } else { 69 | 70 | var title = 'Spacebrew Output '+new Date().toJSON(); 71 | var description = "Some images sent through Spacebrew"; 72 | var category = 'Education'; 73 | var dev_key = 'myDevKey'; 74 | 75 | var video = youtube 76 | .createUpload(path) 77 | .user('jefftimesten@gmail.com') 78 | .source('jefftimesten') 79 | .password('myPassword') 80 | .key(dev_key) 81 | .title(title) 82 | .description(title) 83 | .category(category) 84 | .upload(function(err, res){ 85 | if (err) console.log(err); 86 | else { 87 | console.log('done'); 88 | console.log(res.id); 89 | console.log(res.url); 90 | console.log(res.embed()); 91 | console.log(res.embed(320, 320)); 92 | console.log(require('util').inspect(res, false, 15, true)); 93 | } 94 | }); 95 | } 96 | }); 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /Week_09/youtube-upload/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node app" 7 | }, 8 | "dependencies": { 9 | "express": "3.1.0", 10 | "ejs": "*", 11 | "ws": "~0.4.25", 12 | "youtube": "~0.1.0", 13 | "mime": "~1.2.9", 14 | "request": "~2.16.6", 15 | "xml2js": "~0.2.6", 16 | "qs": "~0.5.5", 17 | "spacebrew": "0.0.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/addons.make: -------------------------------------------------------------------------------- 1 | ofxLibwebsockets 2 | ofxSpacebrew 3 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/SpacebrewText/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/bin/data/Serif Neu.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/SpacebrewText/bin/data/Serif Neu.ttf -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/bin/data/planet_kosmos.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/SpacebrewText/bin/data/planet_kosmos.ttf -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/src/ofxExtrudedText.h: -------------------------------------------------------------------------------- 1 | // 2 | // ofxExtrudedText.h 3 | // SpacebrewText 4 | // 5 | // Created by Jeffrey Crouse on 4/7/13. 6 | // Copyright (c) 2013 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | 10 | #pragma once 11 | #include "ofMain.h" 12 | 13 | class ofxExtrudedText : public ofNode { 14 | public: 15 | vector meshes; 16 | void setup(string text, float depth, ofTrueTypeFont& font); 17 | void update(float deltaTime); 18 | virtual void customDraw(); 19 | ofRectangle bb; 20 | ofVec3f acc, vel, rotvel; 21 | string text; 22 | int verts; 23 | 24 | ofMesh getIndiciedMeshFromNonIndiciedMesh( ofMesh & mesh ); 25 | void calcNormals( ofMesh & mesh, bool bNormalize ); 26 | }; -------------------------------------------------------------------------------- /Week_10/Week_10_OF/SpacebrewText/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxSpacebrew.h" 5 | #include "ofxExtrudedText.h" 6 | 7 | class testApp : public ofBaseApp{ 8 | 9 | public: 10 | void setup(); 11 | void update(); 12 | void draw(); 13 | 14 | void keyPressed (int key); 15 | void keyReleased(int key); 16 | void mouseMoved(int x, int y ); 17 | void mouseDragged(int x, int y, int button); 18 | void mousePressed(int x, int y, int button); 19 | void mouseReleased(int x, int y, int button); 20 | void windowResized(int w, int h); 21 | void dragEvent(ofDragInfo dragInfo); 22 | void gotMessage(ofMessage msg); 23 | 24 | Spacebrew::Connection spacebrew; 25 | void onMessage( Spacebrew::Message & msg ); 26 | 27 | vector queue; 28 | 29 | float nextTweetAt, nextTweetInterval; 30 | ofTrueTypeFont font; 31 | vector fallingWords; 32 | 33 | float lastFrame; 34 | 35 | ofLight light; 36 | }; 37 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude01/addons.make -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude01/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/bin/data/planet_kosmos.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude01/bin/data/planet_kosmos.ttf -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/extrude01.xcodeproj/xcshareddata/xcschemes/extrude Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/src/Letter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Letter.cpp 3 | // extrude 4 | // 5 | // Created by Jeffrey Crouse on 10/24/12. 6 | // 7 | // 8 | 9 | #include "Letter.h" 10 | 11 | // ----------------------------------- 12 | void Letter::setup(ofPath letter, float depth) 13 | { 14 | // Tessellation is subdividing a concave polygon into convex polygons. 15 | front = letter.getTessellation(); 16 | back = front; 17 | 18 | // Loop through all of the vertices in the "back" mesh 19 | // and move them back in on the "z" axis 20 | vector& f = front.getVertices(); 21 | vector& b = back.getVertices(); 22 | for(int j=0; j< f.size(); j++) 23 | { 24 | f[j].z += depth/2.0; 25 | b[j].z -= depth/2.0; 26 | } 27 | } 28 | 29 | // ----------------------------------- 30 | void Letter::draw() 31 | { 32 | front.draw(); 33 | back.draw(); 34 | } -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/src/Letter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Letter.h 3 | // extrude 4 | // 5 | // Created by Jeffrey Crouse on 10/24/12. 6 | // 7 | // 8 | 9 | #pragma once 10 | #include "ofMain.h" 11 | 12 | class Letter { 13 | public: 14 | ofMesh front; 15 | ofMesh back; 16 | 17 | void setup(ofPath letter, float depth); 18 | void draw(); 19 | }; -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude01/src/testApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "Letter.h" 5 | 6 | 7 | class testApp : public ofBaseApp{ 8 | 9 | public: 10 | void setup(); 11 | void update(); 12 | void draw(); 13 | 14 | void keyPressed (int key); 15 | void keyReleased(int key); 16 | void mouseMoved(int x, int y ); 17 | void mouseDragged(int x, int y, int button); 18 | void mousePressed(int x, int y, int button); 19 | void mouseReleased(int x, int y, int button); 20 | void windowResized(int w, int h); 21 | void dragEvent(ofDragInfo dragInfo); 22 | void gotMessage(ofMessage msg); 23 | 24 | ofTrueTypeFont font; 25 | string text; 26 | ofRectangle bb; 27 | vector letters; 28 | 29 | bool bDrawWireframe; 30 | }; 31 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude02/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude02/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude02/addons.make -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude02/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude02/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude02/bin/data/planet_kosmos.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude02/bin/data/planet_kosmos.ttf -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude02/extrude02.xcodeproj/xcshareddata/xcschemes/extrude Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude02/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude02/src/Letter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Letter.cpp 3 | // extrude 4 | // 5 | // Created by Jeffrey Crouse on 10/24/12. 6 | // 7 | // 8 | 9 | #include "Letter.h" 10 | 11 | // ----------------------------------- 12 | void Letter::setup(ofPath letter, float depth) 13 | { 14 | // Tessellation is subdividing a concave polygon into convex polygons. 15 | front = letter.getTessellation(); 16 | back = front; 17 | 18 | // Loop through all of the vertices in the "back" mesh 19 | // and move them back in on the "z" axis 20 | vector& v = back.getVertices(); 21 | for(int j=0; j< v.size(); j++) 22 | { 23 | v[j].z -= depth; 24 | } 25 | 26 | 27 | // TIP - class heirarchy 28 | // an ofPath is basically a container for a bunch of ofPolyLines 29 | // an ofPolyline is a single, continuous line that has lots of useful functions 30 | // such as getSmoothed, getResampledBySpacing, getClosestPoint 31 | 32 | 33 | // The path of a letter may contain several different lines 34 | // Think about the inside of a shape with a hole like "O", "P", "D" 35 | vector lines = letter.getOutline(); 36 | for(int j=0; j& points = lines[j].getVertices(); 46 | int k; 47 | for(k=0; k letters; 28 | 29 | bool bDrawWireframe; 30 | }; 31 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude03/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude03/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude03/addons.make -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude03/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude03/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude03/bin/data/planet_kosmos.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/extrude03/bin/data/planet_kosmos.ttf -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude03/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/extrude03/src/Letter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Letter.cpp 3 | // extrude 4 | // 5 | // Created by Jeffrey Crouse on 10/24/12. 6 | // 7 | // 8 | 9 | #include "Letter.h" 10 | 11 | // ----------------------------------- 12 | void Letter::setup(ofPath letter, float depth) 13 | { 14 | // Tessellation is subdividing a concave polygon into convex polygons. 15 | front = letter.getTessellation(); 16 | back = front; 17 | 18 | // Loop through all of the vertices in the "back" mesh 19 | // and move them back in on the "z" axis 20 | vector& v = back.getVertices(); 21 | for(int j=0; j< v.size(); j++) 22 | { 23 | v[j].z -= depth; 24 | } 25 | 26 | 27 | // TIP - class heirarchy 28 | // an ofPath is basically a container for a bunch of ofPolyLines 29 | // an ofPolyline is a single, continuous line that has lots of useful functions 30 | // such as getSmoothed, getResampledBySpacing, getClosestPoint 31 | 32 | 33 | // The path of a letter may contain several different lines 34 | // Think about the inside of a shape with a hole like "O", "P", "D" 35 | vector lines = letter.getOutline(); 36 | for(int j=0; j& points = lines[j].getVertices(); 46 | int k; 47 | for(k=0; k letters; 28 | ofEasyCam cam; 29 | 30 | bool bDrawWireframe; 31 | }; 32 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 9 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 10 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/font/addons.make -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/font/bin/data/.gitkeep -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/bin/data/planet_kosmos.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffcrouse/SpatialMedia/96c8020727d5d8047e490f1871fa53fe7ae565b1/Week_10/Week_10_OF/font/bin/data/planet_kosmos.ttf -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/font.xcodeproj/xcshareddata/xcschemes/extrude Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/font.xcodeproj/xcshareddata/xcschemes/extrude Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 59 | 60 | 61 | 62 | 68 | 69 | 75 | 76 | 77 | 78 | 80 | 81 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.yourcompany.openFrameworks 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | 20 | 21 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "testApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( ){ 7 | 8 | ofAppGlutWindow window; 9 | ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context 10 | 11 | // this kicks off the running of my app 12 | // can be OF_WINDOW or OF_FULLSCREEN 13 | // pass in width and height too: 14 | ofRunApp( new testApp()); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Week_10/Week_10_OF/font/src/testApp.cpp: -------------------------------------------------------------------------------- 1 | #include "testApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | 6 | ofSetFrameRate(24); 7 | ofBackground(0); 8 | 9 | // Load the font 10 | string filename = "planet_kosmos.ttf"; 11 | int fontSize = 320; 12 | bool bAntiAliased = false; 13 | bool bFullCharacterSet = true; 14 | bool makeContours = true; 15 | float simplifyAmt = 0.3; // uses ofPolyline::simplify 16 | font.loadFont(filename, fontSize, bAntiAliased, bFullCharacterSet, makeContours, simplifyAmt); 17 | 18 | 19 | // Get the bounding box of the text 20 | text = "Spatial\nMedia"; 21 | bb = font.getStringBoundingBox(text, 0, 0); 22 | } 23 | 24 | //-------------------------------------------------------------- 25 | void testApp::update(){ 26 | 27 | } 28 | 29 | //-------------------------------------------------------------- 30 | void testApp::draw(){ 31 | ofBackground(0); 32 | 33 | int nVerts = 0; 34 | 35 | 36 | ofNoFill(); 37 | ofPushMatrix(); 38 | { 39 | ofTranslate((ofGetWidth()/2.0)-(bb.getWidth()/2.0), (ofGetHeight()/2.0)+(bb.height/4.0)); 40 | 41 | // Create a bunch of Letter objects 42 | vector letterPaths = font.getStringAsPoints(text); 43 | for(int i=0; i lines = letterPaths[i].getOutline(); 46 | for(int j=0; j 0) { 56 | var doc = docs[0]; 57 | console.log(doc); 58 | sb.send("vineVideo", "string", doc.link); 59 | sb.send("vineTweet", "string", doc.text); 60 | } 61 | }); 62 | }); 63 | } 64 | setInterval(sendVines, 1000); 65 | 66 | sb.connect(); 67 | 68 | -------------------------------------------------------------------------------- /Week_10/viner/vine.js: -------------------------------------------------------------------------------- 1 | 2 | var request = require("request") 3 | , twitter = require("ntwitter") 4 | , twit = new twitter() 5 | , params = { include_entities: true, since_id: null }; 6 | 7 | 8 | module.exports.getVines = function(keywords, callback) { 9 | var query = "vine.co/v/ AND ("+keywords+")"; 10 | var vines = []; 11 | 12 | twit.search(query, params, function(err, data) { 13 | if(err) { 14 | callback(err); 15 | return; 16 | } else { 17 | params.since_id = data.max_id; 18 | var remaining = data.results.length; 19 | 20 | data.results.forEach(function(tweet){ 21 | var vine_url = null; 22 | tweet.entities.urls.forEach(function(url){ 23 | if( url.expanded_url.split("//")[1].indexOf("vine.co/v/") > -1 ) { 24 | vine_url = url.expanded_url+"/card"; 25 | } 26 | }); 27 | if(!vine_url) return; 28 | 29 | request(vine_url, function (error, response, body) { 30 | if (error) { 31 | console.log("Error fetching "+vine_url+": "+error); 32 | } else { 33 | var matches = body.match(/