123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
-
- #include "ofApp.h"
-
-
- // *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION ****
-
-
- //--------------------------------------------------------------
- void ofApp::setup() {
-
- currentImage = -1;
- ofDisableArbTex();
- ofBackground(0);
-
- //test image
- img.setUseTexture(false);
- if (!img.load("testcard.png"))
- {
- ofLogError("ofApp::setup") << "Could not load image!";
- return;
- }
-
- this->tex.enableMipmap();
- this->tex.loadData(img.getPixels());
-
- //scene properties
- sceneSize.set(1280, 800);
- area.set(0, 0, sceneSize.x, sceneSize.y);
- fbo.allocate(sceneSize.x, sceneSize.y, GL_RGBA);
-
- //clear fbo to make sure there's no scrap
- fbo.begin();
- ofClear(0);
- fbo.end();
-
- //load warp settings from file if present
- //this->warpController.loadSettings("settings.json");
-
- //if there is no file, generate warp
- if (this->warpController.getWarps().empty())
- {
- std::shared_ptr<ofxWarpBase> warp;
-
- warp = this->warpController.buildWarp<ofxWarpPerspective>();
- warp->setSize(sceneSize.x, sceneSize.y);
- warp->setEdges(glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
- }
-
- editingWarp = false;
-
- //testing stuff
- ofSetCircleResolution(60);
- ofSetBackgroundColor(0, 0, 0);
- //ofSetFrameRate(60);
-
- fileImageHex.loadImage("Hexagon.png");
-
- //rainIsActive = true;
- //int particleSystemsForStele = 7; //number of rainparticlesystems (one for single stele)
- //float sceneSizeForSingleParticleSystem = sceneSize.x / particleSystemsForStele; //calculate the widht for every single rainparticlesystem
- //for (int i = 0; i <= particleSystemsForStele - 1; i++) { //create all rainparticlesystem
- // rainParticleSyst.push_back(new RainParticleSystem(i * sceneSizeForSingleParticleSystem, sceneSizeForSingleParticleSystem, sceneSize.y));
- //}
-
-
- VISITOR_COUNT = 0;
- VISITOR_COUNT_LASTFRAME = 0;
- PARTICLE_COUNT = 0;
-
-
- // *** OSC Setup *** OSC Setup *** OSC Setup ***
-
- receiver.setup(PORT);
-
- }
-
- //--------------------------------------------------------------
- void ofApp::update() {
-
-
-
- // *** 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
-
- */
-
-
-
- while (receiver.hasWaitingMessages()) {
-
- ofxOscMessage visitorInformations;
- receiver.getNextMessage(&visitorInformations);
-
- oscMsg = ofToString(visitorInformations);
-
- if (visitorInformations.getAddress() == "/centroidsOfBlob") {
-
- VISITOR_COUNT_LASTFRAME = VISITOR_COUNT;
- VISITOR_COUNT = visitorInformations.getArgAsInt(0); //update the number of Visitors from OSCs first Argument, which is the number of blobs (detected Contours)
-
-
-
- // *** 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 (VISITOR_COUNT > VISITOR_COUNT_LASTFRAME) {
-
- for (int i = 0; i < (VISITOR_COUNT - VISITOR_COUNT_LASTFRAME); i++) {
-
- visitors.push_back(new Visitor);
-
- }
- }
-
-
- // If there are LESS visitors now, delete the difference from the visitors vector
-
-
- if (VISITOR_COUNT < VISITOR_COUNT_LASTFRAME) {
-
- for (int i = 0; i < (VISITOR_COUNT_LASTFRAME - VISITOR_COUNT); i++) {
-
- delete visitors.at(visitors.size()); //maybe nicht zulässig, weil fehleranfällig???
- //erase ergänzen!
- }
-
- }
-
-
- // *** TRANSFER TRACKING-INFORMATION INTO VISITOR-CLASS *** TRANSFER TRACKING-INFORMATION INTO VISITOR-CLASS ***
-
-
- for (int i = 1; i <= VISITOR_COUNT; i++) {
-
- //put Information into visitors
-
- float xOfVisitor = visitorInformations.getArgAsFloat(i * 2 - 1) * ofGetWindowWidth();
- float yOfVisitor = visitorInformations.getArgAsFloat(i * 2) * ofGetWindowHeight();
-
- visitors.at(i - 1)->setPosition(xOfVisitor, yOfVisitor);
-
- }
-
- } //end of .getAddress() == "/centroidsOfBlob")
-
- } //end of receiver.hasWaitingMessages
-
-
-
-
-
-
- // *** RFID Input *** RFID Input *** RFID Input *** RFID Input *** RFID Input ***
-
- /*
-
-
-
- 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.
-
- */
-
-
-
- // *** MAIN UPDATE PARTICLE SYSTEMS *** MAIN UPDATE PARTICLE SYSTEMS *** MAIN UPDATE PARTICLE SYSTEMS ***
-
-
- for (int p = 0; p < particleSystems.size();)
- {
- // Update particle systems
-
- // particleSystems.at(p)->update("xxx , xxx , xxx , .... ");
-
-
- }
-
- if (rainIsActive) { //Movement of the particles of the rainparticlesystems
- for (int i = 0; i < rainParticleSyst.size(); i++) {
- rainParticleSyst.at(i)->updateParticleSystem();
- }
- }
- else if (!rainIsActive){ //Movement of Imageparticlesystems and symbols when rain is false
- for (int i = 0; i < imageParticleSystems.size(); i++) {
- imageParticleSystems.at(i)->updateParticleSystem();
- }
- }
-
-
-
-
- }
-
-
- //--------------------------------------------------------------
- void ofApp::exit() {
- //save warp settings on exit
- this->warpController.saveSettings("settings.json");
- }
-
- //--------------------------------------------------------------
- void ofApp::draw() {
-
-
- fbo.begin();
- ofClear(0, 0, 0);
- //draw stuff here
-
- //ofDrawRectangle(0, 0, 800, 800);
- //ofDrawCircle(sceneSize.x *.5, sceneSize.y * .5, 300);
-
- for (int p = 0; p < particleSystems.size(); p++)
- {
- particleSystems.at(p)->draw();
- }
-
-
- if (rainIsActive) { //drawing the rainparticlesystems
- for (int i = 0; i < rainParticleSyst.size(); i++) {
- rainParticleSyst.at(i)->drawRainParticleSystem();
- }
- }
- else if (!rainIsActive) { //drawing the imageparticlesystems
- for (int i = 0; i < imageParticleSystems.size(); i++) {
- imageParticleSystems.at(i)->drawImageParticleSystem();
- }
- }
-
- //draw all ParticleSystems that are in the particleSystems vector
-
-
- fbo.end();
-
- //do not draw past this point
- //draw warp
- warpController.getWarp(0)->begin();
- fbo.draw(0, 0);
-
- warpController.getWarp(0)->end();
-
- }
-
- //--------------------------------------------------------------
- void ofApp::keyPressed(int key) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::keyReleased(int key) {
- if (key == 'f') //fullscreen
- {
- ofToggleFullscreen();
- }
-
- if (key == 'e') { //Mapping
- editingWarp = !editingWarp;
- warpController.getWarp(0)->setEditing(editingWarp);
- }
-
- //read in the single images and hand over all initial values
- switch (key) {
- case '1':
- imageParticleSystems.push_back(new ImageParticleSystem(sceneSize.x, sceneSize.y, fileImageHex, "PktUmweltTechnik.png"));
- rainIsActive = false;
- currentImage++;
- break;
-
- case '2':
- imageParticleSystems.push_back(new ImageParticleSystem(sceneSize.x, sceneSize.y, fileImageHex, "PktAlltagTechnikUmwelt.png"));
- rainIsActive = false;
- currentImage++;
- break;
-
- case '3':
- imageParticleSystems.push_back(new ImageParticleSystem(sceneSize.x, sceneSize.y, fileImageHex, "PktAlltagWissenschaftUmwelt.png"));
- rainIsActive = false;
- currentImage++;
- break;
- }
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseMoved(int x, int y) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseDragged(int x, int y, int button) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mousePressed(int x, int y, int button) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseReleased(int x, int y, int button) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseEntered(int x, int y) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::mouseExited(int x, int y) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::windowResized(int w, int h) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::gotMessage(ofMessage msg) {
-
- }
-
- //--------------------------------------------------------------
- void ofApp::dragEvent(ofDragInfo dragInfo) {
-
- }
-
- //--------------------------------------------------------------
-
-
|