summaryrefslogtreecommitdiff
path: root/07_performance/src/oni.h
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-06-28 23:32:10 +0100
committerComment <tim@gray.(none)>2013-06-28 23:32:10 +0100
commit1a7e15a63d78a6351028d977b90052f6b0d6bf7d (patch)
tree8345507e9c4dd871cd08eb884fe8b9fe2816137d /07_performance/src/oni.h
parentfd8dc2aa23c4bbc297e835e4f920aaf5342aba5e (diff)
first performance version
Diffstat (limited to '07_performance/src/oni.h')
-rw-r--r--07_performance/src/oni.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/07_performance/src/oni.h b/07_performance/src/oni.h
new file mode 100644
index 0000000..4483a35
--- /dev/null
+++ b/07_performance/src/oni.h
@@ -0,0 +1,104 @@
+#include "ofMain.h"
+#include "ofxXmlSettings.h"
+#include "ofxOpenNI.h"
+
+//a colour video particle
+class fpoint{
+ public:
+ fpoint(float _x,float _y, float _z, unsigned char _r,unsigned char _g,unsigned char _b){
+ setup(x,y,z,r,g,b);
+ }
+ void setup(float _x,float _y, float _z, unsigned char _r,unsigned char _g,unsigned char _b){
+ x=_x;y=_y;z=_z;r=_r;g=_g;b=_b;st=ofGetElapsedTimef();active=true;
+ }
+ float x,y,z;
+ float st;
+ unsigned char r,g,b;
+ bool active;
+ bool draw(float life,float dx,float dy,float dz,float size=5.0f){
+ if (!active) {
+ return true;
+ }
+ float l=ofGetElapsedTimef()-st;
+ if (life>l) {
+ glPointSize((1.0f-(l/life))*size);
+ glBegin(GL_POINTS);
+ glColor3ub(r,g,b);
+ //glColor4ub(r,g,b,(unsigned char)255); // ((l/life)*255.0f));
+ glVertex3f(x-(pow(l,2)*dx),y-(pow(l,2)*dy),z-(pow(l,2)*dz));
+ glEnd();
+ return true;
+ }
+ else {
+ active=false;
+ return false;
+ }
+ }
+};
+class syncOniPlayer{
+ public:
+ syncOniPlayer() {
+ drawable=false;
+ gamma=3.0f;
+ LUT=NULL;
+ makeLUT();
+ playerActive=false;
+ }
+ ~syncOniPlayer(){
+ stop();
+ //if (LUT) delete[] LUT;
+ }
+ void makeLUT(){
+ if (NULL==LUT){
+ LUT=new uint8_t[0xff];
+ }
+ for (int i=0;i<0xFF;i++) {
+ LUT[i]=(uint8_t)(pow(((float)i)/255.0f,gamma)*255.0f);
+ }
+ }
+ void addPlayer(string name);
+ void play();
+ void update();
+ void pause();
+ bool isPlaying();
+ int getCurrentFrame();
+ float getPosition();
+ int getNumParticles();
+ string getCurrentFile();
+ void drawWindows();
+ void drawCloud(int step);
+ void drawPoints(float birth,float life,float dx,float dy, float dz,float size);
+ void stop();
+ string audio;
+
+ private:
+ vector<ofxOpenNI*> players;
+ vector<string> filenames;
+ ofSoundPlayer soundplayer;
+ bool drawable;
+ vector<fpoint> points;
+ set<int> pointPool;
+ float gamma;
+ uint8_t *LUT;
+ float startTime;
+ bool playerActive;
+};
+//========================================
+class oniManager{
+ public:
+ void init(const char* filename);
+ void startPlayer(int num);
+ int getNumClips();
+ int getNumParticles();
+ syncOniPlayer* getCurrentPlayer();
+ string getCurrentFile();
+ void update();
+ void drawWindows();
+ void drawCloud(int step);
+ void drawPoints(float size,float birth,float life,float dx,float dy, float dz);
+ void previous();
+ void next();
+ int playing;
+ ofxXmlSettings XML;
+ vector<syncOniPlayer> players;
+}; \ No newline at end of file