/src/testApp.h

http://github.com/mazbox/Speakotron · C Header · 78 lines · 59 code · 19 blank · 0 comment · 2 complexity · d9e14fbd9961c2bd2430b0ad77acb164 MD5 · raw file

  1. #pragma once
  2. #include "ofMain.h"
  3. #include "ofxOpenCv.h"
  4. #include "Mouth.h"
  5. #include "ofxFaceTracker.h"
  6. #include "ofxPd.h"
  7. #include "msaColor.h"
  8. class Particle {
  9. public:
  10. ofPoint pos;
  11. ofPoint vel;
  12. float start;
  13. float size;
  14. msaColor color;
  15. Particle(ofPoint _pos, float _size) {
  16. if(img==NULL) {
  17. img = new ofImage();
  18. img->loadImage("bulb.png");
  19. img->setAnchorPercent(0.5,0.5);
  20. }
  21. size = 1 + 12.f*_size + ofRandom(0, 20);
  22. color.setHSV(ofRandom(50, 99), 1, 1);
  23. pos = _pos; start = pos.x; vel.y = -2; }
  24. void draw() {
  25. color.setGL();
  26. img->draw(pos.x, pos.y, size, size);
  27. glColor4f(1, 1, 1, 1);
  28. }
  29. void update() {
  30. color.a = pos.y/240.f;
  31. size += 1;
  32. vel.x = -2.5f + 5.f*ofNoise(0.02 + ofGetElapsedTimef()*0.2, 0.3 + start/0.1);
  33. pos += vel;
  34. }
  35. bool isAlive() {
  36. if(pos.y < -20) return false;
  37. return true;
  38. }
  39. static ofImage *img;
  40. };
  41. class testApp : public ofBaseApp{
  42. public:
  43. void setup();
  44. void update();
  45. void draw();
  46. void keyPressed (int key);
  47. void mouseMoved(int x, int y );
  48. void mouseDragged(int x, int y, int button);
  49. void mousePressed(int x, int y, int button);
  50. void mouseReleased(int x, int y, int button);
  51. void windowResized(int w, int h);
  52. void audioRequested (float * input, int bufferSize, int nChannels);
  53. ofVideoGrabber vidGrabber;
  54. vector<Mouth> mouths;
  55. int WIDTH, HEIGHT;
  56. ofxPd pd;
  57. vector<Particle> particles;
  58. ofxFaceTracker tracker;
  59. };