123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281 |
-
- #include "ofApp.h"
-
-
- // *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION ****
-
-
- //--------------------------------------------------------------
- void ofApp::setup(){
-
-
- // *** SETUP STUFF FOR MAPPING ***
-
- setupWarpStuff();
-
-
-
-
- // *** SETUP STUFF FOR PROGRAM ***
-
- sceneHeight = ofGetHeight();
- sceneWidth = ofGetWidth();
-
-
- ofSetBackgroundColor(0,0,0);
-
- COUNT_VISITORS = 0;
- COUNT_VISITORS_LASTFRAME = 0;
- COUNT_PARTICLES = 0;
- COUNT_PARTICLESYSTEMS = 0;
- COUNT_OBJECTPHYSICS = 0;
- COUNT_CHECKEDINVISITORS = 0;
-
- activeTypeOfView = LOGIC;
-
- currentMode = PARTICLE_MODE_DEFAULT;
- currentModeHasChanged = false;
-
- deltaT = ofGetLastFrameTime();
-
- logicalBackground.load("images/logicalBackground2.png");
-
-
-
-
-
- // *** OBJECT PHYSICS SETUP *** OBJECT PHYSICS SETUP *** OBJECT PHYSICS SETUP *** OBJECT PHYSICS SETUP ***
-
- //maybe xml default load?
- //we can generate all the fix emitters.
- //1 in the center
- //6 at the "stelen"-bottoms
- //6 at the "stelen"-tops
-
- // *** VERSUCH MIT ofxXmlSettings ***
-
- // cout << xmlForSetup.load("xml/setup.xml") << endl;
-
- xmlForSetup.loadFile("xml/setup.xml");
-
- centerOfScene.x = xmlForSetup.getValue("setup:center:x" , 0.0) * ofGetHeight();
- centerOfScene.y = xmlForSetup.getValue("setup:center:y" , 0.0) * ofGetHeight();
-
- stele1_bottom.x = xmlForSetup.getValue("setup:stele1:x" , 0.0 ) * ofGetHeight();
- stele1_bottom.y = xmlForSetup.getValue("setup:stele1:y" , 0.0 ) * ofGetHeight();
-
- stele2_bottom.x = xmlForSetup.getValue("setup:stele2:x" , 0.0 ) * ofGetHeight();
- stele2_bottom.y = xmlForSetup.getValue("setup:stele2:y" , 0.0 ) * ofGetHeight();
-
- stele3_bottom.x = xmlForSetup.getValue("setup:stele3:x" , 0.0 ) * ofGetHeight();
- stele3_bottom.y = xmlForSetup.getValue("setup:stele3:y" , 0.0 ) * ofGetHeight();
-
- stele4_bottom.x = xmlForSetup.getValue("setup:stele4:x" , 0.0 ) * ofGetHeight();
- stele4_bottom.y = xmlForSetup.getValue("setup:stele4:y" , 0.0 ) * ofGetHeight();
-
- stele5_bottom.x = xmlForSetup.getValue("setup:stele5:x" , 0.0 ) * ofGetHeight();
- stele5_bottom.y = xmlForSetup.getValue("setup:stele5:y" , 0.0 ) * ofGetHeight();
-
- stele6_bottom.x = xmlForSetup.getValue("setup:stele6:x" , 0.0 ) * ofGetHeight();
- stele6_bottom.y = xmlForSetup.getValue("setup:stele6:y" , 0.0 ) * ofGetHeight();
-
- // visitors.emplace_back(new Visitor);
- // visitors.emplace_back(new Visitor);
-
-
-
- // objectPhysics.emplace_back(new Attraktor(visitors.at(0)->getPosition()));
- // objectPhysics.emplace_back(new Attraktor(visitors.at(1)->getPosition()));
-
-
- objectPhysics.emplace_back(new Emitter(centerOfScene));
- // objectPhysics.emplace_back(new Emitter(stele1_bottom));
- //// objectPhysics.emplace_back(new Emitter(stele1_top));
- // objectPhysics.emplace_back(new Emitter(stele2_bottom));
- //// objectPhysics.emplace_back(new Emitter(stele2_top));
- // objectPhysics.emplace_back(new Emitter(stele3_bottom));
- //// objectPhysics.emplace_back(new Emitter(stele3_top));
- // objectPhysics.emplace_back(new Emitter(stele4_bottom));
- //// objectPhysics.emplace_back(new Emitter(stele4_top));
- // objectPhysics.emplace_back(new Emitter(stele5_bottom));
- //// objectPhysics.emplace_back(new Emitter(stele5_top));
- // objectPhysics.emplace_back(new Emitter(stele6_bottom));
- //// objectPhysics.emplace_back(new Emitter(stele6_top));
- ////
-
-
-
-
-
-
- for (int i = 0; i < particleSystems.size(); i++){
-
-
-
- }
-
-
- // *** OSC Setup *** OSC Setup *** OSC Setup ***
-
- receiver.setup(PORT);
- // std::cout << "breakpoint ofApp_1 erreicht" << std::endl;
-
-
-
-
-
-
- // *** TESTINGAREA *** TESTINGAREA *** TESTINGAREA *** TESTINGAREA *** TESTINGAREA ***
-
- // objectPhysics.emplace_back(new Emitter(150, 150));
- // objectPhysics.emplace_back(new Emitter(400, 200));
- //
- //
-
- particleSystems.emplace_back(new ParticleSystem);
- particleSystems.back()->setup();
-
-
-
- // objectPhysics.emplace_back(new AttraktorAufStelen( 1200 , 500));
-
-
-
- // std::cout << "breakpoint ofApp_2, ofApp setup beendet" << std::endl;
-
- }
-
- //--------------------------------------------------------------
- void ofApp::update(){
-
- // sceneHeight = ofGetHeight();
- // if(sceneHeight != sceneHeightLastFrame){
- // // refreshXML
- // }
-
- if(currentMode == PARTICLE_MODE_POLYMESH){
- timerAfterCheckin += deltaT;
- if(timerAfterCheckin >= 7){
- currentMode = PARTICLE_MODE_DEFAULT;
- timerAfterCheckin = 0;
- }
- }
-
- deltaT = ofGetLastFrameTime();
-
- // *** TESTING AREA ***
- // objectPhysics.front()->setPosition(visitors.at(0)->getPosition());
- // objectPhysics.at(1)->setPosition(visitors.at(1)->getPosition());
-
-
- // for(int i = 0; i < objectPhysics.size(); i++){
- //
- // objectPhysics.at(i)->update(deltaT);
- // if(objectPhysics.at(i)->getAge() > 4){
- //
- // delete objectPhysics.at(i);
- // objectPhysics.erase(objectPhysics.begin() + i);
- //
- // }
- // }
-
- // *** READ ATTRAKTORS FROM CHECKEDINVISITORS ***
-
-
-
-
- // *** OSC RECEIVER *** OSC RECEIVER *** OSC RECEIVER ***
-
-
- /*
-
- Here the program will read and convert the information from the tracking, count them & put coordinates of people entering the ground.
- We have to define, how this information will affect the particleSystems!
-
- -Create message, put the stuff from the received OSC in it
- -duplicate the msg as string to enable onscreen supervision
- -There will be a global visitor count called VISITOR_COUNT
- -Use VISITOR_COUNT to correctly update the size of the visitors vector
- -Iterate trough Message-values and put information in the visitors vector
-
- */
-
- COUNT_VISITORS_LASTFRAME = visitors.size();
-
- if(receiver.hasWaitingMessages() == false){
- COUNT_VISITORS = 0;
- }
-
- while(receiver.hasWaitingMessages()){
-
- ofxOscMessage checkinInformations;
- receiver.getNextMessage(&checkinInformations);
-
- oscMsg = ofToString(checkinInformations);
-
-
- cout << "tracking message incoming" << endl;
-
-
- COUNT_VISITORS = checkinInformations.getArgAsInt(0);
-
-
- cout << COUNT_VISITORS << endl;
-
-
- //Größe des visitor-vectors wird festgelegt und auf die größe der ankommenden Trackingdaten angepasst
- if(checkinInformations.getAddress() == "/centroidsOfBlob") {
- if(COUNT_VISITORS_LASTFRAME != COUNT_VISITORS){
-
- if(COUNT_VISITORS_LASTFRAME < COUNT_VISITORS){
-
- for(int i = 0; i < COUNT_VISITORS - COUNT_VISITORS_LASTFRAME; i++){
-
- visitors.emplace_back(new Visitor);
- objectPhysics.emplace_back(new Attraktor(visitors.back()->getPosition()));
- objectPhysics.back()->setIsVisitor(true);
-
- }
-
- }else{
-
- for(int i = 0; i < COUNT_VISITORS_LASTFRAME - COUNT_VISITORS; i++){
-
- delete visitors.back();
- visitors.pop_back();
- delete objectPhysics.back();
- objectPhysics.pop_back();
-
- }
- }
- }
-
- //Fill the visitors vector with the OSC data!
- for(int i = 1; i < visitors.size() +1; i++){
-
- //put Information into visitors
-
- float xOfVisitor = checkinInformations.getArgAsFloat(i * 2 - 1);
- float yOfVisitor = checkinInformations.getArgAsFloat(i * 2) ;
-
- visitors.at( i - 1 )->setPosition(xOfVisitor, yOfVisitor);
-
- }
- }
-
-
-
- if(checkinInformations.getAddress() == "/players"){
-
- stele = getSteleForCheckin(checkinInformations.getArgAsFloat(0)) + 2;
- playerType = getTypeForCheckin(checkinInformations.getArgAsFloat(1));
- // cout << oscMsg << endl;
-
- }
-
- if(checkinInformations.getAddress() == "/go"){
-
- checkedInVisitors.emplace_back(new CheckedInVisitor());
- checkedInVisitors.back()->setup(playerType , stele , sceneWidth, sceneHeight);
-
- if (currentMode != PARTICLE_MODE_POLYMESH){
-
- std::cout << "change of mode to DEFAULT" << std::endl;
- currentMode = PARTICLE_MODE_POLYMESH;
- currentModeHasChanged = true;
-
- }
- }
-
- }
-
-
- //
- // while(receiver.hasWaitingMessages()){
- //
- // ofxOscMessage visitorInformations;
- // receiver.getNextMessage(&visitorInformations);
- //
- // oscMsg = ofToString(visitorInformations);
- //
- // if(visitorInformations.getAddress() == "/centroidsOfBlob") {
- //
- // cout << "tracking message incoming" << endl;
- // COUNT_VISITORS_LASTFRAME = COUNT_VISITORS;
- // COUNT_VISITORS = visitorInformations.getArgAsInt(0); //first Arg of OSC-Message is number of Blobs
- //
- //
- //
- //// *** CHECK FOR CHANGES IN THE NUMBER OF VISITORS *** CHECK FOR CHANGES IN THE NUMBER OF VISITORS *** CHECK FOR CHANGES IN THE NUMBER OF VISITORS ***
- //
- //
- //// If there are MORE visitors now, add the difference to the visitors vector
- //
- //
- // if(COUNT_VISITORS > COUNT_VISITORS_LASTFRAME){
- //
- // for(int i = 0; i < (COUNT_VISITORS - COUNT_VISITORS_LASTFRAME); i++){
- //
- // visitors.emplace_back(new Visitor);
- // COUNT_VISITORS++;
- //
- //
- //
- // }
- // }
- //
- //
- //// If there are LESS visitors now, delete the difference from the visitors vector
- //
- //
- // if(COUNT_VISITORS < COUNT_VISITORS_LASTFRAME){
- //
- // for(int i = 0; i < (COUNT_VISITORS_LASTFRAME - COUNT_VISITORS); i++){
- //
- // delete visitors.at(visitors.size()); //maybe nicht zulässig, weil fehleranfällig???
- // //erase ergänzen!
- // COUNT_VISITORS--;
- // }
- //
- // }
- //
- //
- //// *** TRANSFER TRACKING-INFORMATION INTO VISITOR-CLASS *** TRANSFER TRACKING-INFORMATION INTO VISITOR-CLASS ***
- //
- //
- // for(int i = 1; i <= COUNT_VISITORS; i++){
- //
- // //put Information into visitors
- //
- // float xOfVisitor = visitorInformations.getArgAsFloat(i * 2 - 1) * sceneWidth;
- // float yOfVisitor = visitorInformations.getArgAsFloat(i * 2) * sceneHeight;
- //
- // visitors.at( i - 1 )->setPosition(xOfVisitor, yOfVisitor);
- //
- // }
- //
- // } //end of .getAddress() == "/centroidsOfBlob")
- //
- // } //end of receiver.hasWaitingMessages
- //
-
- // std::cout << "breakpoint ofApp_3 erreicht, OSC-Datenverarbeitung beendet" << std::endl;
-
- // *** RFID Input *** RFID Input *** RFID Input *** RFID Input *** RFID Input ***
-
-
- // *** GENERATE CHECKED IN VISITOR *** GENERATE CHECKED IN VISITOR *** GENERATE CHECKED IN VISITOR ***
-
- //if key 'v' is pressed, a new checkedInVisitor will be generated
-
-
- /*
-
-
-
- Here we have to define, how the particleSystems react to RFID input.
- Read ID of a visitor and let the particlesystems react to it.
-
- !!! Here in ofApp.cpp there will only be the transfer of incoming information
- //about IDs, playertypes, etc. into the update-methods of the particleSystems. !!!
-
- For example:
-
- - Tell all particleSystems about a new checkedIn-Visitor
- - Set the playerType of one particular particleSystem to the checked in.
-
- */
-
- // *** OBJECT PHYSICS UPDATE *** OBJECT PHYSICS UPDATE *** OBJECT PHYSICS UPDATE *** OBJECT PHYSICS UPDATE ***
-
- //update the objectPhysics, like creating Attractors for visitors in the default mode
-
- //get the begin in the object physics vector with visitor information, then set all remaining objectphysics
- int beginOfVisitorsInObjectPhysics = getBeginOfVisitorsInObjectPhysics();
- if(visitors.size()){
- refreshCoordinatesOfVisitorAttraktors(beginOfVisitorsInObjectPhysics, sceneHeight);
- }
-
- // int visitorIterator = 0;
- // for(beginOfVisitorsInObjectPhysics; beginOfVisitorsInObjectPhysics < (visitors.size()+beginOfVisitorsInObjectPhysics); beginOfVisitorsInObjectPhysics++){
- //
- // objectPhysics.at(beginOfVisitorsInObjectPhysics)->setPosition(visitors.at(visitorIterator)->getPosition());
- // visitorIterator++;
- // }
-
- // if(COUNT_VISITORS > visitors.size()){
- // for(int i = 0; i < (COUNT_VISITORS - COUNT_VISITORS_LASTFRAME); i++){
- //
- // objectPhysics.emplace_back(new Attraktor(visitors.at(i)->getPosition()));
- // objectPhysics.at(i)->setIsVisitor(true);
- //
- // }
- // }
- //
- // if(COUNT_VISITORS < COUNT_VISITORS_LASTFRAME){
- // for(int i = 0; i < (COUNT_VISITORS_LASTFRAME - COUNT_VISITORS); i++){
- //
- //
- // // delete objectPhysics.at(i);
- //
- // }
- // }
-
-
-
- //adding/killing/modifying of emitters/attractors (objectPhysics)
- //Following "if" will guarantee, that we only go into the switch once, if the currentModeHasChanged = true
- //Like this we can setup stuff in the update method, without doing it every update
-
- if(currentMode != lastMode){
- currentModeHasChanged = true;
- }
-
- if(currentModeHasChanged == true){
-
- switch (currentMode){
-
- // *** DEFAULT OBJECTPHYSICS *** DEFAULT OBJECTPHYSICS ***
-
- case PARTICLE_MODE_DEFAULT: {
-
- for(int i = 0; i < objectPhysics.size(); i++){
-
- if( (objectPhysics).at(i)->type == "emitter" ){
-
- (objectPhysics).at(i)->setEmitting(true);
-
- }
- }
-
- currentModeHasChanged = false;
-
- break;
-
- }
-
- // *** POLYMESH OBJECTPHYSICS *** POLYMESH OBJECTPHYSICS ***
-
- case PARTICLE_MODE_POLYMESH: {
-
- for(int i = 0; i < objectPhysics.size(); i++){
-
- if( (objectPhysics).at(i)->type == "emitter" ){
-
- (objectPhysics).at(i)->setEmitting(false);
-
- }
- }
-
-
- /*
-
- implement here: Visitors are Attraktors
- implement here: Visitors are Attraktors
- implement here: Visitors are Attraktors
-
- set every visitorrelated ObjectPhysics to attracting = true
-
- for(int i = 0; i < objectPhysics.size(); i++){
-
- if( (objectPhysics).at(i)->type == "attraktor" && objectPhysics).at(i)->isAVisitorObject == true ){
-
- (objectPhysics).at(i)->setAttracting(true);
-
- }
- }
-
-
-
-
- */
-
- currentModeHasChanged = false;
-
- break;
-
- }
-
- // *** RFID OBJECTPHYSICS & GENERATING CHECKEDINVISITORS ***
-
- case PARTICLE_MODE_RFID: {
-
- for(int i = 0; i < objectPhysics.size(); i++){
-
- if( (objectPhysics).at(i)->type == "emitter" ){
-
- (objectPhysics).at(i)->setEmitting(false);
-
- }
- }
-
- // checkedInVisitors.emplace_back(new CheckedInVisitor);
-
- //5 is the stele where it will be displayed, in the future this number will
- //depend on the input, maybe the position ! (check position.distance(stele1-stele6) and
- //do the setup for the closest stele, maybe this can be implemented in the setup
-
- // checkedInVisitors.back->setStele(5);
- // checkedInVisitors.back->setup(playerType that is transmitted by RFID);
-
-
-
-
-
- currentModeHasChanged = false;
-
- break;
- }
-
-
-
-
-
- default:
- int a = 0;
-
-
- }
- }
-
-
-
- // *** UPDATE THE CHECKEDINVISITORS *** UPDATE THE CHECKEDINVISITORS ***
-
- // int beginOfCheckedInVisitors; //returns the position in the objectPhysics-vector that is an checkedInVisitorEmitter
- // for(int i = 0; i < objectPhysics.size(); i++){
- // if(objectPhysics.at(i)->type == "emitterOnStele"){
- //
- // beginOfCheckedInVisitors = i;
- // break;
- // }
- // }
-
-
- for(int i = 0; i < checkedInVisitors.size(); i++){
-
- checkedInVisitors.at(i)->update(deltaT, sceneWidth, sceneHeight);
-
- // //delete the Emitter on the visitors bottom if the visitor gets older than 3 (number can be replaced later)
- if(checkedInVisitors.at(i)->getAge() > 50){
-
- delete checkedInVisitors.at(i);
- checkedInVisitors.erase(checkedInVisitors.begin() + i);
-
- }
- }
-
- // if(checkedInVisitors.at(i)->getStateOfSetup()==false){
- //
- // objectPhysics.emplace_back(new AttraktorOnStele(checkedInVisitors.at(i)->getPosition()));
- // checkedInVisitors.at(i)->setStateOfSetup(true);
- // }
- // else if(checkedInVisitors.at(i)->getStateOfSetup()==true){
- //
- // objectPhysics.back()->setPosition(checkedInVisitors.at(i)->getPosition());
- //
- // }
- //
-
- // if(checkedInVisitors.at(i)->getStateOfSetup()==false){
- //
- // for(int cv = 0; cv < checkedInVisitors.at(i)->attractingPixelsOfHexagon.size(); cv++){
- //
- // objectPhysics.emplace_back(new AttraktorOnStele(checkedInVisitors.at(i)->getPositionsOfAttractingPixels().at(cv)));
- // checkedInVisitors.at(i)->setStateOfSetup(true);
- //
- // }
- // }
-
-
-
- // *** MAIN UPDATE PARTICLE SYSTEMS *** MAIN UPDATE PARTICLE SYSTEMS *** MAIN UPDATE PARTICLE SYSTEMS ***
-
- //Trigger the TORNADO if there are more then 4 visitors and then make the effect sleep for a while
- tornadoTimer += deltaT;
- if(tornadoTimer > 30000){
- tornadoIsPossible = true;
- }
- if(tornadoIsPossible == true){
- if(COUNT_VISITORS > 4){
-
- currentMode = PARTICLE_MODE_TORNADO;
- tornadoIsPossible = false;
- tornadoTimer = 0;
-
- }
- }
-
-
- for (int p = 0; p < particleSystems.size(); p++){
-
- // Update particle systems
-
- //How to modify a specific particleSystem?
- //Scenario: ParticleSystem 5 should become a dot connecting system
-
- // if p=5 dann particleMode = PARTICLE_MODE_POLYMESH
-
- particleSystems.at(p)->update(deltaT, currentMode, &objectPhysics, &checkedInVisitors, sceneWidth, sceneHeight);
-
- // if( neues xml soll übergeben werden, zB taste/zeit)
- // particleSystems.at(p)->loadXML(&xml);
-
- }
- // std::cout << "breakpoint ofApp_4 erreicht, particleSystem.update beendet" << std::endl;
-
-
- //Zähle alle Partikel
- COUNT_PARTICLES = 0;
- for(int i = 0; i < particleSystems.size(); i++)
- {
- int particlesInThisSystem = particleSystems.at(i)->particles.size();
- COUNT_PARTICLES += particlesInThisSystem;
- }
-
- lastMode = currentMode;
- sceneHeightLastFrame = sceneHeight;
-
- } //end of update()
-
-
-
-
- //--------------------------------------------------------------
- void ofApp::draw(){
-
- fbo_warp.begin();
- ofClear(0, 0, 0);
-
- //draw all ParticleSystems that are in the particleSystems vector
-
- for(int p = 0; p < particleSystems.size(); p++)
- {
- particleSystems.at(p)->draw(activeTypeOfView);
-
- }
-
-
- // *** TESTING AREA DRAW *** TESTING AREA DRAW ***
-
- for(int i = 0; i < checkedInVisitors.size() ; i++){
-
- checkedInVisitors.at(i)->draw();
-
- }
- // drawStelen(sceneWidth, sceneHeight);
-
-
- // ---------------------------
-
- //Which view is active and how it will look can be found and modified here:
-
- if(activeTypeOfView == LOGIC){
-
- drawLogicalScene(ofGetWidth(), ofGetHeight());
-
- }
-
- if(activeTypeOfView == MAPPED){
-
- // drawMappedScene(ofGetWidth(), ofGetHeight());
-
- }
-
-
- fbo_warp.end();
-
- // FIRST WARP
- warpControllerCircle.getWarp(0)->begin();
- fbo_warp.getTexture().drawSubsection(0, 0, 3840, 1200, 0, 0, 1200, 1200);
- //fbo_circle.draw(0, 0);
- warpControllerCircle.getWarp(0)->end();
-
- // SECOND WARP
- warpControllerStele1.getWarp(0)->begin();
- fbo_warp.getTexture().drawSubsection(0, 0, 3840, 1200, 2204.444, 0, 293.3333, 1200);
- warpControllerStele1.getWarp(0)->end();
-
-
- // THIRD WARP
- warpControllerStele2.getWarp(0)->begin();
- fbo_warp.getTexture().drawSubsection(0, 0, 3840, 1200, 2631.1111, 0, 293.3333, 1200);
- warpControllerStele2.getWarp(0)->end();
-
- // FOURTH WARP
- warpControllerStele3.getWarp(0)->begin();
- fbo_warp.getTexture().drawSubsection(0, 0, 3840, 1200, 3057.7773, 0, 293.3333, 1200);
- warpControllerStele3.getWarp(0)->end();
-
-
- //Supervision of globals
-
- string countVisitors = ofToString(visitors.size());
- string countParticles = ofToString(COUNT_PARTICLES);
- string countParticleSystems = ofToString(particleSystems.size());
- string countObjectPhysics = ofToString(objectPhysics.size());
- string countCheckedInVisitors = ofToString(checkedInVisitors.size());
-
- ofSetColor(255,255,255);
-
- ofDrawBitmapString("framerate: " + ofToString(ofGetFrameRate()), sceneWidth*0.05, sceneHeight*0.70);
- ofDrawBitmapString("windowWidth: " + ofToString(ofGetWidth()), sceneWidth*0.05, sceneHeight*0.72);
- ofDrawBitmapString("windowHeight: " + ofToString(ofGetHeight()), sceneWidth*0.05, sceneHeight*0.74);
- ofDrawBitmapString("currentMode: " + ofToString(getCurrentModeAsString()), sceneWidth*0.05, sceneHeight*0.76 );
-
- ofDrawBitmapString("visitors: " + countVisitors, sceneWidth*0.05, sceneHeight*0.80);
- ofDrawBitmapString("checkedInVisitors: " + countCheckedInVisitors, sceneWidth*0.05, sceneHeight*0.82);
- ofDrawBitmapString("particleSystems: " + countParticleSystems, sceneWidth*0.05, sceneHeight*0.86);
- ofDrawBitmapString("particles: " + countParticles, sceneWidth*0.05, sceneHeight*0.88);
- ofDrawBitmapString("objectphysics: " + countObjectPhysics, sceneWidth*0.05, sceneHeight*0.9);
-
-
- // ofDrawBitmapString(ofToString(objectPhysics.at(0)->getPosition()), 100, 500);
- if(checkedInVisitors.size()){
- ofDrawBitmapString("oldest Visitor: " + ofToString(checkedInVisitors.at(0)->getAge()), sceneWidth*0.05, sceneHeight*0.94);
- }
- // std::cout << "breakpoint ofApp_5 erreicht, supervision globals beendet" << std::endl;
-
-
-
-
- //Supervision of visitors
-
- for (int i = 0; i < visitors.size(); i++) {
-
- string x = ofToString(visitors.at(i)->getX());
- string y = ofToString(visitors.at(i)->getY());
-
- ofDrawBitmapString("x: " + x + " y: " + y, 100, 100 + i * 20);
- }
-
- // std::cout << "breakpoint ofApp_6 erreicht, supervision visitors beendet" << std::endl;
-
-
-
-
- // std::cout << "breakpoint ofApp_7 erreicht, drawing_ofApp beendet" << std::endl;
-
-
- }
-
- //--------------------------------------------------------------
-
- void ofApp::drawMappedScene(float sceneWidth, float sceneHeight){
-
- float xToDrawNextRect = - (sceneWidth / 18);
-
- for(int i = 0; i < 7; i++){
-
- //draw 40/360 noFill rect and then increase the x for the next
- ofNoFill();
- ofDrawRectangle(xToDrawNextRect, 0.5*sceneHeight, sceneWidth/9, 0.5*sceneHeight);
- xToDrawNextRect += sceneWidth/9;
-
- ofFill();
- //draw 20/360 black rect and then increase the x for the next
- ofDrawRectangle(xToDrawNextRect, 0.5*sceneHeight, sceneWidth/18, 0.5*sceneHeight);
- xToDrawNextRect += sceneWidth/18;
- }
-
-
-
- }
-
- //--------------------------------------------------------------
-
-
- void ofApp::drawGrid(float sceneWidth, float sceneHeight, int rows, int columns){
-
- ofSetColor(50,50,50);
-
- //draw columns
- for(int i = 0; i < columns-1; i++){
- float xStart = (sceneWidth/columns) * (i+1);
- float xEnd = xStart;
- float yStart = 0;
- float yEnd = sceneHeight;
- ofDrawLine(xStart, yStart, xEnd, yEnd);
- }
-
- //draw rows
- for(int i = 0; i < rows-1; i++){
- float yStart = (sceneHeight/rows) * (i+1);
- float yEnd = yStart;
- float xStart = 0;
- float xEnd = sceneWidth;
- ofDrawLine(xStart, yStart, xEnd, yEnd);
-
- }
-
-
-
- }
-
- //--------------------------------------------------------------
-
- void ofApp::drawStelen(float sceneWidth, float sceneHeight){
-
- ofSetColor(60,60,60);
- float widthStele = (sceneWidth - sceneHeight) / 9;
- float heightStele = widthStele*3.5;
- float yToDraw = sceneHeight - heightStele;
- float xBegin = sceneHeight;
-
- //draw rectangles
-
- // for(int i = 0; i < 6; i++){
- //
- // float xToDraw = sceneHeight*0.5 + i * 1.5 * widthStele;
- //
- // ofDrawRectangle(xToDraw, 0 , widthStele, sceneHeight);
- //
- // }
-
- //draw schwarzzonen
-
- ofDrawRectangle(xBegin, 0, widthStele*0.25, sceneHeight);
- xBegin += 0.25*widthStele;
-
- for(int i = 0; i < 5; i++){
-
- xBegin += widthStele;
- ofDrawRectangle(xBegin, 0, widthStele*0.5, sceneHeight);
- xBegin += 0.5*widthStele;
-
- }
- xBegin += widthStele;
- ofDrawRectangle(xBegin, 0, widthStele*0.25, sceneHeight);
-
-
-
-
- }
-
- //--------------------------------------------------------------
-
-
-
- void ofApp::drawLogicalScene(float sceneWidth, float sceneHeight){
-
-
- ofNoFill();
- ofDrawCircle(sceneHeight/2, sceneHeight/2, sceneHeight/2);
- ofFill();
-
-
- }
-
- //--------------------------------------------------------------
-
-
- string ofApp::getCurrentModeAsString(){
-
- string currentModeAsString = "";
-
- if(currentMode == PARTICLE_MODE_POLYMESH){
- currentModeAsString = "POLYMESH";
- }
- else if(currentMode == PARTICLE_MODE_DEFAULT){
- currentModeAsString = "DEFAULT";
- }
- else if(currentMode == PARTICLE_MODE_RFID){
- currentModeAsString = "RFID";
- }
-
-
- return currentModeAsString;
-
-
- }
-
- //--------------------------------------------------------------
-
-
- int ofApp::getTypeForCheckin(float x){
-
- int numberBetween1and4;
-
- if(x < 0.25){
- return 1;
- }else if(x >= 0.25 && x < 0.5){
- return 2;
- }else if(x >= 0.5 && x < 0.75){
- return 3;
- }else{
- return 4;
- }
-
- }
-
-
- //--------------------------------------------------------------
-
-
- int ofApp::getSteleForCheckin(float x){
-
- int numberBetween1and3;
-
- if(x < 0.334){
- return 1;
- }else if(x >= 0.334 && x < 0.667){
- return 2;
- }
- else{
- return 3;
- }
-
- }
-
- //--------------------------------------------------------------
-
- int ofApp::getBeginOfVisitorsInObjectPhysics(){
-
- for(int i = 0; i < objectPhysics.size(); i++){
-
- if(objectPhysics.at(i)->getIsVisitorObject() == true){
- return i;
- }
- }
- }
-
- //--------------------------------------------------------------
-
-
- void ofApp::refreshCoordinatesOfVisitorAttraktors(int beginOfVisitorsInObjectPhysicsVector, float sceneHeight){
-
- for(int i = 0; i < visitors.size(); i++){
-
- float x = visitors.at(i)->getPosition().x * sceneHeight;
- float y = visitors.at(i)->getPosition().y * sceneHeight;
-
- objectPhysics.at(beginOfVisitorsInObjectPhysicsVector + i)->setPosition(x,y);
-
- }
-
-
-
- }
-
- //--------------------------------------------------------------
-
-
- void ofApp::keyPressed(int key){
-
-
- }
-
- //--------------------------------------------------------------
- void ofApp::keyReleased(int key){
-
- if (key == '1') {
-
-
- checkedInVisitors.emplace_back(new CheckedInVisitor());
- checkedInVisitors.back()->setup(1, 1, ofGetWidth(), ofGetHeight());
-
- if (currentMode != PARTICLE_MODE_DEFAULT){
-
- std::cout << "change of mode to DEFAULT" << std::endl;
- currentMode = PARTICLE_MODE_DEFAULT;
- currentModeHasChanged = true;
-
- }
- }
-
-
- // Here the "RFID"-Effect will be faked!
- // For example, pressing '1' will trigger the animation for one of the playertypes.
-
- if ( key == '2') {
-
-
-
- int randomStele = ofRandom(3,6);
-
- checkedInVisitors.emplace_back(new CheckedInVisitor());
- checkedInVisitors.back()->setup(2, randomStele, ofGetWidth(), ofGetHeight());
-
-
- if(currentMode != PARTICLE_MODE_POLYMESH){
-
- std::cout << "change of mode to POLYMESH" << std::endl;
- currentMode = PARTICLE_MODE_POLYMESH;
- currentModeHasChanged = true;
- timerAfterCheckin = 0;
-
- }
- }
-
- if (key == '3') {
-
-
-
- int randomStele = ofRandom(3,6);
-
- checkedInVisitors.emplace_back(new CheckedInVisitor());
- checkedInVisitors.back()->setup(1, randomStele, ofGetWidth(), ofGetHeight());
-
- if(currentMode != PARTICLE_MODE_RFID){
-
- std::cout << "change of mode to RFID" << std::endl;
- currentMode = PARTICLE_MODE_RFID;
- currentModeHasChanged = true;
- timerAfterCheckin = 0;
- //implement starting a timer here, to trigger DEFAULT_MODE after a specific time
- }
- }
-
- if (key == '4') {
-
- if(listeningForStelenInput == true){
-
- int randomStele = ofRandom(3,6);
-
- checkedInVisitors.emplace_back(new CheckedInVisitor());
- checkedInVisitors.back()->setup(2, randomStele, ofGetWidth(), ofGetHeight());
-
-
- }
- }
-
- if (key == '5') {
-
- if(listeningForStelenInput == true){
-
- int randomStele = ofRandom(3,6);
-
- checkedInVisitors.emplace_back(new CheckedInVisitor());
- checkedInVisitors.back()->setup(3, randomStele, ofGetWidth(), ofGetHeight());
-
-
- }
- }
-
- if (key == '6') {
-
- if(listeningForStelenInput == true){
-
- int randomStele = ofRandom(3,6);
-
- checkedInVisitors.emplace_back(new CheckedInVisitor());
- checkedInVisitors.back()->setup(4, randomStele, ofGetWidth(), ofGetHeight());
-
-
- }
- }
-
-
- if ( key == '7') {
-
- if( activeTypeOfView == LOGIC){
-
- activeTypeOfView = MAPPED;
-
- }else if(activeTypeOfView == MAPPED){
-
- activeTypeOfView = LOGIC;
- }
- }
-
- if ( key == 'q') {
-
-
- }
-
- if (key == 's') { //SAVE MAYBE warpControllerStelen
- warpControllerCircle.getWarp(0)->setEditing(false);
- warpControllerStele1.getWarp(0)->setEditing(false);
- warpControllerStele2.getWarp(0)->setEditing(false);
- warpControllerStele3.getWarp(0)->setEditing(false);
-
- }
-
- if (key == 'x') { //Mapping
- // editingWarp = !editingWarp;
- warpControllerCircle.getWarp(0)->setEditing(true);
- }
-
-
- if (key == 'c') { //Mapping
- // editingWarp = !editingWarp;
- warpControllerStele1.getWarp(0)->setEditing(true);
- }
-
- if (key == 'v') { //Mapping
- // editingWarp = !editingWarp;
- warpControllerStele2.getWarp(0)->setEditing(true);
- }
-
- if (key == 'b') { //Mapping
- // editingWarp = !editingWarp;
- warpControllerStele3.getWarp(0)->setEditing(true);
- }
-
- if (key == 'l') {
- // secondWindow.toggleHidden();
- }
-
- if ( key == 'w') {
-
-
- ofToggleFullscreen();
- }
-
-
-
- if ( key == 'r') {
-
- //So we can use the keys 1-6 for different functionalities.
- //If listeningForStelenInput == true there cannot be changes in the mode,
- //but it is possible to generate checkedInVisitors
-
- if( listeningForStelenInput == true){
-
- listeningForStelenInput = false;
-
- }else if(listeningForStelenInput == false){
-
- listeningForStelenInput = true;
-
- }
- }
-
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseMoved(int x, int y){
-
- // if(visitors.size()){
- // visitors.at(0)->setup(x, y);
- // visitors.at(1)->setup(x + 200, y + 200);
- // }
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseDragged(int x, int y, int button){
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mousePressed(int x, int y, int button){
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseReleased(int x, int y, int button){
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseEntered(int x, int y){
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseExited(int x, int y){
-
- }
-
- //--------------------------------------------------------------
- void ofApp::windowResized(int w, int h){
-
- }
-
- //--------------------------------------------------------------
- void ofApp::gotMessage(ofMessage msg){
-
- }
-
- //--------------------------------------------------------------
- void ofApp::dragEvent(ofDragInfo dragInfo){
-
- }
-
- //--------------------------------------------------------------
-
- void ofApp::setupWarpStuff() {
-
- ofDisableArbTex();
- sceneSizeWarp.set(3840, 1200);
-
- fbo_warp.allocate(sceneSizeWarp.x, sceneSizeWarp.y, GL_RGB);
-
- fbo_warp.begin();
- ofClear(0);
- fbo_warp.end();
-
- // * WARP CONTROLLING * * WARP CONTROLLING * * WARP CONTROLLING * * WARP CONTROLLING * * WARP CONTROLLING *
- //load warp settings from file if present
- //this->warpController.loadSettings("settings.json");
-
- //if there is no file, generate warp
-
- if (this->warpControllerCircle.getWarps().empty())
- {
- std::shared_ptr<ofxWarpBase> warpCircle;
-
- warpCircle = this->warpControllerCircle.buildWarp<ofxWarpPerspective>();
- warpCircle->setSize(sceneSizeWarp.x, sceneSizeWarp.y);
- // warp->setEdges(0.0f, 0.0f, 1.0f, 1.0f);
- warpCircle->setControlPoint(0, glm::vec2(0.0f, 0.0f));
- warpCircle->setControlPoint(1, glm::vec2(0.333f, 0.0f));
- warpCircle->setControlPoint(2, glm::vec2(0.333f, 1.0f));
- warpCircle->setControlPoint(3, glm::vec2(0.0f, 1.0f));
-
- }
-
- // SECOND WARP
-
- if (this->warpControllerStele1.getWarps().empty())
- {
- std::shared_ptr<ofxWarpBase> warpStele1;
-
- warpStele1 = this->warpControllerStele1.buildWarp<ofxWarpPerspective>();
- warpStele1->setSize(sceneSizeWarp.x, sceneSizeWarp.y);
- // warp_stelen->setEdges(0.0f, 0.0f, 1.0f, 1.0f);
- warpStele1->setControlPoint(0, glm::vec2(0.57193f, 0.0f));
- warpStele1->setControlPoint(1, glm::vec2(0.64637f, 0.0f));
- warpStele1->setControlPoint(2, glm::vec2(0.64637f, 1.0f));
- warpStele1->setControlPoint(3, glm::vec2(0.57193f, 1.0f));
-
- }
- // THIRD WARP
-
- if (this->warpControllerStele2.getWarps().empty())
- {
- std::shared_ptr<ofxWarpBase> warpStele2;
-
- warpStele2 = this->warpControllerStele2.buildWarp<ofxWarpPerspective>();
- warpStele2->setSize(sceneSizeWarp.x, sceneSizeWarp.y);
- // warp_stelen->setEdges(0.0f, 0.0f, 1.0f, 1.0f);
- warpStele2->setControlPoint(0, glm::vec2(0.68359f, 0.0f));
- warpStele2->setControlPoint(1, glm::vec2(0.75803f, 0.0f));
- warpStele2->setControlPoint(2, glm::vec2(0.75803f, 1.0f));
- warpStele2->setControlPoint(3, glm::vec2(0.68359f, 1.0f));
-
- }
-
- // FORTH WARP
-
- if (this->warpControllerStele3.getWarps().empty())
- {
- std::shared_ptr<ofxWarpBase> warpStele3;
-
- warpStele3 = this->warpControllerStele3.buildWarp<ofxWarpPerspective>();
- warpStele3->setSize(sceneSizeWarp.x, sceneSizeWarp.y);
- // warp_stelen->setEdges(0.0f, 0.0f, 1.0f, 1.0f);
- warpStele3->setControlPoint(0, glm::vec2(0.79525f, 0.0f));
- warpStele3->setControlPoint(1, glm::vec2(0.86969f, 0.0f));
- warpStele3->setControlPoint(2, glm::vec2(0.86969f, 1.0f));
- warpStele3->setControlPoint(3, glm::vec2(0.79525f, 1.0f));
-
- }
-
- }
-
- //--------------------------------------------------------------
-
|