Projektordner für das Team Deutsches Museum (FORUM).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ofApp.cpp 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. #include "ofApp.h"
  2. // *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION *** GLOBALS DEFINITION ****
  3. //--------------------------------------------------------------
  4. void ofApp::setup(){
  5. VISITOR_COUNT = 0;
  6. VISITOR_COUNT_LASTFRAME = 0;
  7. PARTICLE_COUNT = 0;
  8. for (int i = 0; i < particleSystems.size(); i++){
  9. }
  10. // *** OSC Setup *** OSC Setup *** OSC Setup ***
  11. receiver.setup(PORT);
  12. }
  13. //--------------------------------------------------------------
  14. void ofApp::update(){
  15. // *** OSC RECEIVER *** OSC RECEIVER *** OSC RECEIVER ***
  16. /*
  17. Here the program will read and convert the information from the tracking, count them & put coordinates of people entering the ground.
  18. We have to define, how this information will affect the particleSystems!
  19. -Create message, put the stuff from the received OSC in it
  20. -duplicate the msg as string to enable onscreen supervision
  21. -There will be a global visitor count called VISITOR_COUNT
  22. -Use VISITOR_COUNT to correctly update the size of the visitors vector
  23. -Iterate trough Message-values and put information in the visitors vector
  24. */
  25. while(receiver.hasWaitingMessages()){
  26. ofxOscMessage visitorInformations;
  27. receiver.getNextMessage(&visitorInformations);
  28. oscMsg = ofToString(visitorInformations);
  29. if(visitorInformations.getAddress() == "/centroidsOfBlob") {
  30. VISITOR_COUNT_LASTFRAME = VISITOR_COUNT;
  31. VISITOR_COUNT = visitorInformations.getArgAsInt(0); //update the number of Visitors from OSCs first Argument, which is the number of blobs (detected Contours)
  32. // *** CHECK FOR CHANGES IN THE NUMBER OF VISITORS *** CHECK FOR CHANGES IN THE NUMBER OF VISITORS *** CHECK FOR CHANGES IN THE NUMBER OF VISITORS ***
  33. // If there are MORE visitors now, add the difference to the visitors vector
  34. if(VISITOR_COUNT > VISITOR_COUNT_LASTFRAME){
  35. for(int i = 0; i < (VISITOR_COUNT - VISITOR_COUNT_LASTFRAME); i++){
  36. visitors.push_back(new Visitor);
  37. }
  38. }
  39. // If there are LESS visitors now, delete the difference from the visitors vector
  40. if(VISITOR_COUNT < VISITOR_COUNT_LASTFRAME){
  41. for(int i = 0; i < (VISITOR_COUNT_LASTFRAME - VISITOR_COUNT); i++){
  42. delete visitors.at(visitors.size()); //maybe nicht zulässig, weil fehleranfällig???
  43. //erase ergänzen!
  44. }
  45. }
  46. // *** TRANSFER TRACKING-INFORMATION INTO VISITOR-CLASS *** TRANSFER TRACKING-INFORMATION INTO VISITOR-CLASS ***
  47. for(int i = 1; i <= VISITOR_COUNT; i++){
  48. //put Information into visitors
  49. float xOfVisitor = visitorInformations.getArgAsFloat(i * 2 - 1) * ofGetWindowWidth();
  50. float yOfVisitor = visitorInformations.getArgAsFloat(i * 2) * ofGetWindowHeight();
  51. visitors.at( i - 1 )->setPosition(xOfVisitor, yOfVisitor);
  52. }
  53. } //end of .getAddress() == "/centroidsOfBlob")
  54. } //end of receiver.hasWaitingMessages
  55. // *** RFID Input *** RFID Input *** RFID Input *** RFID Input *** RFID Input ***
  56. /*
  57. Here we have to define, how the particleSystems react to RFID input.
  58. Read ID of a visitor and let the particlesystems react to it.
  59. !!! Here in ofApp.cpp there will only be the transfer of incoming information about IDs, playertypes, etc. into the update-methods of the particleSystems. !!!
  60. For example:
  61. - Tell all particleSystems about a new checkedIn-Visitor
  62. - Set the playerType of one particular particleSystem to the checked in.
  63. */
  64. // *** MAIN UPDATE PARTICLE SYSTEMS *** MAIN UPDATE PARTICLE SYSTEMS *** MAIN UPDATE PARTICLE SYSTEMS ***
  65. for (int p = 0; p < particleSystems.size();)
  66. {
  67. // Update particle systems
  68. // particleSystems.at(p)->update("xxx , xxx , xxx , .... ");
  69. }
  70. } //end of update()
  71. //--------------------------------------------------------------
  72. void ofApp::draw(){
  73. //draw all ParticleSystems that are in the particleSystems vector
  74. for(int p = 0; p < particleSystems.size(); p++)
  75. {
  76. particleSystems.at(p)->draw();
  77. }
  78. }
  79. //--------------------------------------------------------------
  80. void ofApp::keyPressed(int key){
  81. }
  82. //--------------------------------------------------------------
  83. void ofApp::keyReleased(int key){
  84. }
  85. //--------------------------------------------------------------
  86. void ofApp::mouseMoved(int x, int y){
  87. }
  88. //--------------------------------------------------------------
  89. void ofApp::mouseDragged(int x, int y, int button){
  90. }
  91. //--------------------------------------------------------------
  92. void ofApp::mousePressed(int x, int y, int button){
  93. }
  94. //--------------------------------------------------------------
  95. void ofApp::mouseReleased(int x, int y, int button){
  96. }
  97. //--------------------------------------------------------------
  98. void ofApp::mouseEntered(int x, int y){
  99. }
  100. //--------------------------------------------------------------
  101. void ofApp::mouseExited(int x, int y){
  102. }
  103. //--------------------------------------------------------------
  104. void ofApp::windowResized(int w, int h){
  105. }
  106. //--------------------------------------------------------------
  107. void ofApp::gotMessage(ofMessage msg){
  108. }
  109. //--------------------------------------------------------------
  110. void ofApp::dragEvent(ofDragInfo dragInfo){
  111. }
  112. //--------------------------------------------------------------