├── .gitignore ├── 01_drawSample ├── addons.make ├── bin │ └── data │ │ └── .gitkeep ├── config.make └── src │ ├── eyebox.cpp │ ├── eyebox.h │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 02_particles_and_noise ├── addons.make ├── bin │ └── data │ │ └── .gitkeep ├── config.make └── src │ ├── Particle.cpp │ ├── Particle.hpp │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 03_shootTheFinger ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ ├── boom.mp3 │ │ └── settings.xml ├── config.make └── src │ ├── Particle.cpp │ ├── Particle.hpp │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 04_basicTracking ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ ├── settings.xml │ │ └── test.JPG ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 05_3D_space ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── space.jpg ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 06_Arduino ├── addons.make ├── arduino_code │ └── arduino_code.ino ├── bin │ └── data │ │ ├── .gitkeep │ │ ├── 1085.mp3 │ │ ├── OstrichSans-Heavy.otf │ │ ├── disc.png │ │ └── frabk.ttf ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 07_Networking_BigScreen ├── BigScreenClient │ ├── addons.make │ ├── bin │ │ └── data │ │ │ └── .gitkeep │ ├── config.make │ └── src │ │ ├── main.cpp │ │ ├── ofApp.cpp │ │ └── ofApp.h └── BigScreenServer │ ├── addons.make │ ├── bin │ └── data │ │ ├── .gitkeep │ │ └── VarelaRound-Regular.ttf │ ├── config.make │ └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 08_Pointers_and_UI ├── PassingData │ ├── addons.make │ ├── bin │ │ └── data │ │ │ └── .gitkeep │ ├── config.make │ └── src │ │ ├── main.cpp │ │ ├── ofApp.cpp │ │ ├── ofApp.h │ │ ├── test.cpp │ │ └── test.hpp ├── UI │ ├── addons.make │ ├── bin │ │ └── data │ │ │ ├── .gitkeep │ │ │ └── settings.xml │ ├── config.make │ └── src │ │ ├── main.cpp │ │ ├── ofApp.cpp │ │ ├── ofApp.h │ │ ├── uiNode.cpp │ │ └── uiNode.hpp └── UISoundplayer │ ├── addons.make │ ├── bin │ └── data │ │ ├── .gitkeep │ │ └── settings.xml │ ├── config.make │ └── src │ ├── main.cpp │ ├── ofApp.cpp │ ├── ofApp.h │ ├── uiNode.cpp │ └── uiNode.hpp ├── 09_Kaleidoscope ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── CYstTNNUsAA0uKp.jpg ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── 10_genetic_algorigthm ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── settings.xml ├── config.make └── src │ ├── DNA.cpp │ ├── DNA.hpp │ ├── Obstacle.h │ ├── Rocket.cpp │ ├── Rocket.hpp │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── INSTALL.md ├── Images ├── 10_Kaleidoscope.png ├── 1_drawSample.png ├── 1_install.png ├── 2_install.png ├── 2_particles_and_noise.jpg ├── 3_shootTheFinger.png ├── 4_basicTracking.png ├── 5_3D_space.png ├── 6_arduino.png ├── 7_Networking_OSC.png ├── 9_UI_and_sound.png └── extra_particles.png ├── OSCProxy ├── addons.make ├── bin │ └── data │ │ └── .gitkeep ├── config.make └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── README.md ├── extra_particles_noise1 ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── text.jpg ├── config.make └── src │ ├── Particle.cpp │ ├── Particle.hpp │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── extra_particles_noise2 ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ └── settings.xml ├── config.make └── src │ ├── Particle.cpp │ ├── Particle.hpp │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── extra_shooter_game ├── addons.make ├── bin │ └── data │ │ ├── .gitkeep │ │ ├── boem.mp3 │ │ ├── boem2.mov │ │ └── laser.mp3 ├── config.make └── src │ ├── Particle.cpp │ ├── Particle.hpp │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h └── goniCircle ├── addons.make ├── bin └── data │ └── .gitkeep ├── config.make └── src ├── main.cpp ├── ofApp.cpp └── ofApp.h /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | 3 | Makefile 4 | 5 | [Bb]uild/ 6 | [Oo]bj/ 7 | *.o 8 | **/[Dd]ebug*/ 9 | **/[Rr]elease*/ 10 | **/gcc-debug/ 11 | **/gcc-release/ 12 | *.mode* 13 | *.app/ 14 | *.pyc 15 | .svn/ 16 | *.log 17 | *.cpp.eep 18 | *.cpp.elf 19 | *.cpp.hex 20 | 21 | **/bin/*.dll 22 | **/bin/*.exe 23 | **/bin/*.ilk 24 | **/bin/*.exp 25 | **/bin/*.pdb 26 | **/bin/*.lib 27 | **/data/sounds 28 | 29 | # XCode 30 | *.xcodeproj 31 | Project.xcconfig 32 | openFrameworks-Info.plist 33 | ofxiOS-Info.plist 34 | ofxiOS_Prefix.pch 35 | 36 | # Code::Blocks 37 | *.cbp 38 | *.workspace 39 | 40 | # Visual Studio 41 | *.sln 42 | *.vcxproj 43 | *.vcxproj.user 44 | *.vcxproj.filters 45 | 46 | 47 | 48 | 49 | 50 | ipch/ 51 | 52 | 53 | # OSX 54 | .DS_Store 55 | *.swp 56 | *~.nib 57 | # Thumbnails 58 | ._* 59 | 60 | # Windows 61 | # Windows image file caches 62 | Thumbs.db 63 | # Folder config file 64 | Desktop.ini 65 | -------------------------------------------------------------------------------- /01_drawSample/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/01_drawSample/addons.make -------------------------------------------------------------------------------- /01_drawSample/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/01_drawSample/bin/data/.gitkeep -------------------------------------------------------------------------------- /01_drawSample/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /01_drawSample/src/eyebox.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // eyebox.cpp 3 | // drawSample 4 | // 5 | // Created by Kris Meeusen on 11/02/15. 6 | // 7 | // 8 | 9 | #include "eyebox.h" 10 | 11 | void eyeBox::setup(ofVec2f center,float width){ 12 | 13 | mWidth = width; 14 | 15 | mCenter = center; 16 | 17 | blinkOnTime = 1; 18 | setNextBlink(); 19 | createNewEye(); 20 | } 21 | 22 | 23 | void eyeBox::createNewEye(){ 24 | circleResolution = ofRandom(3,12); 25 | 26 | float colorSwitch = ofRandom(0, 14); 27 | 28 | if(colorSwitch < 5){ 29 | backgroundColor.set(255, 0, 0); 30 | } 31 | else if(colorSwitch < 10) 32 | { 33 | backgroundColor.set(0, 255, 255); 34 | } 35 | else 36 | { 37 | backgroundColor.set(255, ofRandom(200,255), 0); 38 | } 39 | 40 | mWidth = ofRandom(10,50); 41 | eye.set(0 ,mWidth * 0.4); 42 | 43 | float eyeSizeMultiplier = ofRandom(1, 3); 44 | 45 | eyeRadiusSmall = mWidth / 8; 46 | eyeRadiusBig = mWidth / 3; 47 | 48 | eyeRadiusBig *= eyeSizeMultiplier; 49 | eyeRadiusSmall *= eyeSizeMultiplier; 50 | 51 | } 52 | 53 | 54 | void eyeBox::update(){ 55 | // std::cout << ofGetElapsedTimeMillis() << std::endl; 56 | 57 | if(doBlinkTime > -1 && (ofGetElapsedTimeMillis() - doBlinkTime) > nextBlinkTime){ 58 | blinkOnTime = ofGetElapsedTimeMillis(); 59 | doBlinkTime = -1; 60 | createNewEye(); 61 | } 62 | 63 | 64 | if(blinkOnTime > -1 && (ofGetElapsedTimeMillis()-blinkOnTime) > maxBlinkTime){ 65 | blinkOnTime = -1; 66 | setNextBlink(); 67 | } 68 | 69 | 70 | mouseDistance = (mCenter - ofVec2f(ofGetMouseX(),ofGetMouseY() )); 71 | 72 | if (fabs(mouseDistance.length()) < mWidth*2) { 73 | createNewEye(); 74 | } 75 | 76 | } 77 | 78 | 79 | void eyeBox::setNextBlink(){ 80 | 81 | doBlinkTime = ofGetElapsedTimeMillis(); 82 | maxBlinkTime = ofRandom(2000, 40000); 83 | nextBlinkTime = ofRandom(20 * 1000, 100 * 1000); 84 | 85 | } 86 | 87 | void eyeBox::draw(){ 88 | 89 | 90 | ofSetColor(backgroundColor); 91 | 92 | 93 | ofVec2f movingCenter = mCenter; 94 | movingCenter.y += (sin(ofGetElapsedTimef() * 0.5 + (mCenter.y* 20)) * 6.0f); 95 | 96 | 97 | // draw body 98 | ofSetCircleResolution(circleResolution); 99 | ofDrawCircle(movingCenter + eye, mWidth); 100 | 101 | ofPoint absoluteEyePos = mCenter + eye; 102 | 103 | // outer eye background 104 | ofSetColor(backgroundColor * 0.9); 105 | ofDrawCircle(absoluteEyePos,eyeRadiusBig + 10); 106 | 107 | // inner eye 108 | if(blinkOnTime <= 0){ 109 | ofSetLineWidth(3); 110 | 111 | 112 | ofSetColor(255, 255, 255); 113 | ofDrawCircle(absoluteEyePos,eyeRadiusBig); 114 | 115 | 116 | float maxLength = MIN((eyeRadiusBig-eyeRadiusSmall) * 0.8,mouseDistance.length()); 117 | 118 | ofVec2f mouseDiv = mouseDistance.getNormalized() * maxLength; 119 | ofSetColor(20, 20, 26); 120 | ofDrawCircle(absoluteEyePos - mouseDiv , eyeRadiusSmall ); 121 | } 122 | 123 | 124 | 125 | } 126 | 127 | -------------------------------------------------------------------------------- /01_drawSample/src/eyebox.h: -------------------------------------------------------------------------------- 1 | // 2 | // eyebox.h 3 | // drawSample 4 | // 5 | // Created by Kris Meeusen on 11/02/15. 6 | // 7 | // 8 | 9 | #ifndef __drawSample__eyebox__ 10 | #define __drawSample__eyebox__ 11 | 12 | #include 13 | #include "ofMain.h" 14 | 15 | class eyeBox{ 16 | 17 | ofVec2f mCenter; 18 | ofVec2f eye; 19 | ofVec2f mouseDistance; 20 | 21 | ofColor backgroundColor; 22 | 23 | int circleResolution; 24 | 25 | float mWidth; 26 | 27 | float eyeRadiusSmall; 28 | float eyeRadiusBig; 29 | 30 | float doBlinkTime; 31 | float blinkOnTime; 32 | float maxBlinkTime; 33 | float nextBlinkTime; 34 | 35 | void setNextBlink(); 36 | 37 | public: 38 | 39 | void setup(ofVec2f center,float width); 40 | void createNewEye(); 41 | void update(); 42 | void draw(); 43 | }; 44 | 45 | #endif /* defined(__drawSample__eyebox__) */ 46 | -------------------------------------------------------------------------------- /01_drawSample/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /01_drawSample/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | float lastRender; 4 | 5 | 6 | 7 | 8 | //-------------------------------------------------------------- 9 | void ofApp::setup(){ 10 | 11 | 12 | for (int x=0; x < 25; ++x) { 13 | for (int y=0; y < 14; ++y) { 14 | eyeBox eye; 15 | eye.setup(ofVec2f(10 + x * 90,10 + y * 90),ofRandom(10,50)); 16 | eyes.push_back(eye); 17 | } 18 | } 19 | 20 | 21 | ofSetCircleResolution(6); 22 | ofEnableAntiAliasing(); 23 | 24 | ofHideCursor(); 25 | ofSetFrameRate(60); 26 | 27 | } 28 | 29 | //-------------------------------------------------------------- 30 | void ofApp::update(){ 31 | for (eyeBox& eye : eyes) { 32 | eye.update(); 33 | } 34 | } 35 | 36 | //-------------------------------------------------------------- 37 | void ofApp::draw(){ 38 | 39 | // uncomment this to see how a shape is composed 40 | //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 41 | 42 | // use the & sign to create a reference instead of a copy. 43 | for (eyeBox& eye : eyes) { 44 | eye.draw(); 45 | } 46 | 47 | 48 | // adjust mouse cursor 49 | ofPushMatrix(); 50 | ofTranslate(ofGetMouseX(), ofGetMouseY()); 51 | ofRotate(ofGetElapsedTimeMillis()/4); 52 | ofSetColor(255,255,255); 53 | ofDrawCircle(0, 0, 10); 54 | ofPopMatrix(); 55 | 56 | 57 | ofDrawBitmapStringHighlight(ofToString(ofGetFrameRate()), 10, 10); 58 | 59 | } 60 | 61 | //-------------------------------------------------------------- 62 | void ofApp::keyPressed(int key){ 63 | if(key == 'f'){ 64 | ofToggleFullscreen(); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /01_drawSample/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "eyebox.h" 5 | 6 | class ofApp : public ofBaseApp{ 7 | 8 | std::vector eyes; 9 | 10 | public: 11 | void setup(); 12 | void update(); 13 | void draw(); 14 | 15 | void keyPressed(int key); 16 | 17 | 18 | }; 19 | -------------------------------------------------------------------------------- /02_particles_and_noise/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/02_particles_and_noise/addons.make -------------------------------------------------------------------------------- /02_particles_and_noise/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/02_particles_and_noise/bin/data/.gitkeep -------------------------------------------------------------------------------- /02_particles_and_noise/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /02_particles_and_noise/src/Particle.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Particle.hpp" 3 | 4 | 5 | 6 | void Particle::setup(){ 7 | // this will add small hue variations. 8 | hueOffset = ofRandom(-20,20); 9 | } 10 | 11 | void Particle::update(){ 12 | position += (direction * speed); 13 | } 14 | 15 | 16 | void Particle::draw(){ 17 | 18 | // mapping speed to hsl values. 19 | // this will result in particle colors changing 20 | // according to speed 21 | float hue = ofMap(speed, 0.5, 22, 170,290); 22 | float brigthness = ofMap(speed, 0.1, 14, 200,255); 23 | float sat = ofMap(speed,33.5, 0, 0,255,true); 24 | 25 | ofColor newColor = ofColor::fromHsb(hue + hueOffset, sat, 255, 255); 26 | ofSetColor(newColor); 27 | 28 | // changing the linelength and width according to the 29 | // speed 30 | // using pow to make big values pop-out more 31 | float lineLength = fmax(pow(speed,1.2) * .5, 12.4); 32 | float lineWidth = fmax(pow(speed,1.1) * .1, 0.5); 33 | 34 | ofSetLineWidth(lineWidth); 35 | ofDrawLine(position, position + (direction * lineLength)); 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /02_particles_and_noise/src/Particle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | 4 | 5 | class Particle{ 6 | 7 | float hueOffset; 8 | 9 | public: 10 | 11 | ofVec2f position; 12 | ofVec2f direction; 13 | float speed; 14 | 15 | void setup(); 16 | void update(); 17 | void draw(); 18 | 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /02_particles_and_noise/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /02_particles_and_noise/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | 4 | 5 | 6 | //-------------------------------------------------------------- 7 | void ofApp::setup(){ 8 | 9 | ofSetFrameRate(60); 10 | 11 | //ofSetFullscreen(); 12 | ofHideCursor(); 13 | 14 | for(int i =0; i < 3500; i++){ 15 | 16 | Particle p; 17 | p.setup(); 18 | setParticleStartPosition(p.position); 19 | setParticleStartDirection(p.direction); 20 | 21 | particles.push_back(p); 22 | 23 | } 24 | } 25 | 26 | 27 | void ofApp::setParticleStartPosition(ofVec2f& incomingPosition){ 28 | 29 | float xRandom = ofRandom(-ofGetWindowWidth(), 0); 30 | float yRandom = ofRandom(500, ofGetHeight() - 500); 31 | 32 | incomingPosition.set(xRandom,yRandom); 33 | } 34 | 35 | 36 | void ofApp::setParticleStartDirection(ofVec2f& incomingDirection){ 37 | 38 | float xDirRandom = ofRandom(0.7,1.0); 39 | float yDirRandom = ofRandom(-0.1,0.1); 40 | 41 | incomingDirection.set(xDirRandom,yDirRandom); 42 | } 43 | 44 | 45 | 46 | //-------------------------------------------------------------- 47 | void ofApp::update(){ 48 | 49 | for(int i=0; i < particles.size(); i++){ 50 | 51 | 52 | // decide where to sample in the 2D noisemap 53 | // by multiplying the particle x and y we stretch the shape. 54 | // by adding the time to the x postion we slide horizontally through the noisemap. 55 | 56 | float noiseSamplePositionX = particles[i].position.x * 0.001 + (ofGetElapsedTimef() * 0.55); 57 | float noiseSamplePositionY = particles[i].position.y * 0.001; // + (ofGetElapsedTimef() * 0.001); 58 | 59 | // signed noise will give us a result between -1 and 1 60 | float noiseYDirection = ofSignedNoise(noiseSamplePositionX , noiseSamplePositionY); 61 | noiseYDirection *= 0.88; 62 | 63 | // bending the current y direction to the new calculated noiseResult. 64 | // the interpolation factor decides how much we take from new direction. 65 | float interpolationFactor = 0.023; 66 | particles[i].direction.y += (noiseYDirection - particles[i].direction.y) * interpolationFactor; 67 | 68 | 69 | // now we change the speed 70 | float newSpeed = ofNoise(noiseSamplePositionX * 0.2 , noiseSamplePositionY * 0.8) * 4.0f; 71 | // we use a pow to make the fast ones faster. 72 | newSpeed = pow(newSpeed,2.7); 73 | // add a minimum speed 74 | newSpeed += 2; 75 | 76 | // the interpolation factor decides how much we take from new direction. 77 | interpolationFactor = 0.1; 78 | // we calculate the difference between the wanted and current speed. 79 | // than use the the interpolationFactor to decide how much we take from the difference 80 | particles[i].speed += (newSpeed - particles[i].speed) * interpolationFactor; 81 | 82 | 83 | particles[i].update(); 84 | 85 | // reset the particle when outsides the screen. 86 | if(particles[i].position.x > ofGetWindowWidth()){ 87 | setParticleStartPosition(particles[i].position); 88 | setParticleStartDirection(particles[i].direction); 89 | } 90 | } 91 | 92 | } 93 | 94 | 95 | 96 | //-------------------------------------------------------------- 97 | void ofApp::draw(){ 98 | 99 | ofClear(2,0,23); 100 | 101 | for(int i=0; i < particles.size(); i++){ 102 | particles[i].draw(); 103 | } 104 | 105 | // using a circle as mousecursor 106 | ofSetColor(255, 255, 255); 107 | ofDrawCircle(ofGetMouseX(), ofGetMouseY(), 4); 108 | 109 | } 110 | 111 | 112 | 113 | 114 | //-------------------------------------------------------------- 115 | void ofApp::mouseMoved(int x, int y ){ 116 | 117 | } 118 | 119 | //-------------------------------------------------------------- 120 | void ofApp::mouseDragged(int x, int y, int button){ 121 | 122 | } 123 | 124 | //-------------------------------------------------------------- 125 | void ofApp::mousePressed(int x, int y, int button){ 126 | 127 | } 128 | 129 | //-------------------------------------------------------------- 130 | void ofApp::mouseReleased(int x, int y, int button){ 131 | 132 | } 133 | 134 | -------------------------------------------------------------------------------- /02_particles_and_noise/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "Particle.hpp" 5 | 6 | 7 | class ofApp : public ofBaseApp{ 8 | 9 | 10 | vector particles; 11 | 12 | void setParticleStartPosition(ofVec2f& incomingPosition); 13 | void setParticleStartDirection(ofVec2f& incomingDirection); 14 | 15 | public: 16 | void setup(); 17 | void update(); 18 | void draw(); 19 | 20 | void mouseMoved(int x, int y ); 21 | void mouseDragged(int x, int y, int button); 22 | void mousePressed(int x, int y, int button); 23 | void mouseReleased(int x, int y, int button); 24 | 25 | }; 26 | -------------------------------------------------------------------------------- /03_shootTheFinger/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/03_shootTheFinger/addons.make -------------------------------------------------------------------------------- /03_shootTheFinger/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/03_shootTheFinger/bin/data/.gitkeep -------------------------------------------------------------------------------- /03_shootTheFinger/bin/data/boom.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/03_shootTheFinger/bin/data/boom.mp3 -------------------------------------------------------------------------------- /03_shootTheFinger/bin/data/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 45 3 | 405 4 | 2115 5 | 6 | -------------------------------------------------------------------------------- /03_shootTheFinger/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /03_shootTheFinger/src/Particle.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Particle.cpp 3 | // shootTheFinger 4 | // 5 | // Created by Kris Meeusen on 23/02/16. 6 | // 7 | // 8 | 9 | #include "Particle.hpp" 10 | 11 | 12 | Particle::Particle(){ 13 | isActive = false; 14 | 15 | } 16 | 17 | void Particle::set(ofVec2f startPosition){ 18 | position.set(startPosition); 19 | direction.set(0, ofRandom(-2,-10)); 20 | 21 | isActive = true; 22 | } 23 | 24 | 25 | 26 | void Particle::update(){ 27 | 28 | if(!isActive) return; 29 | 30 | position += direction; 31 | 32 | 33 | mDrawPosition1 = position; 34 | // mDrawPosition1.x += (ofSignedNoise(position.x, ofGetElapsedTimef() * .8f) * 3.0f); 35 | 36 | 37 | mDrawPosition2 = mDrawPosition1 + (direction * 6); 38 | 39 | if(position.y < -20 || position.x < -20 || position.x > ofGetWindowWidth() || position.y > ofGetWindowHeight()) isActive = false; 40 | 41 | } 42 | 43 | 44 | void Particle::draw(){ 45 | if(!isActive) return; 46 | // ofColor(color); 47 | 48 | // ofSetLineWidth(1 + direction.length() * 0.5); 49 | 50 | ofSetColor(color.r,color.g,color.b); 51 | ofDrawLine(mDrawPosition1,mDrawPosition2); 52 | } 53 | -------------------------------------------------------------------------------- /03_shootTheFinger/src/Particle.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Particle.hpp 3 | // shootTheFinger 4 | // 5 | // Created by Kris Meeusen on 23/02/16. 6 | // 7 | // 8 | 9 | #ifndef Particle_hpp 10 | #define Particle_hpp 11 | 12 | #include 13 | #include "ofMain.h" 14 | 15 | class Particle { 16 | 17 | public: 18 | bool isActive; 19 | 20 | ofVec2f direction; 21 | ofVec2f position; 22 | 23 | ofVec2f mDrawPosition1; 24 | ofVec2f mDrawPosition2; 25 | 26 | ofColor color; 27 | 28 | void set(ofVec2f startPosition); 29 | void update(); 30 | void draw(); 31 | 32 | bool hitTest; 33 | 34 | Particle(); 35 | 36 | 37 | }; 38 | 39 | 40 | #endif /* Particle_hpp */ 41 | -------------------------------------------------------------------------------- /03_shootTheFinger/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /03_shootTheFinger/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | 4 | //-------------------------------------------------------------- 5 | void ofApp::setup(){ 6 | 7 | grabberSize.set(320, 240); 8 | processSize.set(320, 240); 9 | 10 | // vidGrabber.setDeviceID(1); 11 | // vidGrabber.listDevices(); 12 | vidGrabber.setVerbose(true); 13 | vidGrabber.setup(grabberSize.x,grabberSize.y); 14 | 15 | colorImg.allocate(grabberSize.x,grabberSize.y); 16 | grayImage.allocate(processSize.x,processSize.y); 17 | grayBg.allocate(processSize.x,processSize.y); 18 | grayDiff.allocate(processSize.x,processSize.y); 19 | 20 | bLearnBakground = true; 21 | bDebug = false; 22 | 23 | gui.setup(); // most of the time you don't need a name 24 | gui.add(thresholdSlider.setup("threshold", 40, 1, 300)); 25 | gui.add(minArea.setup("minArea", 40, 1, 3000)); 26 | gui.add(maxArea.setup("maxArea", 540, 1, 3000)); 27 | 28 | 29 | scale = 3; 30 | reset(); 31 | 32 | ofSetCircleResolution(50); 33 | ofSetFrameRate(60); 34 | 35 | cout << vidGrabber.getWidth() << " x " < particles; 45 | ofVec2f explosionPosition; 46 | 47 | public: 48 | void setup(); 49 | void update(); 50 | void draw(); 51 | 52 | void reset(); 53 | void boem(ofVec2f b); 54 | 55 | void keyPressed(int key); 56 | 57 | }; 58 | -------------------------------------------------------------------------------- /04_basicTracking/addons.make: -------------------------------------------------------------------------------- 1 | ofxGui 2 | ofxOpenCv 3 | -------------------------------------------------------------------------------- /04_basicTracking/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/04_basicTracking/bin/data/.gitkeep -------------------------------------------------------------------------------- /04_basicTracking/bin/data/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 1182.2 3 | 184813 4 | 178.5 5 | 0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /04_basicTracking/bin/data/test.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/04_basicTracking/bin/data/test.JPG -------------------------------------------------------------------------------- /04_basicTracking/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /04_basicTracking/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /04_basicTracking/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | 6 | gui.setup(); 7 | gui.add(minArea.setup("circle minArea", 5, 3, 1024*768 * 0.01)); 8 | gui.add(maxArea.setup("circle maxArea", 5, 3, 1024*768 * 0.5)); 9 | gui.add(threshold.setup("threshold", 5, 0, 255)); 10 | gui.add(debugOn.setup("debug", false)); 11 | 12 | gui.loadFromFile("settings.xml"); 13 | 14 | // loading of the demo image 15 | testImage.load("test.JPG"); 16 | 17 | float w = testImage.getWidth(); 18 | float h = testImage.getHeight(); 19 | 20 | colorImg.allocate(w,h); 21 | grayImage.allocate(w,h); 22 | 23 | ofSetCircleResolution(30); 24 | ofEnableAlphaBlending(); 25 | } 26 | 27 | 28 | 29 | //-------------------------------------------------------------- 30 | void ofApp::update(){ 31 | 32 | // convert the testimage to a opencv image 33 | colorImg.setFromPixels(testImage.getPixels()); 34 | // convert the color image tot grayscale 35 | grayImage = colorImg; 36 | 37 | grayImage.invert(); 38 | grayImage.threshold(threshold); 39 | 40 | contourFinder.findContours(grayImage, minArea, maxArea, 10, false); 41 | 42 | 43 | 44 | 45 | 46 | } 47 | 48 | //-------------------------------------------------------------- 49 | void ofApp::draw(){ 50 | 51 | ofSetHexColor(0xffffff); 52 | 53 | colorImg.draw(0, 0); 54 | 55 | 56 | if(debugOn){ 57 | ofSetHexColor(0xffffff); 58 | 59 | grayImage.draw(0,0); 60 | 61 | for (int i = 0; i < contourFinder.nBlobs; i++){ 62 | ofSetColor(255, 255, 250); 63 | contourFinder.blobs[i].draw(0,0); 64 | } 65 | } 66 | 67 | 68 | ofSetLineWidth(5); 69 | 70 | 71 | 72 | 73 | for (int i = 0; i < contourFinder.nBlobs; i++){ 74 | ofVec2f blobCenter = contourFinder.blobs[i].centroid; 75 | 76 | 77 | ofVec2f endPoint = ofVec2f(cos(ofGetElapsedTimef()),sin(ofGetElapsedTimef())); 78 | endPoint *=163.0; 79 | endPoint += blobCenter; 80 | 81 | ofFill(); 82 | 83 | ofSetColor(255, 20,200 ,120); 84 | ofDrawCircle(blobCenter,100); 85 | 86 | ofDrawLine(blobCenter, endPoint); 87 | 88 | } 89 | 90 | 91 | gui.draw(); 92 | 93 | } 94 | -------------------------------------------------------------------------------- /04_basicTracking/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | #include "ofxOpenCv.h" 6 | #include "ofxGui.h" 7 | 8 | 9 | class ofApp : public ofBaseApp{ 10 | 11 | public: 12 | void setup(); 13 | void update(); 14 | void draw(); 15 | 16 | 17 | ofxCvColorImage colorImg; 18 | ofxCvGrayscaleImage grayImage; 19 | 20 | ofxCvContourFinder contourFinder; 21 | 22 | ofImage testImage; 23 | 24 | ofxPanel gui; 25 | ofxFloatSlider minArea; 26 | ofxFloatSlider maxArea; 27 | ofxFloatSlider threshold; 28 | ofxToggle debugOn; 29 | 30 | 31 | 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /05_3D_space/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/05_3D_space/addons.make -------------------------------------------------------------------------------- /05_3D_space/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/05_3D_space/bin/data/.gitkeep -------------------------------------------------------------------------------- /05_3D_space/bin/data/space.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/05_3D_space/bin/data/space.jpg -------------------------------------------------------------------------------- /05_3D_space/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /05_3D_space/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /05_3D_space/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | camera.setFov(100); 6 | 7 | camera.setPosition(ofVec3f(60,60,60)); 8 | camera.lookAt(ofVec3f(0,0,0)); 9 | 10 | pointLight1.setPosition(0, 82, 100); 11 | pointLight1.setDiffuseColor(ofColor(255,250,154)); 12 | 13 | pointLight2.setPosition(0, 82, -100); 14 | pointLight2.setDiffuseColor(ofColor(255,130,5)); 15 | 16 | 17 | ofEnableDepthTest(); 18 | space.load("space.jpg"); 19 | 20 | 21 | 22 | drawingMode = 0; 23 | } 24 | 25 | //-------------------------------------------------------------- 26 | void ofApp::update(){ 27 | 28 | 29 | // Camera manipulation 30 | float distance = sin(ofGetElapsedTimef() * 0.4)* 100; 31 | 32 | 33 | float radius = 120 + (sin(ofGetElapsedTimef() * 0.3) * 100); 34 | float height = 30 + (sin(ofGetElapsedTimef() * 0.6) * 60); 35 | 36 | ofVec3f newCamera = ofVec3f(cos(ofGetElapsedTimef()) * radius,height,sin(ofGetElapsedTimef()) * radius ); 37 | 38 | camera.setPosition(newCamera); 39 | camera.lookAt(ofVec3f(0,0,0)); 40 | 41 | 42 | } 43 | 44 | //-------------------------------------------------------------- 45 | void ofApp::draw(){ 46 | 47 | camera.begin(); 48 | 49 | 50 | ofDrawAxis(100); //will draw the x(red)y(green)z(blue)axis. 51 | 52 | ofEnableLighting(); 53 | pointLight1.enable(); 54 | pointLight2.enable(); 55 | 56 | 57 | 58 | if (drawingMode == 0) { 59 | drawSpaceInvader(); 60 | }else if(drawingMode ==1){ 61 | drawTail(); 62 | }else if(drawingMode ==2){ 63 | drawCylinder(); 64 | } 65 | 66 | 67 | 68 | pointLight1.draw(); 69 | pointLight2.draw(); 70 | 71 | camera.end(); 72 | 73 | ofDrawBitmapString("press space to switch drawing ", 10, 20); 74 | 75 | 76 | } 77 | 78 | 79 | 80 | void ofApp::drawSpaceInvader(){ 81 | 82 | ofPushMatrix(); 83 | 84 | ofTranslate(-space.getWidth() * 0.5, space.getHeight() * 0.5,0); 85 | 86 | int gridSize = 15; 87 | for (int x = 0; x < space.getWidth(); x += gridSize) { 88 | for (int y = 0; y < space.getHeight(); y += gridSize) { 89 | 90 | if (space.getColor(x, y).getBrightness() > 240) { 91 | ofDrawBox(ofVec3f(x,-y,0), 12); 92 | } 93 | } 94 | } 95 | 96 | ofPopMatrix(); 97 | 98 | 99 | } 100 | 101 | 102 | void ofApp::drawCylinder(){ 103 | 104 | for(float angle = 0; angle < 360; ++angle){ 105 | 106 | 107 | float radius = 50 + (angle * 0.1) + sin(ofGetElapsedTimef() * 0.4) * 24; 108 | ofVec3f position(sin(angle) * radius,-100 + angle,cos(angle) * radius ); 109 | 110 | 111 | ofPushMatrix(); 112 | 113 | ofTranslate(position); 114 | ofRotate(angle,0,1,0); 115 | ofDrawBox(ofVec3f(0,0,0), fabs(sin(angle)) * 8); 116 | 117 | 118 | ofPopMatrix(); 119 | 120 | 121 | } 122 | } 123 | 124 | 125 | void ofApp::drawTail(){ 126 | ofPushMatrix(); 127 | 128 | for (int i=0; i < 40; ++i) { 129 | ofTranslate(i * 0.2, 0,0); 130 | ofRotate(ofGetElapsedTimef() * 20, 1,1,1); 131 | ofScale(1.1,1.1,1.1); 132 | ofDrawBox(ofVec3f(0,0,0), 4); 133 | } 134 | 135 | ofPopMatrix(); 136 | } 137 | 138 | 139 | //-------------------------------------------------------------- 140 | void ofApp::keyReleased(int key){ 141 | if (key == 'f') { 142 | ofToggleFullscreen(); 143 | }else if(key == ' '){ 144 | drawingMode = ++drawingMode % 3; 145 | } 146 | 147 | } 148 | 149 | -------------------------------------------------------------------------------- /05_3D_space/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | class ofApp : public ofBaseApp{ 6 | 7 | ofCamera camera; 8 | 9 | ofLight pointLight1; 10 | ofLight pointLight2; 11 | 12 | 13 | ofImage space; 14 | 15 | int drawingMode; 16 | 17 | public: 18 | void setup(); 19 | void update(); 20 | void draw(); 21 | 22 | void drawSpaceInvader(); 23 | void drawCylinder(); 24 | void drawTail(); 25 | 26 | void keyReleased(int key); 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /06_Arduino/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/06_Arduino/addons.make -------------------------------------------------------------------------------- /06_Arduino/arduino_code/arduino_code.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | int b; 4 | 5 | void setup() { 6 | Serial.begin(9600); 7 | 8 | pinMode(9, OUTPUT); 9 | b=0; 10 | } 11 | 12 | void loop() { 13 | // to view the data the serial monitor. 14 | 15 | // Serial.write(analogRead(0)); 16 | 17 | // analogWrite(9, b++); 18 | // delay(3); 19 | 20 | 21 | 22 | 23 | Serial.println( analogRead(0)); 24 | // 25 | // 26 | // // write one byte 27 | // //Serial.write(analogRead(0)); 28 | // 29 | // 30 | // use a marker : 31 | // Serial.print(analogRead(0)); 32 | 33 | Serial.print(analogRead(0)); 34 | Serial.print(":"); 35 | 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /06_Arduino/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/06_Arduino/bin/data/.gitkeep -------------------------------------------------------------------------------- /06_Arduino/bin/data/1085.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/06_Arduino/bin/data/1085.mp3 -------------------------------------------------------------------------------- /06_Arduino/bin/data/OstrichSans-Heavy.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/06_Arduino/bin/data/OstrichSans-Heavy.otf -------------------------------------------------------------------------------- /06_Arduino/bin/data/disc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/06_Arduino/bin/data/disc.png -------------------------------------------------------------------------------- /06_Arduino/bin/data/frabk.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/06_Arduino/bin/data/frabk.ttf -------------------------------------------------------------------------------- /06_Arduino/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /06_Arduino/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /06_Arduino/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | 4 | 5 | //-------------------------------------------------------------- 6 | void ofApp::setup(){ 7 | ofSetLogLevel(OF_LOG_VERBOSE); 8 | serial.listDevices(); 9 | 10 | serial.setup(0, 9600); //open the first device 11 | 12 | ofSetCircleResolution(250); 13 | // ofSetBackgroundColor(143, 234, 139); 14 | ofSetBackgroundColor(244, 234, 255); 15 | 16 | 17 | sound.load("1085.mp3"); 18 | sound.play(); 19 | sound.setLoop(true); 20 | 21 | disc.load("disc.png"); 22 | 23 | ofSetFrameRate(60); 24 | 25 | rotation = 0; 26 | speed = 1; 27 | 28 | 29 | fontType.load("OstrichSans-Heavy.otf", 46); 30 | fontType.setLineHeight(18.0f); 31 | fontType.setLetterSpacing(1.037); 32 | 33 | 34 | } 35 | 36 | //-------------------------------------------------------------- 37 | void ofApp::update(){ 38 | 39 | 40 | char charByte; 41 | string validMessage = ""; 42 | 43 | bool seperatorFound = false; 44 | 45 | if (serial.available()){ 46 | tmpBuffer = ""; 47 | 48 | while(serial.available() > 0){ 49 | charByte = serial.readByte(); 50 | if(charByte == ':'){ 51 | 52 | if(!seperatorFound){ 53 | tmpBuffer = ""; 54 | seperatorFound = true; 55 | }else if(seperatorFound){ 56 | validMessage = tmpBuffer; 57 | seperatorFound = false; 58 | } 59 | 60 | 61 | }else{ 62 | tmpBuffer += ofToString(charByte); 63 | } 64 | } 65 | serial.flush(); 66 | } 67 | 68 | if(validMessage != ""){ 69 | inputValue = ofToInt(validMessage); 70 | speed = ofMap(inputValue, 30, 470, 1, -1.0,true); 71 | sound.setSpeed(speed); 72 | } 73 | 74 | rotation += (speed * 2.09); 75 | 76 | 77 | ofSoundUpdate(); 78 | 79 | } 80 | 81 | 82 | //-------------------------------------------------------------- 83 | void ofApp::draw(){ 84 | 85 | 86 | 87 | ofPushMatrix(); 88 | ofTranslate(ofGetWindowSize()/2); 89 | ofRotate(rotation); 90 | ofTranslate(-disc.getWidth() /2, -disc.getHeight()/2); 91 | disc.draw(0,0); 92 | ofPopMatrix(); 93 | 94 | ofSetColor(255, 255, 255); 95 | fontType.drawString("Speed: " + ofToString(speed), 20, 54); 96 | fontType.drawString("Sensor input: " + ofToString(inputValue), 20, 100); 97 | 98 | } 99 | 100 | //-------------------------------------------------------------- 101 | void ofApp::keyPressed(int key){ 102 | ofToggleFullscreen(); 103 | } 104 | 105 | //-------------------------------------------------------------- 106 | void ofApp::keyReleased(int key){ 107 | 108 | } 109 | 110 | //-------------------------------------------------------------- 111 | void ofApp::mouseMoved(int x, int y ){ 112 | 113 | } 114 | 115 | //-------------------------------------------------------------- 116 | void ofApp::mouseDragged(int x, int y, int button){ 117 | 118 | } 119 | 120 | //-------------------------------------------------------------- 121 | void ofApp::mousePressed(int x, int y, int button){ 122 | 123 | } 124 | 125 | //-------------------------------------------------------------- 126 | void ofApp::mouseReleased(int x, int y, int button){ 127 | 128 | } 129 | 130 | //-------------------------------------------------------------- 131 | void ofApp::mouseEntered(int x, int y){ 132 | 133 | } 134 | 135 | //-------------------------------------------------------------- 136 | void ofApp::mouseExited(int x, int y){ 137 | 138 | } 139 | 140 | //-------------------------------------------------------------- 141 | void ofApp::windowResized(int w, int h){ 142 | 143 | } 144 | 145 | //-------------------------------------------------------------- 146 | void ofApp::gotMessage(ofMessage msg){ 147 | 148 | } 149 | 150 | //-------------------------------------------------------------- 151 | void ofApp::dragEvent(ofDragInfo dragInfo){ 152 | 153 | } 154 | -------------------------------------------------------------------------------- /06_Arduino/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | class ofApp : public ofBaseApp{ 6 | 7 | ofSerial serial; 8 | float radius; 9 | int inputValue; 10 | float speed; 11 | float rotation; 12 | 13 | ofSoundPlayer sound; 14 | string tmpBuffer = ""; 15 | ofImage disc; 16 | ofTrueTypeFont fontType; 17 | 18 | 19 | public: 20 | void setup(); 21 | void update(); 22 | void draw(); 23 | 24 | void keyPressed(int key); 25 | void keyReleased(int key); 26 | void mouseMoved(int x, int y ); 27 | void mouseDragged(int x, int y, int button); 28 | void mousePressed(int x, int y, int button); 29 | void mouseReleased(int x, int y, int button); 30 | void mouseEntered(int x, int y); 31 | void mouseExited(int x, int y); 32 | void windowResized(int w, int h); 33 | void dragEvent(ofDragInfo dragInfo); 34 | void gotMessage(ofMessage msg); 35 | 36 | 37 | }; 38 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenClient/addons.make: -------------------------------------------------------------------------------- 1 | ofxOsc 2 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenClient/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/07_Networking_BigScreen/BigScreenClient/bin/data/.gitkeep -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenClient/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenClient/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | clientSender.setup("192.168.1.17", 9000); 6 | clientReceiver.setup(9001); 7 | 8 | id= -1; 9 | // ofSetFullscreen(true); 10 | ofSetFrameRate(60); 11 | 12 | //image.load("image.jpg"); 13 | } 14 | 15 | //-------------------------------------------------------------- 16 | void ofApp::update(){ 17 | 18 | if(id == -1){ 19 | ofxOscMessage m; 20 | m.setAddress("/getId"); 21 | m.addInt32Arg(ofGetWindowWidth()); 22 | clientSender.sendMessage(m); 23 | } 24 | 25 | while(clientReceiver.hasWaitingMessages()){ 26 | // get the next message 27 | ofxOscMessage m; 28 | clientReceiver.getNextMessage(m); 29 | 30 | if(m.getAddress() == "/id"){ 31 | id = m.getArgAsInt(0); 32 | globalWidth = m.getArgAsInt(1); 33 | 34 | } 35 | 36 | 37 | if(m.getAddress() == "/broadcast"){ 38 | if(m.getNumArgs() >= 2){ 39 | position.x = m.getArgAsFloat(0) - globalWidth; 40 | position.y = m.getArgAsFloat(1); 41 | 42 | } 43 | } 44 | } 45 | 46 | } 47 | 48 | //-------------------------------------------------------------- 49 | void ofApp::draw(){ 50 | if (id != -1) { 51 | ofSetColor(255,255,255); 52 | 53 | ofDrawBitmapString("ID " + ofToString(id), 20, 20); 54 | ofDrawBitmapString("width " + ofToString(globalWidth), 20, 40); 55 | } 56 | 57 | ofSetColor(255,210,0); 58 | 59 | ofPushMatrix(); 60 | ofTranslate(position); 61 | ofDrawCircle(0,0,20); 62 | 63 | ofRotate(ofGetElapsedTimef()*100.0); 64 | ofDrawCircle(20 + fabs(sin(ofGetElapsedTimef() * 4) * 10), 0, 4); 65 | ofDrawCircle(-20 - fabs(sin(ofGetElapsedTimef() * -4) * 10), 0, 4); 66 | 67 | ofPopMatrix(); 68 | 69 | 70 | 71 | 72 | } 73 | 74 | //-------------------------------------------------------------- 75 | void ofApp::keyPressed(int key){ 76 | id = -1; 77 | } 78 | 79 | //-------------------------------------------------------------- 80 | void ofApp::keyReleased(int key){ 81 | 82 | } 83 | 84 | //-------------------------------------------------------------- 85 | void ofApp::mouseMoved(int x, int y ){ 86 | 87 | } 88 | 89 | //-------------------------------------------------------------- 90 | void ofApp::mouseDragged(int x, int y, int button){ 91 | 92 | } 93 | 94 | //-------------------------------------------------------------- 95 | void ofApp::mousePressed(int x, int y, int button){ 96 | 97 | } 98 | 99 | //-------------------------------------------------------------- 100 | void ofApp::mouseReleased(int x, int y, int button){ 101 | 102 | } 103 | 104 | //-------------------------------------------------------------- 105 | void ofApp::mouseEntered(int x, int y){ 106 | 107 | } 108 | 109 | //-------------------------------------------------------------- 110 | void ofApp::mouseExited(int x, int y){ 111 | 112 | } 113 | 114 | //-------------------------------------------------------------- 115 | void ofApp::windowResized(int w, int h){ 116 | 117 | } 118 | 119 | //-------------------------------------------------------------- 120 | void ofApp::gotMessage(ofMessage msg){ 121 | 122 | } 123 | 124 | //-------------------------------------------------------------- 125 | void ofApp::dragEvent(ofDragInfo dragInfo){ 126 | 127 | } 128 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenClient/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxOsc.h" 5 | 6 | 7 | 8 | 9 | class ofApp : public ofBaseApp{ 10 | 11 | 12 | ofxOscSender clientSender; // all-important ofxOscSender object 13 | ofxOscReceiver clientReceiver; // OSC receiver 14 | 15 | int id; 16 | int globalWidth; 17 | ofVec2f position; 18 | 19 | ofImage image; 20 | 21 | public: 22 | void setup(); 23 | void update(); 24 | void draw(); 25 | 26 | void keyPressed(int key); 27 | void keyReleased(int key); 28 | void mouseMoved(int x, int y ); 29 | void mouseDragged(int x, int y, int button); 30 | void mousePressed(int x, int y, int button); 31 | void mouseReleased(int x, int y, int button); 32 | void mouseEntered(int x, int y); 33 | void mouseExited(int x, int y); 34 | void windowResized(int w, int h); 35 | void dragEvent(ofDragInfo dragInfo); 36 | void gotMessage(ofMessage msg); 37 | 38 | }; 39 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenServer/addons.make: -------------------------------------------------------------------------------- 1 | ofxOsc 2 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenServer/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/07_Networking_BigScreen/BigScreenServer/bin/data/.gitkeep -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenServer/bin/data/VarelaRound-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/07_Networking_BigScreen/BigScreenServer/bin/data/VarelaRound-Regular.ttf -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenServer/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenServer/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | ofSetFrameRate(60); // run at 60 fps 6 | // Enable some logging information 7 | ofSetLogLevel(OF_LOG_VERBOSE); 8 | 9 | //Server side 10 | //listen for incoming messages on a port; setup OSC receiver with usage: 11 | serverReceiver.setup(9000); 12 | 13 | position.set(0,500); 14 | speed = 3; 15 | targetSpeed = speed; 16 | 17 | ofSetBackgroundColor(0, 200, 255); 18 | ofSetWindowShape(1024, 200); 19 | 20 | fontBig.load("VarelaRound-Regular.ttf", 24); 21 | fontSmall.load("VarelaRound-Regular.ttf", 14); 22 | 23 | } 24 | 25 | 26 | int ofApp::getTotalWidth(){ 27 | int totalWidth =0; 28 | for (networkClient c : clients){ 29 | totalWidth += c.width; 30 | } 31 | 32 | return totalWidth; 33 | } 34 | 35 | 36 | int ofApp::getLeftPaddingForClient(networkClient* client){ 37 | 38 | int padding =0; 39 | for (networkClient c : clients){ 40 | if(c.id == client->id) break; 41 | padding += c.width; 42 | } 43 | 44 | return padding; 45 | 46 | } 47 | 48 | 49 | 50 | //-------------------------------------------------------------- 51 | void ofApp::update(){ 52 | 53 | speed -= (speed - targetSpeed) * 0.03; 54 | 55 | position.x += (speed + ofGetLastFrameTime()); 56 | broadCast(position); 57 | 58 | if(position.x > getTotalWidth()){ 59 | position.x = 0; 60 | } 61 | 62 | if(position.x < 0){ 63 | position.x = getTotalWidth(); 64 | } 65 | 66 | 67 | while(serverReceiver.hasWaitingMessages()){ 68 | 69 | // get the next message 70 | ofxOscMessage m; 71 | serverReceiver.getNextMessage(m); 72 | // ofLogVerbose("Server recvd msg " + m.getAddress() + " from " + m.getRemoteIp()); 73 | 74 | try{ 75 | 76 | 77 | if(m.getAddress() == "/beat"){ 78 | speed += 18; 79 | } 80 | //bool existingClient = false; 81 | networkClient* existingClient = nullptr; 82 | 83 | 84 | //if(m.getRemoteHost() == "127.0.0.1") return; 85 | 86 | for (networkClient& c : clients) { 87 | if(c.ip == m.getRemoteHost()){ 88 | existingClient = &c; 89 | break; 90 | } 91 | } 92 | 93 | 94 | if(m.getAddress() == "/getId"){ 95 | if(m.getNumArgs() != 1 || m.getArgType(0) != OFXOSC_TYPE_INT32){ 96 | cout << "invalid package from " << m.getRemoteHost() << std::endl; 97 | }else{ 98 | // add new client. 99 | if(existingClient == nullptr){ 100 | networkClient newClient(m.getRemoteHost(),clients.size()); 101 | clients.push_back(newClient); 102 | existingClient = &clients.back(); 103 | } 104 | 105 | int incomingWidth = m.getArgAsInt(0); 106 | existingClient->width = incomingWidth; 107 | sendIdAndWidth(existingClient); 108 | 109 | 110 | 111 | } 112 | } 113 | }catch(...){ 114 | cout << "error from " << m.getRemoteHost() << std::endl; 115 | } 116 | } 117 | } 118 | 119 | 120 | void ofApp::sendIdAndWidth(networkClient* client){ 121 | // send client number 122 | ofxOscMessage message; 123 | message.setAddress("/id"); 124 | message.addInt32Arg(client->id); 125 | message.addInt32Arg(getLeftPaddingForClient(client)); 126 | 127 | client->oscSender.sendMessage(message); 128 | 129 | 130 | } 131 | 132 | 133 | 134 | 135 | void ofApp::broadCast(ofVec2f position){ 136 | 137 | float offset=0; 138 | for(networkClient& c : clients){ 139 | 140 | ofxOscMessage message; 141 | message.setAddress("/broadcast"); 142 | message.addFloatArg(position.x); 143 | message.addFloatArg(position.y); 144 | message.addFloatArg(offset); 145 | 146 | offset += c.width; 147 | 148 | c.oscSender.sendMessage(message); 149 | } 150 | } 151 | 152 | //-------------------------------------------------------------- 153 | void ofApp::draw(){ 154 | ofSetColor(255,255,255); 155 | 156 | fontBig.drawString( "CLIENTS (" + ofToString(clients.size()) + ")", 30,40); 157 | fontBig.drawString( "BIG screen: " + ofToString(getTotalWidth()) + "px",30,70); 158 | fontSmall.drawString( "targetSpeed: " + ofToString(targetSpeed) + "",30,90); 159 | fontSmall.drawString( "currentSpeed: " + ofToString(speed) + "",30,110); 160 | 161 | float localX = ofMap(position.x, 0, getTotalWidth(), 0, 1024); 162 | ofSetColor(255,210,0); 163 | 164 | ofDrawCircle(localX, 50,20); 165 | 166 | int i = 1; 167 | 168 | ofSetColor(0,0,0); 169 | 170 | for(networkClient& c : clients){ 171 | string test = ofToString(i) + ":" + c.ip + " -- " + ofToString(c.width); 172 | fontSmall.drawString(test , 660, 20 + (i * 20)); 173 | i++; 174 | } 175 | 176 | } 177 | 178 | //-------------------------------------------------------------- 179 | void ofApp::keyPressed(int key){ 180 | if(key == '1'){ 181 | targetSpeed -= 1; 182 | }else if(key == '2'){ 183 | targetSpeed += 1; 184 | } 185 | } 186 | 187 | //-------------------------------------------------------------- 188 | void ofApp::keyReleased(int key){ 189 | 190 | } 191 | 192 | //-------------------------------------------------------------- 193 | void ofApp::mouseMoved(int x, int y ){ 194 | 195 | } 196 | 197 | //-------------------------------------------------------------- 198 | void ofApp::mouseDragged(int x, int y, int button){ 199 | 200 | } 201 | 202 | //-------------------------------------------------------------- 203 | void ofApp::mousePressed(int x, int y, int button){ 204 | 205 | } 206 | 207 | //-------------------------------------------------------------- 208 | void ofApp::mouseReleased(int x, int y, int button){ 209 | 210 | } 211 | 212 | //-------------------------------------------------------------- 213 | void ofApp::mouseEntered(int x, int y){ 214 | 215 | } 216 | 217 | //-------------------------------------------------------------- 218 | void ofApp::mouseExited(int x, int y){ 219 | 220 | } 221 | 222 | //-------------------------------------------------------------- 223 | void ofApp::windowResized(int w, int h){ 224 | 225 | } 226 | 227 | //-------------------------------------------------------------- 228 | void ofApp::gotMessage(ofMessage msg){ 229 | 230 | } 231 | 232 | //-------------------------------------------------------------- 233 | void ofApp::dragEvent(ofDragInfo dragInfo){ 234 | 235 | } 236 | -------------------------------------------------------------------------------- /07_Networking_BigScreen/BigScreenServer/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxOsc.h" 5 | 6 | 7 | class networkClient{ 8 | public: 9 | 10 | networkClient(std::string _ip,int _id){ 11 | id = _id; 12 | ip = _ip; 13 | oscSender.setup(_ip, 9001); 14 | } 15 | 16 | ofxOscSender oscSender; 17 | string ip; 18 | int id; 19 | int width; 20 | 21 | 22 | }; 23 | 24 | class ofApp : public ofBaseApp{ 25 | 26 | ofVec2f position; 27 | float speed; 28 | 29 | float targetSpeed; 30 | 31 | 32 | ofxOscReceiver serverReceiver; // OSC receiver 33 | 34 | vector clients; 35 | ofTrueTypeFont fontBig; 36 | ofTrueTypeFont fontSmall; 37 | 38 | 39 | public: 40 | void setup(); 41 | void update(); 42 | void draw(); 43 | void sendIdAndWidth(networkClient* client); 44 | 45 | int getTotalWidth(); 46 | int getLeftPaddingForClient(networkClient* client); 47 | 48 | void broadCast(ofVec2f position); 49 | 50 | void keyPressed(int key); 51 | void keyReleased(int key); 52 | void mouseMoved(int x, int y ); 53 | void mouseDragged(int x, int y, int button); 54 | void mousePressed(int x, int y, int button); 55 | void mouseReleased(int x, int y, int button); 56 | void mouseEntered(int x, int y); 57 | void mouseExited(int x, int y); 58 | void windowResized(int w, int h); 59 | void dragEvent(ofDragInfo dragInfo); 60 | void gotMessage(ofMessage msg); 61 | 62 | }; 63 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/PassingData/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/08_Pointers_and_UI/PassingData/addons.make -------------------------------------------------------------------------------- /08_Pointers_and_UI/PassingData/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/08_Pointers_and_UI/PassingData/bin/data/.gitkeep -------------------------------------------------------------------------------- /08_Pointers_and_UI/PassingData/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/PassingData/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | 4 | 5 | void processDataByValue(vector data){ 6 | 7 | float total = 0; 8 | for (float f : data) { 9 | total += f; 10 | } 11 | } 12 | 13 | 14 | void processDataReference(vector& data){ 15 | float total = 0; 16 | for (float f : data) { 17 | total += f; 18 | } 19 | } 20 | 21 | void processDataPointer(vector* data){ 22 | float total = 0; 23 | 24 | for (float f : *data) { 25 | total += f; 26 | } 27 | } 28 | 29 | 30 | //-------------------------------------------------------------- 31 | void ofApp::setup(){ 32 | // create a large block of data. 33 | bigData.reserve(999999999); 34 | bigData.assign(999999999, 1); 35 | 36 | } 37 | 38 | //-------------------------------------------------------------- 39 | void ofApp::update(){ 40 | 41 | } 42 | 43 | //-------------------------------------------------------------- 44 | void ofApp::draw(){ 45 | ofDrawBitmapStringHighlight("CHECK memmory usage in Visual studio or XCode", 100, 100); 46 | ofDrawBitmapStringHighlight("press 1 to process the data by value", 100, 140); 47 | ofDrawBitmapStringHighlight("press 2 to process the data by reference", 100, 170); 48 | ofDrawBitmapStringHighlight("press 3 to process the data by pointer", 100, 2010); 49 | 50 | } 51 | 52 | //-------------------------------------------------------------- 53 | void ofApp::keyReleased(int key){ 54 | float startTime; 55 | 56 | if(key == '1' ){ 57 | float startTime = ofGetElapsedTimef(); 58 | processDataByValue(bigData); 59 | std::cout << " time by value: " << ofGetElapsedTimef() - startTime << std::endl; 60 | } 61 | 62 | if(key== '2'){ 63 | startTime = ofGetElapsedTimef(); 64 | processDataReference(bigData); 65 | std::cout << " time by reference: " << ofGetElapsedTimef() - startTime << std::endl; 66 | 67 | } 68 | 69 | 70 | if(key== '3'){ 71 | startTime = ofGetElapsedTimef(); 72 | processDataPointer(&bigData); 73 | std::cout << " time by pointer: " << ofGetElapsedTimef() - startTime << std::endl; 74 | 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/PassingData/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "test.hpp" 5 | 6 | class ofApp : public ofBaseApp{ 7 | 8 | vector bigData; 9 | test t; 10 | 11 | 12 | public: 13 | void setup(); 14 | void update(); 15 | void draw(); 16 | 17 | void keyReleased(int key); 18 | }; 19 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/PassingData/src/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // test.cpp 3 | // PassingData 4 | // 5 | // Created by Kris Meeusen on 22/04/16. 6 | // 7 | // 8 | 9 | #include "test.hpp" 10 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/PassingData/src/test.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // test.hpp 3 | // PassingData 4 | // 5 | // Created by Kris Meeusen on 22/04/16. 6 | // 7 | // 8 | 9 | #ifndef test_hpp 10 | #define test_hpp 11 | 12 | #include 13 | #include "ofMain.h" 14 | 15 | 16 | class test{ 17 | public: 18 | 19 | test(); 20 | ~test(); 21 | 22 | string& mName; 23 | 24 | void setName(string& name){ 25 | mName = name; 26 | } 27 | 28 | }; 29 | 30 | #endif /* test_hpp */ 31 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/addons.make: -------------------------------------------------------------------------------- 1 | ofxGui 2 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/08_Pointers_and_UI/UI/bin/data/.gitkeep -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/bin/data/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 0.42 3 | 8 4 | 1.05 5 | -13.2653, 12.2449, 7.14285 6 | -66.3265, 44.898, 12.2449 7 | 8 | 9 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | 6 | nBandsToGet = 62; 7 | ofSetFrameRate(60); 8 | ofSetBackgroundColor(30, 30, 30); 9 | 10 | menu.setup(400,100,200,30); 11 | menu.setName("MENU"); 12 | menu.enableChildren(true); 13 | 14 | ofDirectory dir; 15 | dir.listDir("sounds/"); 16 | 17 | for(int i = 0 ; i < dir.size(); ++i){ 18 | uiNode* soundNode = new uiNode(); 19 | soundNode->setup(0,40+ i * 20,260,20); 20 | soundNode->setName(dir.getName(i)); 21 | ofAddListener(soundNode->clickedInside, this, &ofApp::clickedInside); 22 | 23 | menu.addChild(soundNode); 24 | 25 | } 26 | 27 | ofAddListener(menu.clickedInside, this, &ofApp::clickedInside); 28 | 29 | camera.setFov(110); 30 | 31 | 32 | pointLight1.setPosition(0, 82, 100); 33 | pointLight1.setDiffuseColor(ofColor(255,0,0)); 34 | 35 | pointLight2.setPosition(230, 252, 250); 36 | pointLight2.setDiffuseColor(ofColor(0,10,255)); 37 | 38 | 39 | ofEnableDepthTest(); 40 | 41 | // the fft needs to be smoothed out, so we create an array of floats 42 | // for that purpose: 43 | fftSmoothed = new float[8192]; 44 | for (int i = 0; i < 8192; i++){ 45 | fftSmoothed[i] = 0; 46 | } 47 | 48 | 49 | rotation = 0; 50 | kick = 0; 51 | radius = 200; 52 | increaseRadius = 1.4; 53 | 54 | 55 | panel.setup(); // most of the time you don't need a name 56 | 57 | panel.add(kickFallOff.setup("kickFallOff", 0.2,0.0,1.0)); 58 | panel.add(radius.setup("radius", 2.2,0.0,400.0)); 59 | panel.add(increaseRadius.setup("increaseRadius", 1.2,0.0,2.0)); 60 | panel.add(cameraLookAt.setup("cameraLookAt", ofVec3f(0, 0, 0),ofVec3f(-100, -100, -100),ofVec3f(100, 100, 100))); 61 | panel.add(cameraPostion.setup("cameraPostion", ofVec3f(0, 0, 0),ofVec3f(-100, -100, -100),ofVec3f(100, 100, 100))); 62 | 63 | panel.loadFromFile("settings.xml"); 64 | 65 | } 66 | 67 | 68 | 69 | void ofApp::clickedInside(string& name){ 70 | if(name == "MENU"){ 71 | menu.enableChildren(!menu.hasChildrenEnabled()); 72 | }else{ 73 | 74 | if(ofFile::doesFileExist(ofToDataPath("sounds/" + name))){ 75 | soundPlayer.load("sounds/" + name); 76 | soundPlayer.play(); 77 | } 78 | } 79 | } 80 | 81 | //-------------------------------------------------------------- 82 | void ofApp::update(){ 83 | 84 | camera.setPosition(cameraPostion); 85 | camera.lookAt(cameraLookAt); 86 | 87 | 88 | 89 | menu.position.y = 100 + (sin(ofGetElapsedTimef() * 0.6f) * 20.0f) ; 90 | 91 | // update the sound playing system: 92 | ofSoundUpdate(); 93 | float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft 94 | 95 | if(fftSmoothed[0] > 0.8) kick += fftSmoothed[0]; 96 | 97 | for (int i = 0;i < nBandsToGet; i++){ 98 | 99 | // let the smoothed calue sink to zero: 100 | fftSmoothed[i] *= 0.96f; 101 | 102 | // take the max, either the smoothed or the incoming: 103 | if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; 104 | 105 | } 106 | 107 | 108 | if(kick > 0) kick -= kick * kickFallOff; 109 | rotation += pow(kick,2.0); 110 | } 111 | 112 | //-------------------------------------------------------------- 113 | void ofApp::draw(){ 114 | 115 | ofSetColor(255); 116 | ofEnableDepthTest(); 117 | camera.begin(); 118 | pointLight1.enable(); 119 | pointLight2.enable(); 120 | 121 | 122 | ofPushMatrix(); 123 | 124 | ofRotateY(rotation); 125 | ofRotateX(10.4+ kick * 2.0); 126 | 127 | float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft 128 | 129 | 130 | float offset = nBandsToGet * 11 *0.5; 131 | float newRadius =radius; 132 | 133 | for (int i = 0;i < nBandsToGet; i++){ 134 | 135 | 136 | //ofVec3f position(i* 12 - offset,0,0); 137 | newRadius *= increaseRadius; 138 | ofVec3f position(sin(i) * newRadius,0,cos(i) * newRadius); 139 | 140 | ofDrawBox(position, 10, fftSmoothed[i] * 200, 6); 141 | } 142 | 143 | ofPopMatrix(); 144 | 145 | 146 | camera.end(); 147 | 148 | 149 | ofSetColor(255, 255, 255); 150 | ofDisableDepthTest(); 151 | ofDisableLighting(); 152 | pointLight1.disable(); 153 | pointLight2.disable(); 154 | 155 | menu.draw(); 156 | panel.draw(); 157 | 158 | 159 | } 160 | 161 | //-------------------------------------------------------------- 162 | void ofApp::keyPressed(int key){ 163 | if(key == 'f'){ 164 | ofToggleFullscreen(); 165 | } 166 | } 167 | 168 | //-------------------------------------------------------------- 169 | void ofApp::keyReleased(int key){ 170 | 171 | } 172 | 173 | //-------------------------------------------------------------- 174 | void ofApp::mouseMoved(int x, int y ){ 175 | 176 | } 177 | 178 | //-------------------------------------------------------------- 179 | void ofApp::mouseDragged(int x, int y, int button){ 180 | 181 | } 182 | 183 | //-------------------------------------------------------------- 184 | void ofApp::mousePressed(int x, int y, int button){ 185 | //menu.enableChildren(true); 186 | menu.mouseUp(x, y); 187 | } 188 | 189 | //-------------------------------------------------------------- 190 | void ofApp::mouseReleased(int x, int y, int button){ 191 | 192 | } 193 | 194 | 195 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "uiNode.hpp" 5 | #include "ofxGui.h" 6 | 7 | class ofApp : public ofBaseApp{ 8 | 9 | 10 | uiNode menu; 11 | ofSoundPlayer soundPlayer; 12 | 13 | ofCamera camera; 14 | ofLight pointLight1; 15 | ofLight pointLight2; 16 | 17 | 18 | ofxPanel panel; 19 | ofxSlider kickFallOff; 20 | ofxSlider radius; 21 | ofxSlider increaseRadius; 22 | 23 | ofxVec3Slider cameraPostion; 24 | ofxVec3Slider cameraLookAt; 25 | 26 | float *fftSmoothed; 27 | int nBandsToGet; 28 | float kick; 29 | float rotation; 30 | 31 | 32 | public: 33 | void setup(); 34 | void update(); 35 | void draw(); 36 | 37 | void keyPressed(int key); 38 | void keyReleased(int key); 39 | void mouseMoved(int x, int y ); 40 | void mouseDragged(int x, int y, int button); 41 | void mousePressed(int x, int y, int button); 42 | void mouseReleased(int x, int y, int button); 43 | 44 | void clickedInside(string& name); 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/src/uiNode.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UINode.cpp 3 | // UI 4 | // 5 | // Created by lab101 on 21/04/16. 6 | // 7 | // 8 | 9 | #include "UINode.hpp" 10 | 11 | 12 | uiNode::uiNode(){ 13 | name = ""; 14 | parent = nullptr; 15 | childrenEnabled = true; 16 | } 17 | 18 | void uiNode::setup(float x,float y){ 19 | position.x = x; 20 | position.y = x; 21 | } 22 | 23 | 24 | void uiNode::setup(float x,float y, float width, float height){ 25 | position.x = x; 26 | position.y = y; 27 | 28 | boundingBox.set(0, 0, width, height); 29 | } 30 | 31 | 32 | void uiNode::addChild(uiNode* childNode){ 33 | children.push_back(childNode); 34 | childNode->parent = this; 35 | } 36 | 37 | 38 | void uiNode::setName(string newName){ 39 | name = newName; 40 | } 41 | 42 | void uiNode::getName(){ 43 | return name; 44 | } 45 | 46 | void uiNode::enableChildren(bool value){ 47 | childrenEnabled = value; 48 | } 49 | 50 | bool uiNode::hasChildrenEnabled(){ 51 | return childrenEnabled; 52 | } 53 | 54 | 55 | void uiNode::update(){ 56 | 57 | } 58 | 59 | void uiNode::draw(){ 60 | 61 | ofPushMatrix(); 62 | ofTranslate(position); 63 | 64 | ofFill(); 65 | ofSetLineWidth(2); 66 | ofSetColor(55, 55, 55,20); 67 | ofDrawRectangle(boundingBox); 68 | ofNoFill(); 69 | ofSetColor(55, 55, 55,255); 70 | ofDrawRectangle(boundingBox); 71 | 72 | if(name != "") ofDrawBitmapString(name, 10,15); 73 | 74 | if(childrenEnabled){ 75 | for(uiNode* child : children){ 76 | child->draw(); 77 | } 78 | } 79 | 80 | ofFill(); 81 | 82 | ofPopMatrix(); 83 | 84 | } 85 | 86 | 87 | ofVec2f uiNode::getGlobalPosition(){ 88 | ofVec2f globalPosition = position; 89 | 90 | if(parent != nullptr){ 91 | globalPosition += parent->getGlobalPosition(); 92 | } 93 | 94 | return globalPosition; 95 | } 96 | 97 | 98 | void uiNode::mouseDown(float x,float y){ 99 | 100 | } 101 | 102 | void uiNode::mouseUp(float x,float y){ 103 | ofRectangle globalBoundingBox = boundingBox; 104 | ofVec2f globalPosition = getGlobalPosition(); 105 | 106 | globalBoundingBox.x += globalPosition.x; 107 | globalBoundingBox.y += globalPosition.y; 108 | 109 | if(globalBoundingBox.inside(x, y)){ 110 | cout << "BANG!" << name << std::endl; 111 | ofNotifyEvent(clickedInside, name, this); 112 | 113 | } 114 | 115 | if(childrenEnabled){ 116 | for(uiNode* child : children){ 117 | child->mouseUp(x, y); 118 | } 119 | } 120 | 121 | 122 | 123 | 124 | } 125 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UI/src/uiNode.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // UINode.hpp 3 | // UI 4 | // 5 | // Created by lab101 on 21/04/16. 6 | // 7 | // 8 | 9 | #ifndef UINode_hpp 10 | #define UINode_hpp 11 | 12 | #include 13 | #include "ofMain.h" 14 | 15 | class uiNode{ 16 | 17 | 18 | vector children; 19 | uiNode* parent; 20 | string name; 21 | bool childrenEnabled; 22 | 23 | public: 24 | 25 | uiNode(); 26 | ofEvent clickedInside; 27 | 28 | ofVec2f position; 29 | ofRectangle boundingBox; 30 | 31 | 32 | void setup(float x,float y); 33 | void setup(float x,float y, float width, float height); 34 | 35 | void update(); 36 | void draw(); 37 | 38 | void mouseDown(float x,float y); 39 | void mouseUp(float x,float y); 40 | 41 | 42 | void addChild(uiNode* childNode); 43 | 44 | void setName(string newName); 45 | void getName(); 46 | 47 | 48 | ofVec2f getGlobalPosition(); 49 | 50 | void enableChildren(bool value); 51 | bool hasChildrenEnabled(); 52 | }; 53 | 54 | 55 | 56 | #endif /* UINode_hpp */ 57 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/addons.make: -------------------------------------------------------------------------------- 1 | ofxGui 2 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/08_Pointers_and_UI/UISoundplayer/bin/data/.gitkeep -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/bin/data/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 405.102, -100, -100 3 | 377.041, -43.8775, 259.184 4 | 5 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | ofSetBackgroundColor(0, 0, 0); 6 | menu.setup(200, 999999999, 100, 20, "MENU"); 7 | ofAddListener(menu.onClickInside, this, &ofApp::onNodeClicked); 8 | 9 | 10 | //debugPanel.loadFrom("setttings.xml"); 11 | 12 | 13 | ofDirectory dir; 14 | dir.listDir("sounds"); 15 | 16 | for(int i = 0; i < (int) dir.size(); i++){ 17 | 18 | uiNode* child = new uiNode(); 19 | child->setup(0, 40 + (30*i), 160, 20, dir.getPath(i)); 20 | menu.addChild(child); 21 | 22 | ofAddListener(child->onClickInside, this, &ofApp::onNodeClicked); 23 | } 24 | 25 | nBandsToGet = 60; 26 | fftSmoothed = new float[8192]; 27 | for (int i = 0; i < 8192; i++){ 28 | fftSmoothed[i] = 0; 29 | } 30 | 31 | kick = 0; 32 | 33 | camera.setupPerspective(); 34 | camera.setFov(120); 35 | camera.lookAt(ofVec3f( nBandsToGet * 10 * 0.5 ,0,0)); 36 | camera.setPosition(ofVec3f(nBandsToGet * 10 * 0.5,0,200)); 37 | 38 | debugPanel.setup(); 39 | debugPanel.add(cameraLookAt.setup("lookat",ofVec3f(100,100,100),ofVec3f(-100,-100,-100),ofVec3f(1000,1000,1000))); 40 | debugPanel.add(cameraPosition.setup("position",ofVec3f(100,100,100),ofVec3f(-100,-100,-100),ofVec3f(1000,1000,1000))); 41 | 42 | } 43 | 44 | 45 | 46 | void ofApp::onNodeClicked(string& nodeName){ 47 | if(nodeName == "MENU"){ 48 | menu.setChildrenEnabled(!menu.getChildrenEnabled()); 49 | }else{ 50 | cout << "PLAY " << nodeName << endl; 51 | soundPlayer.load(nodeName); 52 | soundPlayer.play(); 53 | } 54 | 55 | } 56 | 57 | 58 | 59 | //-------------------------------------------------------------- 60 | void ofApp::update(){ 61 | menu.position.y = 30.0f + (sin(ofGetElapsedTimef()) * 14.0f); 62 | ofSoundUpdate(); 63 | 64 | camera.lookAt(cameraLookAt); 65 | camera.setPosition(cameraPosition); 66 | 67 | // (5) grab the fft, and put in into a "smoothed" array, 68 | // by taking maximums, as peaks and then smoothing downward 69 | float * val = ofSoundGetSpectrum(nBandsToGet); 70 | // request 128 values for fft 71 | for (int i = 0;i < nBandsToGet; i++){ 72 | 73 | // let the smoothed calue sink to zero: 74 | fftSmoothed[i] *= 0.79f; 75 | 76 | // take the max, either the smoothed or the incoming: 77 | if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; 78 | 79 | } 80 | 81 | 82 | kick *= 0.96; 83 | 84 | if(val[0] > 0.8){ 85 | kick += pow(val[0]*2,2); 86 | } 87 | 88 | 89 | } 90 | 91 | //-------------------------------------------------------------- 92 | void ofApp::draw(){ 93 | 94 | ofSetBackgroundColor(kick, kick, kick); 95 | 96 | 97 | camera.begin(); 98 | for (int i = 0;i < nBandsToGet; i++){ 99 | // ofDrawCircle(i* 10, fftSmoothed[i] * 600.0, 20); 100 | 101 | ofVec3f position(i*10, 0 , 0); 102 | ofDrawBox(position, 10, fftSmoothed[i] * 200.0, 3); 103 | } 104 | camera.end(); 105 | 106 | menu.draw(); 107 | ofDrawBitmapString(ofToString(kick), 10, 10); 108 | debugPanel.draw(); 109 | 110 | } 111 | 112 | //-------------------------------------------------------------- 113 | void ofApp::keyPressed(int key){ 114 | 115 | } 116 | 117 | //-------------------------------------------------------------- 118 | void ofApp::keyReleased(int key){ 119 | 120 | } 121 | 122 | //-------------------------------------------------------------- 123 | void ofApp::mouseMoved(int x, int y ){ 124 | 125 | } 126 | 127 | //-------------------------------------------------------------- 128 | void ofApp::mouseDragged(int x, int y, int button){ 129 | 130 | } 131 | 132 | //-------------------------------------------------------------- 133 | void ofApp::mousePressed(int x, int y, int button){ 134 | 135 | 136 | } 137 | 138 | //-------------------------------------------------------------- 139 | void ofApp::mouseReleased(int x, int y, int button){ 140 | menu.mouseUp(x, y); 141 | } 142 | 143 | //-------------------------------------------------------------- 144 | void ofApp::mouseEntered(int x, int y){ 145 | 146 | } 147 | 148 | //-------------------------------------------------------------- 149 | void ofApp::mouseExited(int x, int y){ 150 | 151 | } 152 | 153 | //-------------------------------------------------------------- 154 | void ofApp::windowResized(int w, int h){ 155 | 156 | } 157 | 158 | //-------------------------------------------------------------- 159 | void ofApp::gotMessage(ofMessage msg){ 160 | 161 | } 162 | 163 | //-------------------------------------------------------------- 164 | void ofApp::dragEvent(ofDragInfo dragInfo){ 165 | 166 | } 167 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "uiNode.hpp" 5 | #include "ofxGui.h" 6 | 7 | class ofApp : public ofBaseApp{ 8 | 9 | uiNode menu; 10 | ofSoundPlayer soundPlayer; 11 | 12 | 13 | float* fftSmoothed; 14 | int nBandsToGet; 15 | float kick; 16 | 17 | ofxPanel debugPanel; 18 | ofxVec3Slider cameraPosition; 19 | ofxVec3Slider cameraLookAt; 20 | 21 | ofCamera camera; 22 | ofLight light; 23 | 24 | public: 25 | void setup(); 26 | void update(); 27 | void draw(); 28 | 29 | void keyPressed(int key); 30 | void keyReleased(int key); 31 | void mouseMoved(int x, int y ); 32 | void mouseDragged(int x, int y, int button); 33 | void mousePressed(int x, int y, int button); 34 | void mouseReleased(int x, int y, int button); 35 | void mouseEntered(int x, int y); 36 | void mouseExited(int x, int y); 37 | void windowResized(int w, int h); 38 | void dragEvent(ofDragInfo dragInfo); 39 | void gotMessage(ofMessage msg); 40 | 41 | void onNodeClicked(string& nodeName); 42 | 43 | 44 | 45 | }; 46 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/src/uiNode.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // uiNode.cpp 3 | // UISoundplayer 4 | // 5 | // Created by Kris Meeusen on 22/04/16. 6 | // 7 | // 8 | 9 | #include "uiNode.hpp" 10 | 11 | 12 | void uiNode::setup(float x,float y, float width,float height,string newName){ 13 | 14 | position.set(x, y); 15 | size.set(width, height); 16 | 17 | 18 | name = newName; 19 | // testje! 20 | //this->name =name; 21 | 22 | childrenEnabled = true; 23 | parent = nullptr; 24 | } 25 | 26 | 27 | void uiNode::addChild(uiNode* child){ 28 | children.push_back(child); 29 | child->parent = this; 30 | } 31 | 32 | void uiNode::setChildrenEnabled(bool enabled){ 33 | childrenEnabled = enabled; 34 | } 35 | 36 | bool uiNode::getChildrenEnabled(){ 37 | return childrenEnabled; 38 | } 39 | 40 | 41 | ofVec2f uiNode::getGlobalPosition(){ 42 | 43 | ofVec2f globalPosition = position; 44 | 45 | if(parent != nullptr){ 46 | globalPosition += parent->getGlobalPosition(); 47 | } 48 | 49 | return globalPosition; 50 | } 51 | 52 | 53 | 54 | 55 | void uiNode::mouseUp(float x,float y){ 56 | 57 | 58 | ofRectangle boundingbox(getGlobalPosition(),size.x,size.y); 59 | 60 | if(boundingbox.inside(x,y)){ 61 | cout << name << endl; 62 | ofNotifyEvent(onClickInside, name, this); 63 | 64 | 65 | } 66 | 67 | 68 | if(childrenEnabled){ 69 | for(uiNode* node : children){ 70 | node->mouseUp(x, y); 71 | } 72 | } 73 | 74 | 75 | } 76 | 77 | 78 | 79 | 80 | void uiNode::draw(){ 81 | ofNoFill(); 82 | 83 | ofPushMatrix(); 84 | ofTranslate(position); 85 | 86 | ofDrawRectangle(0,0, size.x, size.y); 87 | ofDrawBitmapString(name,ofVec2f(4,14)); 88 | 89 | if(childrenEnabled){ 90 | for(uiNode* node : children){ 91 | node->draw(); 92 | } 93 | } 94 | 95 | ofPopMatrix(); 96 | 97 | } 98 | -------------------------------------------------------------------------------- /08_Pointers_and_UI/UISoundplayer/src/uiNode.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // uiNode.hpp 3 | // UISoundplayer 4 | // 5 | // Created by Kris Meeusen on 22/04/16. 6 | // 7 | // 8 | 9 | #ifndef uiNode_hpp 10 | #define uiNode_hpp 11 | 12 | #include "ofMain.h" 13 | 14 | 15 | class uiNode{ 16 | 17 | ofVec2f size; 18 | 19 | vector children; 20 | uiNode* parent; 21 | 22 | bool childrenEnabled; 23 | 24 | public: 25 | 26 | ofVec2f position; 27 | ofEvent onClickInside; 28 | 29 | string name; 30 | 31 | void setup(float x,float y, float width,float height,string name); 32 | void addChild(uiNode* child); 33 | 34 | 35 | void setChildrenEnabled(bool enabled); 36 | bool getChildrenEnabled(); 37 | 38 | ofVec2f getGlobalPosition(); 39 | 40 | void mouseUp(float x,float y); 41 | 42 | 43 | void draw(); 44 | 45 | }; 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | #endif /* uiNode_hpp */ 60 | -------------------------------------------------------------------------------- /09_Kaleidoscope/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/09_Kaleidoscope/addons.make -------------------------------------------------------------------------------- /09_Kaleidoscope/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/09_Kaleidoscope/bin/data/.gitkeep -------------------------------------------------------------------------------- /09_Kaleidoscope/bin/data/CYstTNNUsAA0uKp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/09_Kaleidoscope/bin/data/CYstTNNUsAA0uKp.jpg -------------------------------------------------------------------------------- /09_Kaleidoscope/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /09_Kaleidoscope/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /09_Kaleidoscope/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | 6 | 7 | ofSetBackgroundColor(0, 0, 0); 8 | ofSetColor(255, 255, 255); 9 | 10 | 11 | vidGrabber.setDeviceID(0); 12 | vidGrabber.setDesiredFrameRate(60); 13 | vidGrabber.initGrabber(1024,768); 14 | 15 | float h = sin(ofDegToRad(angleStep )) * radius ; 16 | float w = cos(ofDegToRad(angleStep)) * radius; 17 | 18 | bool yOffset = false; 19 | 20 | float x = 200; 21 | float y = 200; 22 | for(int x = w; x < ofGetWindowWidth(); x += (w*3)){ 23 | for(int y=h; y < ofGetWindowHeight() + h * 2; y+=(h*2)){ 24 | int newY = y + ((yOffset) ? -h : 0); 25 | createMesh(ofVec2f(x,newY)); 26 | } 27 | yOffset = !yOffset; 28 | } 29 | 30 | } 31 | 32 | 33 | void ofApp::createMesh(ofVec3f center){ 34 | 35 | ofMesh mesh; 36 | 37 | mesh.setMode(OF_PRIMITIVE_TRIANGLES); 38 | 39 | // ofVec3f center(ofGetWindowWidth() * 0.5,ofGetWindowHeight() * 0.5, 0); 40 | 41 | bool flip = false; 42 | 43 | for(float angle = 0; angle < 360 ; angle += angleStep){ 44 | float angleRad = ofDegToRad(angle); 45 | float angle2Rad = ofDegToRad(angle + angleStep); 46 | 47 | // go to center 48 | mesh.addVertex(center); 49 | mesh.addTexCoord(ofVec2f(1024*0.5,0)); 50 | 51 | // add point 1 52 | ofVec3f p1 = ofVec3f(cos(angleRad) * radius,sin(angleRad) * radius ,0); 53 | mesh.addVertex(center + p1); 54 | 55 | // punt2 56 | ofVec3f p2 = ofVec3f(cos(angle2Rad) * radius,sin(angle2Rad) * radius ,0); 57 | mesh.addVertex(center + p2); 58 | 59 | if(flip){ 60 | mesh.addTexCoord(ofVec2f(128,768)); 61 | mesh.addTexCoord(ofVec2f(1024-128,768)); 62 | }else{ 63 | mesh.addTexCoord(ofVec2f(1024-128,768)); 64 | mesh.addTexCoord(ofVec2f(128,768)); 65 | } 66 | flip = !flip; 67 | } 68 | 69 | meshes.push_back(mesh); 70 | } 71 | 72 | 73 | //-------------------------------------------------------------- 74 | void ofApp::update(){ 75 | vidGrabber.update(); 76 | } 77 | 78 | //-------------------------------------------------------------- 79 | void ofApp::draw(){ 80 | vidGrabber.getTexture().bind(); 81 | 82 | for(ofMesh& mesh : meshes){ 83 | mesh.draw(); 84 | } 85 | 86 | vidGrabber.getTexture().unbind(); 87 | 88 | } 89 | 90 | -------------------------------------------------------------------------------- /09_Kaleidoscope/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | class ofApp : public ofBaseApp{ 6 | 7 | //ofMesh mesh; 8 | 9 | vector meshes; 10 | 11 | ofImage image; 12 | ofVideoGrabber vidGrabber; 13 | 14 | float radius = 180; 15 | float angleStep = 60; 16 | 17 | 18 | public: 19 | 20 | void createMesh(ofVec3f center); 21 | 22 | void setup(); 23 | void update(); 24 | void draw(); 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/addons.make: -------------------------------------------------------------------------------- 1 | ofxGui 2 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/10_genetic_algorigthm/bin/data/.gitkeep -------------------------------------------------------------------------------- /10_genetic_algorigthm/bin/data/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 0.106647 3 | 6.564 4 | 0.05781 5 | 6 | 7 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/src/DNA.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // DNA.cpp 3 | // 11_genetic_algorigthm 4 | // 5 | // Created by Kris Meeusen on 10/05/17. 6 | // 7 | // 8 | 9 | #include "DNA.hpp" 10 | 11 | 12 | void DNA::setRandomValues(int samples){ 13 | 14 | speed.reserve(samples); 15 | direction.reserve(samples); 16 | 17 | for(int i =0; i < samples; ++i){ 18 | 19 | speed.push_back(ofRandom(0.1, 26)); 20 | direction.push_back(ofVec2f(ofRandom(-1,1),ofRandom(-1,1))); 21 | } 22 | } 23 | 24 | 25 | void DNA::crossover(DNA& incoming){ 26 | 27 | int nrOfFrames = incoming.speed.size(); 28 | 29 | int middlePoint = ofRandom(nrOfFrames); 30 | for(int i = middlePoint; i < nrOfFrames; ++ i){ 31 | 32 | speed[i] = incoming.speed[i]; 33 | direction[i] = incoming.direction[i]; 34 | } 35 | } 36 | 37 | void DNA::mutate(float mutationFactor) { 38 | for (int i = 0; i < speed.size(); i++) { 39 | if (ofRandom(1.0) < mutationFactor) { 40 | speed[i] = ofRandom(0.1, 26); 41 | direction[i] = ofVec2f(ofRandom(-1,1),ofRandom(-1,1)); 42 | 43 | } 44 | } 45 | } 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/src/DNA.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // DNA.hpp 3 | // 11_genetic_algorigthm 4 | // 5 | // Created by Kris Meeusen on 10/05/17. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "ofMain.h" 12 | 13 | class DNA{ 14 | 15 | 16 | 17 | public: 18 | vector direction; 19 | vector speed; 20 | 21 | void setRandomValues(int samples); 22 | void crossover(DNA& incoming); 23 | void mutate(float mutationFactor); 24 | }; -------------------------------------------------------------------------------- /10_genetic_algorigthm/src/Obstacle.h: -------------------------------------------------------------------------------- 1 | // 2 | // Obstacle.h 3 | // 11_genetic_algorigthm 4 | // 5 | // Created by Kris Meeusen on 11/05/17. 6 | // 7 | // 8 | 9 | #ifndef Obstacle_h 10 | #define Obstacle_h 11 | 12 | #include "ofMain.h" 13 | 14 | class Obstacle : public ofRectangle{ 15 | 16 | public: 17 | 18 | bool isHit = false; 19 | 20 | Obstacle(float x,float y,float width,float height) : ofRectangle ( x, y, width, height) { 21 | isHit = false; 22 | }; 23 | 24 | 25 | Obstacle(ofVec2f p1, ofVec2f p2) : ofRectangle (p1, p2) { 26 | isHit = false; 27 | }; 28 | 29 | 30 | // Obstacle::Obstacle(int x, int y, int width,int height){ 31 | // 32 | // } 33 | }; 34 | 35 | 36 | #endif /* Obstacle_h */ 37 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/src/Rocket.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Rocket.cpp 3 | // 11_genetic_algorigthm 4 | // 5 | // Created by Kris Meeusen on 10/05/17. 6 | // 7 | // 8 | 9 | #include "Rocket.hpp" 10 | 11 | 12 | 13 | Rocket::Rocket(ofVec2f newPosition){ 14 | position = newPosition; 15 | } 16 | 17 | 18 | void Rocket::update(int frameIndex,vector& obstacles,float interpolationFactor){ 19 | 20 | if(isDead) return; 21 | 22 | aliveFrames++; 23 | 24 | if(isWinner) return; 25 | 26 | framesToWin++; 27 | 28 | direction.interpolate(dna.direction[frameIndex],interpolationFactor); 29 | // same function as in interpolate 30 | float targetSpeed = dna.speed[frameIndex]; 31 | speed = speed * (1-interpolationFactor) + targetSpeed * interpolationFactor; 32 | 33 | 34 | 35 | for(Obstacle& r : obstacles){ 36 | 37 | ofVec2f closestPoint (ofClamp(position.x, r.x, r.x + r.width),ofClamp(position.y, r.y, r.y + r.height)); 38 | 39 | if(closestPoint.distance(position) < radius){ 40 | isDead = true; 41 | r.isHit = true; 42 | return; 43 | } 44 | } 45 | 46 | position += (direction *speed); 47 | } 48 | 49 | void Rocket::checkDistance(ofVec2f &target){ 50 | bestDistanceToTarget = fminf(bestDistanceToTarget,fabs(target.distance(position))); 51 | } 52 | 53 | 54 | void Rocket::setStartValues(ofVec2f startPosition){ 55 | 56 | direction = dna.direction[0]; 57 | speed = dna.speed[0]; 58 | isDead = false; 59 | isWinner = false; 60 | //isReplay = false; 61 | aliveFrames =0; 62 | framesToWin =0; 63 | bestDistanceToTarget = 1000000; 64 | position = startPosition; 65 | } 66 | 67 | void Rocket::draw(){ 68 | 69 | if(isWinner){ 70 | ofSetColor(255, 255, 255); 71 | }else if(isDead){ 72 | ofSetColor(255, 0, 0); 73 | }else{ 74 | ofSetColor(255,255,255,200); 75 | 76 | 77 | // quick to fix for OF API change in drawarrow. 78 | ofVec3f pos1Vec3 = ofVec3f(position.x,position.y,0); 79 | ofVec3f directionVec3 = ofVec3f(direction.x,direction.y,0); 80 | ofVec3f pos2Vec3 = pos1Vec3 + (directionVec3 * speed * 10); 81 | 82 | ofDrawArrow(pos1Vec3,pos2Vec3); 83 | //ofDrawArrow(position, position + (direction *speed * 10),4); 84 | } 85 | 86 | ofDrawCircle(position,radius); 87 | } 88 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/src/Rocket.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Rocket.hpp 3 | // 11_genetic_algorigthm 4 | // 5 | // Created by Kris Meeusen on 10/05/17. 6 | // 7 | // 8 | 9 | #pragma once 10 | 11 | #include "ofMain.h" 12 | #include "DNA.hpp" 13 | #include "Obstacle.h" 14 | 15 | class Rocket{ 16 | 17 | float speed; 18 | ofVec2f direction; 19 | 20 | float radius = 4; 21 | 22 | public: 23 | bool isDead; 24 | bool isWinner; 25 | bool isReplay; 26 | 27 | int framesToWin; 28 | float bestDistanceToTarget; 29 | float aliveFrames; 30 | 31 | DNA dna; 32 | ofVec2f position; 33 | 34 | void setStartValues(ofVec2f startPosition); 35 | 36 | Rocket(ofVec2f newPosition); 37 | 38 | void setup(); 39 | void update(int frameIndex,vector& obstacles, float interpolationFactor); 40 | void checkDistance(ofVec2f& target); 41 | void draw(); 42 | 43 | 44 | 45 | }; 46 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /10_genetic_algorigthm/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | #include "Rocket.hpp" 6 | #include "Obstacle.h" 7 | #include "ofxGui.h" 8 | 9 | 10 | class ofApp : public ofBaseApp{ 11 | 12 | 13 | ofxPanel gui; 14 | ofxFloatSlider mutationFactor; 15 | ofxFloatSlider aliveRewardFactor; 16 | ofxFloatSlider distanceRewardFactor; 17 | ofxFloatSlider interPolationFactor; 18 | 19 | vector rockets; 20 | vector obstacles; 21 | 22 | // used to make a new selection; 23 | vector newDNAset; 24 | vector mattingPool; 25 | 26 | ofVec2f startDrag; 27 | ofVec2f targetPosition; 28 | ofVec2f startPosition; 29 | 30 | bool replayMode = false; 31 | bool isRunning = false; 32 | 33 | int nrOfFrames; 34 | int wins; 35 | float firstWin; 36 | 37 | float currentFrame; 38 | int nrOfSimulations; 39 | int currentGeneration; 40 | 41 | float bestFitness; 42 | long avgFitness; 43 | 44 | void createNewSelection(); 45 | 46 | public: 47 | void setup(); 48 | void update(); 49 | void draw(); 50 | 51 | void keyPressed(int key); 52 | void keyReleased(int key); 53 | void mouseMoved(int x, int y ); 54 | void mouseDragged(int x, int y, int button); 55 | void mousePressed(int x, int y, int button); 56 | void mouseReleased(int x, int y, int button); 57 | }; 58 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | # INSTALL 2 | 3 | Clone this repository in /openframeworks/apps/ 4 | To be futureproof no specific IDE files are included. 5 | You can create them easily with the projectGenerator using the below instructions. 6 | This way you have project files for you IDE in a eye blink. 7 | 8 | 9 | ![Image](/Images/1_install.png) 10 | ![Image](/Images/2_install.png) 11 | -------------------------------------------------------------------------------- /Images/10_Kaleidoscope.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/10_Kaleidoscope.png -------------------------------------------------------------------------------- /Images/1_drawSample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/1_drawSample.png -------------------------------------------------------------------------------- /Images/1_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/1_install.png -------------------------------------------------------------------------------- /Images/2_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/2_install.png -------------------------------------------------------------------------------- /Images/2_particles_and_noise.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/2_particles_and_noise.jpg -------------------------------------------------------------------------------- /Images/3_shootTheFinger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/3_shootTheFinger.png -------------------------------------------------------------------------------- /Images/4_basicTracking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/4_basicTracking.png -------------------------------------------------------------------------------- /Images/5_3D_space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/5_3D_space.png -------------------------------------------------------------------------------- /Images/6_arduino.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/6_arduino.png -------------------------------------------------------------------------------- /Images/7_Networking_OSC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/7_Networking_OSC.png -------------------------------------------------------------------------------- /Images/9_UI_and_sound.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/9_UI_and_sound.png -------------------------------------------------------------------------------- /Images/extra_particles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/Images/extra_particles.png -------------------------------------------------------------------------------- /OSCProxy/addons.make: -------------------------------------------------------------------------------- 1 | ofxOsc 2 | -------------------------------------------------------------------------------- /OSCProxy/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/OSCProxy/bin/data/.gitkeep -------------------------------------------------------------------------------- /OSCProxy/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /OSCProxy/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /OSCProxy/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | sender.setup("10.3.208.96", 9001); 6 | receiver.setup(9001); 7 | kick = -1; 8 | } 9 | 10 | //-------------------------------------------------------------- 11 | void ofApp::update(){ 12 | while(receiver.hasWaitingMessages()){ 13 | 14 | kick = 100; 15 | // get the next message 16 | ofxOscMessage incomingMessage; 17 | receiver.getNextMessage(incomingMessage); 18 | 19 | sender.sendMessage(incomingMessage); 20 | 21 | } 22 | } 23 | 24 | //-------------------------------------------------------------- 25 | void ofApp::draw(){ 26 | 27 | ofSetCircleResolution(40); 28 | if(kick > 0){ 29 | kick-= (kick*0.03); 30 | ofDrawCircle(ofGetWindowSize() * 0.5,kick); 31 | } 32 | 33 | } 34 | 35 | //-------------------------------------------------------------- 36 | void ofApp::keyPressed(int key){ 37 | kick = 100; 38 | } 39 | 40 | //-------------------------------------------------------------- 41 | void ofApp::keyReleased(int key){ 42 | 43 | } 44 | 45 | //-------------------------------------------------------------- 46 | void ofApp::mouseMoved(int x, int y ){ 47 | 48 | } 49 | 50 | //-------------------------------------------------------------- 51 | void ofApp::mouseDragged(int x, int y, int button){ 52 | 53 | } 54 | 55 | //-------------------------------------------------------------- 56 | void ofApp::mousePressed(int x, int y, int button){ 57 | 58 | } 59 | 60 | //-------------------------------------------------------------- 61 | void ofApp::mouseReleased(int x, int y, int button){ 62 | 63 | } 64 | 65 | //-------------------------------------------------------------- 66 | void ofApp::mouseEntered(int x, int y){ 67 | 68 | } 69 | 70 | //-------------------------------------------------------------- 71 | void ofApp::mouseExited(int x, int y){ 72 | 73 | } 74 | 75 | //-------------------------------------------------------------- 76 | void ofApp::windowResized(int w, int h){ 77 | 78 | } 79 | 80 | //-------------------------------------------------------------- 81 | void ofApp::gotMessage(ofMessage msg){ 82 | 83 | } 84 | 85 | //-------------------------------------------------------------- 86 | void ofApp::dragEvent(ofDragInfo dragInfo){ 87 | 88 | } 89 | -------------------------------------------------------------------------------- /OSCProxy/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxOsc.h" 5 | 6 | 7 | class ofApp : public ofBaseApp{ 8 | 9 | 10 | 11 | float kick; 12 | 13 | ofxOscSender sender; 14 | ofxOscReceiver receiver; 15 | 16 | public: 17 | void setup(); 18 | void update(); 19 | void draw(); 20 | 21 | void keyPressed(int key); 22 | void keyReleased(int key); 23 | void mouseMoved(int x, int y ); 24 | void mouseDragged(int x, int y, int button); 25 | void mousePressed(int x, int y, int button); 26 | void mouseReleased(int x, int y, int button); 27 | void mouseEntered(int x, int y); 28 | void mouseExited(int x, int y); 29 | void windowResized(int w, int h); 30 | void dragEvent(ofDragInfo dragInfo); 31 | void gotMessage(ofMessage msg); 32 | 33 | }; 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OFLessons 2 | Samples used in a openframeWorks course which I teach at EHB brussels. 3 | Covering different topics. 4 | Always interested in giving this course at other places. 5 | Most of the samples can be made fancier or more performant but for educational purpose they are as simple as possible. 6 | 7 | Check the [INSTALL instructions](INSTALL.md) 8 | 9 | 10 | Getting familiar with drawing and setting up new files and classes. 11 | ![Image](/Images/1_drawSample.png) 12 | Using Noise and particles. 13 | ![Image](/Images/2_particles_and_noise.jpg) 14 | More particles and blob tracking with background subtraction. 15 | Short demo video: https://www.instagram.com/p/BCN23Tolh8D/ 16 | ![Image](/Images/3_shootTheFinger.png) 17 | Make your own tracking by drawing on white paper without subtraction. 18 | ![Image](/Images/4_basicTracking.png) 19 | Getting familiar on working in 3D space in OF. 20 | ![Image](/Images/5_3D_space.png) 21 | Connecting an Arduino. 22 | ![Image](/Images/6_arduino.png) 23 | Networking OSC client & Server. 24 | ![Image](/Images/7_Networking_OSC.png) 25 | Usage of pointers and some extra eyecandy to make it more fun. 26 | ![Image](/Images/9_UI_and_sound.png) 27 | Kaleidoscope: ofMesh and texture exercise. 28 | Short demo video: https://www.instagram.com/p/zSkjlmFh8N/ 29 | ![Image](/Images/10_Kaleidoscope.png) 30 | Another simple particle example 31 | ![Image](/Images/extra_particles.png) 32 | 33 | -------------------------------------------------------------------------------- /extra_particles_noise1/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_particles_noise1/addons.make -------------------------------------------------------------------------------- /extra_particles_noise1/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_particles_noise1/bin/data/.gitkeep -------------------------------------------------------------------------------- /extra_particles_noise1/bin/data/text.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_particles_noise1/bin/data/text.jpg -------------------------------------------------------------------------------- /extra_particles_noise1/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /extra_particles_noise1/src/Particle.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Particle.hpp" 3 | 4 | 5 | void Particle::setup(ofVec2f newPosition){ 6 | position = newPosition; 7 | startPosition = newPosition; 8 | 9 | reset(); 10 | } 11 | 12 | 13 | void Particle::reset(){ 14 | position = startPosition; 15 | velocity = -ofRandom(4) - ofMap(startPosition.x, 0, ofGetWindowWidth(), 6, 0); 16 | direction.set(ofRandom(1.1, 18), ofRandom(-2, 2)); 17 | 18 | alpha = ofMap(direction.x + (direction.y*0.4), 0.1, 20, 270, 100,true); 19 | strokeSize = ofMap(direction.x + (direction.y*0,1), 0.1, 20, 4, 1,true); 20 | 21 | 22 | } 23 | 24 | 25 | void Particle::update(bool startMoving){ 26 | 27 | drawPosition = position; 28 | 29 | if(startMoving){ 30 | 31 | velocity += 0.01; 32 | 33 | float xNoise = ofSignedNoise(ofGetElapsedTimef() * 0.004 ,startPosition.y) * 3.0f; 34 | float yNoise = ofSignedNoise(ofGetElapsedTimef() * 0.2 ,startPosition.x) * 62.0f; 35 | 36 | 37 | float v = fmax(0,velocity); 38 | position += (direction * v); 39 | drawPosition = position + ofVec2f(xNoise,yNoise) * fmax(0,v); 40 | 41 | } 42 | 43 | 44 | } 45 | 46 | void Particle::draw(){ 47 | 48 | 49 | 50 | float r = ofMap(direction.x, 0.1, 30, 1, 8,true); 51 | float length = ofMap(direction.x, 0.1, 30, 1, 4,true); 52 | 53 | 54 | ofColor c; 55 | c = c.fromHsb(alpha, 180, 200); 56 | 57 | ofSetColor(c); 58 | ofSetLineWidth(strokeSize); 59 | 60 | 61 | 62 | 63 | float yNoise = ofSignedNoise(startPosition.x + ofGetElapsedTimef() * 0.2 ,startPosition.y) * 12.0f; 64 | 65 | 66 | //drawPosition += ofVec2f(0,yNoise); 67 | 68 | ofDrawLine(drawPosition, drawPosition + (direction * length) +ofVec2f(0,yNoise) ); 69 | 70 | 71 | } 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /extra_particles_noise1/src/Particle.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "ofMain.h" 5 | 6 | class Particle{ 7 | 8 | ofVec2f direction; 9 | 10 | public: 11 | 12 | ofVec2f startPosition; 13 | 14 | ofVec2f position; 15 | ofVec2f drawPosition; 16 | bool isActive = false; 17 | 18 | float velocity; 19 | float alpha; 20 | float strokeSize; 21 | 22 | 23 | public: 24 | 25 | void setup(ofVec2f newPosition); 26 | void update(bool startMoving); 27 | void draw(); 28 | 29 | void reset(); 30 | 31 | }; -------------------------------------------------------------------------------- /extra_particles_noise1/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /extra_particles_noise1/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | 6 | 7 | ofSetFrameRate(60); 8 | ofEnableAlphaBlending(); 9 | ofSetBackgroundColor(255, 240, 255); 10 | 11 | ofSetCircleResolution(10); 12 | 13 | int gridSize = 7; 14 | started = false; 15 | 16 | image.load("text.jpg"); 17 | 18 | 19 | 20 | for(float x=0;x250 ){ 25 | 26 | Particle p; 27 | p.isActive = true; 28 | 29 | p.setup(ofVec2f(x ,y+ 200)); 30 | particles.push_back(p); 31 | } 32 | } 33 | } 34 | 35 | } 36 | 37 | 38 | 39 | 40 | 41 | //-------------------------------------------------------------- 42 | void ofApp::update(){ 43 | 44 | 45 | for (Particle& p : particles) { 46 | p.update(started); 47 | } 48 | 49 | } 50 | 51 | //-------------------------------------------------------------- 52 | void ofApp::draw(){ 53 | for (Particle& p1 : particles) { 54 | if(!p1.isActive) continue; 55 | 56 | p1.draw(); 57 | } 58 | 59 | } 60 | 61 | //-------------------------------------------------------------- 62 | void ofApp::keyPressed(int key){ 63 | if(key == 'f') ofToggleFullscreen(); 64 | if(key == ' ') started = !started; 65 | 66 | if(key == 'r') { 67 | 68 | for (Particle& p2 : particles) { 69 | 70 | p2.reset(); 71 | started = false; 72 | } 73 | 74 | 75 | 76 | } 77 | } 78 | 79 | //-------------------------------------------------------------- 80 | void ofApp::keyReleased(int key){ 81 | 82 | } 83 | 84 | //-------------------------------------------------------------- 85 | void ofApp::mouseMoved(int x, int y ){ 86 | for (Particle& p : particles) { 87 | // search for available particle. 88 | if(!p.isActive){ 89 | p.position = ofVec2f(x,y); 90 | p.isActive = true; 91 | return; 92 | } 93 | } 94 | 95 | } 96 | 97 | 98 | -------------------------------------------------------------------------------- /extra_particles_noise1/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "Particle.hpp" 5 | 6 | class ofApp : public ofBaseApp{ 7 | 8 | vector particles; 9 | 10 | ofImage image; 11 | 12 | bool started; 13 | 14 | 15 | public: 16 | 17 | 18 | 19 | void setup(); 20 | void update(); 21 | void draw(); 22 | 23 | void keyPressed(int key); 24 | void keyReleased(int key); 25 | void mouseMoved(int x, int y ); 26 | }; 27 | -------------------------------------------------------------------------------- /extra_particles_noise2/addons.make: -------------------------------------------------------------------------------- 1 | ofxGui 2 | -------------------------------------------------------------------------------- /extra_particles_noise2/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_particles_noise2/bin/data/.gitkeep -------------------------------------------------------------------------------- /extra_particles_noise2/bin/data/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.001 4 | 0.00001 5 | 0.012388 6 | 0.03037 7 | 1.2 8 | 14 9 | 3 10 | 88 11 | 28 12 | 9.91e-06 13 | 1.01 14 | 1.0625 15 | 0 16 | 17 | -------------------------------------------------------------------------------- /extra_particles_noise2/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /extra_particles_noise2/src/Particle.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Particle.hpp" 3 | 4 | 5 | 6 | void Particle::setup(){ 7 | // this will add small hue variations. 8 | hueOffset = ofRandom(-3,4); 9 | maxTrailSize = ofRandom(10,100); 10 | trailIndex = 0; 11 | speed = 0; 12 | } 13 | 14 | void Particle::update(){ 15 | position += (direction * speed); 16 | 17 | // if(trail.size() < maxTrailSize){ 18 | // trail.push_back(position); 19 | // }else{ 20 | // if(++trailIndex >= maxTrailSize){ 21 | // trailIndex = 0; 22 | // } 23 | // trail[trailIndex] = position; 24 | // } 25 | 26 | trail2.push_front(position); 27 | 28 | if(trail2.size() > maxTrailSize){ 29 | std::list::iterator range_end = trail2.end(); 30 | std::advance(range_end,-1); 31 | trail2.erase(range_end,trail2.end()); 32 | } 33 | } 34 | 35 | 36 | void Particle::resetTrail(){ 37 | trailIndex =0; 38 | trail2.clear(); 39 | } 40 | 41 | void Particle::draw(){ 42 | 43 | // mapping speed to hsl values. 44 | // this will result in particle colors changing 45 | // according to speed 46 | float hue = ofMap(speed, 6, 8, 150,160,true); 47 | float brigthness = ofMap(speed, 6, 8, 100,150,true); 48 | float sat = ofMap(speed, 8, 6, 140,170,true); 49 | 50 | ofColor newColor = ofColor::fromHsb(hue + hueOffset, sat, 255, 190); 51 | // newColor.a = 120; 52 | ofSetColor(newColor); 53 | 54 | // changing the linelength and width according to the 55 | // speed 56 | // using pow to make big values pop-out more 57 | float lineLength = fmax(pow(speed,1.2) * .5, 12.4); 58 | // float lineWidth = ofClamp(5-(pow(speed,1.2) * 0.3), 2.0,4.0); 59 | float lineWidth = ofMap((pow(speed,1.2) * 0.3), 1, 11, 4.5, .5,true); 60 | 61 | ofSetLineWidth(lineWidth); 62 | ofDrawLine(position, position + (direction * lineLength)); 63 | 64 | ofVec2f* prev = nullptr; 65 | float a = 120; 66 | float hoffset = 255; 67 | float satOffset = sat; 68 | 69 | for(auto& t : trail2){ 70 | if(prev != nullptr){ 71 | hoffset -= .5; 72 | // satOffset -= 1.25; 73 | 74 | ofColor newColor = ofColor::fromHsb(hue, sat, hoffset, 190); 75 | // newColor.a = 120; 76 | ofSetColor(newColor); 77 | ofDrawLine(*prev,t); 78 | } 79 | prev = &t; 80 | } 81 | 82 | // ofDrawBitmapString(ofToString(speed), position + ofVec2f(20,0)); 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /extra_particles_noise2/src/Particle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | 4 | 5 | class Particle{ 6 | 7 | float hueOffset; 8 | 9 | std::list trail2; 10 | std::list trailColor; 11 | 12 | int trailIndex; 13 | int maxTrailSize; 14 | 15 | 16 | public: 17 | 18 | ofVec2f position; 19 | ofVec2f direction; 20 | float speed; 21 | 22 | void setup(); 23 | void update(); 24 | void draw(); 25 | void resetTrail(); 26 | 27 | }; 28 | 29 | -------------------------------------------------------------------------------- /extra_particles_noise2/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /extra_particles_noise2/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "Particle.hpp" 5 | #include "ofxGui.h" 6 | 7 | class ofApp : public ofBaseApp{ 8 | 9 | 10 | vector particles; 11 | std::vector forces; 12 | 13 | // settings 14 | ofxPanel panel; 15 | ofxFloatSlider noiseXSampleScale; 16 | ofxFloatSlider noiseYSampleScale; 17 | ofxFloatSlider noiseDirectionForce; 18 | 19 | ofxFloatSlider attractionForceIn; 20 | ofxFloatSlider attractionForceOut; 21 | 22 | ofxFloatSlider attractionSpeedAccIn; 23 | ofxFloatSlider attractionSpeedAccOut; 24 | 25 | ofxFloatSlider forceRadiusIn; 26 | ofxFloatSlider forceRadiusOut; 27 | ofxToggle debugDraw; 28 | 29 | 30 | 31 | ofxFloatSlider minSpeed; 32 | ofxFloatSlider maxSpeed; 33 | ofxFloatSlider speedNoiseFactor; 34 | 35 | 36 | void setParticleStartPosition(ofVec2f& incomingPosition); 37 | void setParticleStartDirection(ofVec2f& incomingDirection); 38 | 39 | void resetHorizontal(Particle& p); 40 | void resetVertical(Particle& p); 41 | 42 | 43 | void addDirectionNoise(Particle& p); 44 | void addSpeedNoise(Particle& p); 45 | 46 | public: 47 | void setup(); 48 | void update(); 49 | void draw(); 50 | 51 | void mouseMoved(int x, int y ); 52 | void mouseDragged(int x, int y, int button); 53 | void mousePressed(int x, int y, int button); 54 | void mouseReleased(int x, int y, int button); 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /extra_shooter_game/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_shooter_game/addons.make -------------------------------------------------------------------------------- /extra_shooter_game/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_shooter_game/bin/data/.gitkeep -------------------------------------------------------------------------------- /extra_shooter_game/bin/data/boem.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_shooter_game/bin/data/boem.mp3 -------------------------------------------------------------------------------- /extra_shooter_game/bin/data/boem2.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_shooter_game/bin/data/boem2.mov -------------------------------------------------------------------------------- /extra_shooter_game/bin/data/laser.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/extra_shooter_game/bin/data/laser.mp3 -------------------------------------------------------------------------------- /extra_shooter_game/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /extra_shooter_game/src/Particle.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Particle.cpp 3 | // 2_particle_clock 4 | // 5 | // Created by Kris Meeusen on 20/02/2018. 6 | // 7 | 8 | #include "Particle.hpp" 9 | 10 | 11 | Particle::Particle(){ 12 | mIsDead = true; 13 | } 14 | 15 | 16 | void Particle::update(){ 17 | if(!mIsDead){ 18 | 19 | mPosition += (mDirection * mSpeed); 20 | mSpeed *= 1.01; 21 | 22 | mDirection.interpolate(ofVec2f(0,1), 0.028); 23 | } 24 | } 25 | 26 | 27 | void Particle::draw(){ 28 | if(!mIsDead){ 29 | ofDrawCircle(mPosition, mRadius); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /extra_shooter_game/src/Particle.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Particle.hpp 3 | // 2_particle_clock 4 | // 5 | // Created by Kris Meeusen on 20/02/2018. 6 | // 7 | 8 | #pragma once 9 | #include "ofMain.h" 10 | 11 | class Particle{ 12 | 13 | public: 14 | ofVec2f mPosition; 15 | ofVec2f mDirection; 16 | float mSpeed; 17 | float mRadius; 18 | 19 | bool mIsDead; 20 | 21 | Particle(); 22 | 23 | 24 | void update(); 25 | void draw(); 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /extra_shooter_game/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /extra_shooter_game/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "Particle.hpp" 5 | 6 | class Bullet{ 7 | public: 8 | ofVec2f position; 9 | ofVec2f direction; 10 | float speed; 11 | bool active = false; 12 | }; 13 | 14 | 15 | class Enemy{ 16 | public: 17 | ofVec2f position; 18 | ofVec2f direction; 19 | float speed; 20 | bool active = false; 21 | float size; 22 | }; 23 | 24 | 25 | 26 | class ofApp : public ofBaseApp{ 27 | 28 | float triggerSize; 29 | 30 | int points; 31 | int deads; 32 | float angle; 33 | ofVec2f currentDirection; 34 | 35 | vector bullets; 36 | vector enemies; 37 | vector particles; 38 | 39 | 40 | void launchParticles(ofVec2f& position); 41 | ofSoundPlayer boem; 42 | ofSoundPlayer laser; 43 | 44 | float releaseEnemy; 45 | 46 | 47 | public: 48 | void setup(); 49 | void update(); 50 | void draw(); 51 | 52 | void keyPressed(int key); 53 | void keyReleased(int key); 54 | void mouseMoved(int x, int y ); 55 | void mouseDragged(int x, int y, int button); 56 | void mousePressed(int x, int y, int button); 57 | void mouseReleased(int x, int y, int button); 58 | void mouseEntered(int x, int y); 59 | void mouseExited(int x, int y); 60 | void windowResized(int w, int h); 61 | void dragEvent(ofDragInfo dragInfo); 62 | void gotMessage(ofMessage msg); 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /goniCircle/addons.make: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/goniCircle/addons.make -------------------------------------------------------------------------------- /goniCircle/bin/data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lab101/OFLessons/08fade35fc6284bfa6fd475edc84a9f238536597/goniCircle/bin/data/.gitkeep -------------------------------------------------------------------------------- /goniCircle/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /goniCircle/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /goniCircle/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void ofApp::setup(){ 5 | 6 | } 7 | 8 | //-------------------------------------------------------------- 9 | void ofApp::update(){ 10 | 11 | } 12 | 13 | //-------------------------------------------------------------- 14 | void ofApp::draw(){ 15 | 16 | 17 | // drawing from a predefined center 18 | ofVec2f center = ofGetWindowSize() * 0.5; 19 | float radius = 300; 20 | float angleStep = 10; 21 | 22 | // going to through the circle in steps of 60 degrees 23 | for(float i =0; i < 360; i+= angleStep){ 24 | 25 | // converting i which is in degrees to radians 26 | // because sin and cos expect radians and not degrees 27 | float angle = ofDegToRad(i); 28 | // sin and cos wil give results between -1 and 1 29 | // therefore we multiply it by the radius. 30 | float x = cos(angle) * radius; 31 | float y = sin(angle) * radius; 32 | 33 | // the point is calculated from 0,0 34 | // by adding the center we move it to desidered center. 35 | ofVec2f p1 = center + ofVec2f(x,y); 36 | 37 | 38 | ofSetColor(255,i,0); 39 | ofDrawCircle(p1,6); 40 | 41 | } 42 | 43 | ofSetColor(0,255,0); 44 | 45 | ofDrawCircle(center,4); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /goniCircle/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | class ofApp : public ofBaseApp{ 6 | 7 | public: 8 | void setup(); 9 | void update(); 10 | void draw(); 11 | }; 12 | --------------------------------------------------------------------------------