diff options
Diffstat (limited to '04_playobjects/src')
| -rw-r--r-- | 04_playobjects/src/testApp.cpp | 30 | ||||
| -rw-r--r-- | 04_playobjects/src/testApp.h | 75 |
2 files changed, 83 insertions, 22 deletions
diff --git a/04_playobjects/src/testApp.cpp b/04_playobjects/src/testApp.cpp index c1850f9..6351282 100644 --- a/04_playobjects/src/testApp.cpp +++ b/04_playobjects/src/testApp.cpp @@ -21,7 +21,9 @@ void testApp::setup() { for (int i=0;i<num;i++) { players.push_back(syncOniPlayer()); players[i].addPlayer(XML.getAttribute("rec","left","",i)); - if (numDevices>1) players[i].addPlayer(XML.getAttribute("rec","right","",i)); + if (numDevices==2) { + players[i].addPlayer(XML.getAttribute("rec","right","",i)); + } players[i].audio=XML.getAttribute("rec","audio","",i); } } @@ -34,20 +36,14 @@ void testApp::setup() { receiver.setup(OSCPORT); - user.setUseMaskTexture(true); - user.setUsePointCloud(true); - user.setPointCloudDrawSize(2); // this is the size of the glPoint that will be drawn for the point cloud - user.setPointCloudResolution(2); // this is the step size between points for the cloud -> eg., this sets it to every second point - - drawmovies=false;drawcloud=true; + drawmovies=false;drawcloud=false; } void testApp::startPlayers(int newplayer){ if (playing>-1) players[playing].stop(); - soundplayer.stop(); usleep(100000); playing=newplayer; - players[playing].play(user); + players[playing].play(); } //-------------------------------------------------------------- @@ -82,8 +78,19 @@ void testApp::draw(){ ofPushMatrix(); - if (drawmovies) players[playing].drawWindows(); - if (drawmovies) players[playing].drawCloud(); + if (playing>-1) { + if (drawmovies) { + players[playing].drawWindows(); + } + + if (drawcloud) { + cam.begin(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2,0); + players[playing].drawCloud(); + ofDrawAxis(100); + cam.end(); + } + } ofPopMatrix(); @@ -93,6 +100,7 @@ void testApp::draw(){ msg += "\nclip: "+ofToString(playing); if (playing>-1) msg += "\n"+players[playing].audio; msg += "\noffset: "+ofToString(offset); + if (drawcloud>-1) msg += "\nwith cloud"; verdana.drawString(msg, 10, 10); } diff --git a/04_playobjects/src/testApp.h b/04_playobjects/src/testApp.h index 0de2207..32e6dad 100644 --- a/04_playobjects/src/testApp.h +++ b/04_playobjects/src/testApp.h @@ -4,6 +4,7 @@ #include "ofxOpenNI.h" #include "ofMain.h" #include "ofxXmlSettings.h" +#include "ofxMayaCam.h" #include "ofxOsc.h" @@ -35,21 +36,22 @@ class syncOniPlayer{ //players[players.size()-1]->start(); //players[players.size()-1]->startPlayer(name); } - void play(ofxOpenNIUser user){ + void play(){ for (int i=0;i<players.size();i++) { players[i]=new ofxOpenNI(); //players[i]->setSafeThreading(true); - players[i]->setupFromONI(filenames[i],true); - players[i]->addUserGenerator(); - players[i]->setRegister(true); + players[i]->setupFromONI(filenames[i],false); + //players[i]->addDepthGenerator(); + //players[i]->addImageGenerator(); + //players[i]->setRegister(true); players[i]->setLooped(false); - players[i]->setBaseUserClass(user); + //players[i]->setBaseUserClass(user); players[i]->start(); //players[players.size()-1]->setSpeed(1.0f); if (audio!="") { soundplayer.loadSound(audio); soundplayer.play(); - } + }; } } void update(){ @@ -63,29 +65,81 @@ class syncOniPlayer{ players[i]->setPaused(true); } } + int getCurrentFrame(){ + if (players.size()) return players[0]->getCurrentFrame(); + else return -1; + } void drawWindows(){ for (int i=0;i<players.size();i++) { + if (players[i]==NULL) break; ofTranslate(0, i * 400); players[i]->drawDepth(50, 0,520,390); players[i]->drawImage(600, 0,520,390); } } void drawCloud(){ + /* + int num=0; for (int i=0;i<players.size();i++) { ofPushMatrix(); ofEnableBlendMode(OF_BLENDMODE_ALPHA); int numUsers = players[i]->getNumTrackedUsers(); for (int nID = 0; nID < numUsers; nID++){ ofxOpenNIUser & user = players[i]->getTrackedUser(nID); - user.drawMask(); + //user.drawMask(); ofPushMatrix(); - ofTranslate(ofGetWidth()/2, ofGetHeight()/2, -1000); + ofTranslate(0,0,-1000); user.drawPointCloud(); ofPopMatrix(); } + num+=numUsers; ofDisableBlendMode(); ofPopMatrix(); } + return num; + */ + //cerr<<"drawing "<<players.size()<<" clouds"<<endl; we are getting to here when unititialised + + int count; + for (int i=0;i<players.size();i++) { + + const XnDepthPixel* depthmap=players[i]->getDepthGenerator().GetDepthMap(); + //uint16_t* depthpixels=depthmap.getPixels(); + int range=2500; + + if (players[i]==NULL) { + cerr<<"more spooky shit....!"; + return; + } + int dmw=players[i]->getWidth(); + + for (int i=0;i<players[i]->getWidth();i+=2) { + + glBegin(GL_LINES); + + for (int j=0;j<players[i]->getHeight();j+=2) { + + + + ofPoint p= players[i]->projectiveToWorld(ofPoint(i,j,(float)(depthmap[j*dmw+i]))); + //ofPoint p= projectiveToWorld(ofPoint(i,j,(float)depthmap[j*dmw+i])); + + if (p.z == 0 || p.z>range) continue; // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd + //ofColor color = kinect->getColorAt(x,y); //userID); + //if (col) glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a); + // else + + + glColor4ub((unsigned char)255, (unsigned char)255, (unsigned char)255, (unsigned char)255); + glVertex3f(p.x, p.y, p.z); + //if (i==320&&j==160) cerr<<"world point: "<<p.x<<","<<p.y<<","<<p.z<<endl; + } + + glEnd(); + } + } + + return; } void stop(){ soundplayer.stop(); @@ -130,7 +184,6 @@ public: int numDevices; ofxOpenNI openNIPlayers[MAX_DEVICES]; - ofxOpenNIUser user; int playing; @@ -140,12 +193,12 @@ public: vector<syncOniPlayer> players; - ofSoundPlayer soundplayer; - ofxOscReceiver receiver; bool drawmovies,drawcloud; int offset; + + ofxMayaCam cam; }; |
