summaryrefslogtreecommitdiff
path: root/04_playobjects
diff options
context:
space:
mode:
Diffstat (limited to '04_playobjects')
-rw-r--r--04_playobjects/src/testApp.h221
1 files changed, 0 insertions, 221 deletions
diff --git a/04_playobjects/src/testApp.h b/04_playobjects/src/testApp.h
deleted file mode 100644
index 93cacc4..0000000
--- a/04_playobjects/src/testApp.h
+++ /dev/null
@@ -1,221 +0,0 @@
-#ifndef _TEST_APP
-#define _TEST_APP
-
-#include "ofxOpenNI.h"
-#include "ofMain.h"
-#include "ofxXmlSettings.h"
-#include "ofxMayaCam.h"
-
-#include "ofxOsc.h"
-
-#define OSCPORT 12345
-
-#define MAX_DEVICES 2
-
-struct record{
- vector<string> data;
- string audio;
-};
-
-//in order to play different clips it seems necessary to have a player per clip
-class syncOniPlayer{
- public:
- int depthW;
- int depthH;
- syncOniPlayer() {
- drawable=false;
- depthW=320;
- depthH=240;
- }
- ~syncOniPlayer(){
- stop();
- }
- void addPlayer(string name){
- //ofxOpenNI *o=new ofxOpenNI;
- //o->setupFromONI(name,true);
- //o->setPaused(true);
- //players.push_back(o);
- players.push_back(NULL);
- filenames.push_back(name);
- soundplayer.setLoop(false);
- //players[players.size()-1]->setSpeed(0.0f);
- //players[players.size()-1]->setup(true);
- //players[players.size()-1]->start();
- //players[players.size()-1]->startPlayer(name);
- }
- 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]->addDepthGenerator();
- //players[i]->addImageGenerator();
- //players[i]->setRegister(true);
- players[i]->setLooped(false);
- //players[i]->setBaseUserClass(user);
- players[i]->start();
- //players[players.size()-1]->setSpeed(1.0f);
- if (audio!="") {
- soundplayer.loadSound(audio);
- soundplayer.play();
- };
- sleep(1);
- drawable=true;
- }
- }
- void update(){
- for (int i=0;i<players.size();i++) {
- players[i]->update();
- }
- }
- void pause(){
- for (int i=0;i<players.size();i++) {
- //players[players.size()-1]->setSpeed(0.0f);
- players[i]->setPaused(true);
- }
- }
- int getCurrentFrame(){
- if (players.size()) return players[0]->getCurrentFrame();
- else return -1;
- }
- void drawWindows(){
- if (!drawable) return;
- 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);
-
- 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;
-
- for (int i=0;i<depthW;i+=2) {
-
- glBegin(GL_LINES);
-
- for (int j=0;j<depthH;j+=2) {
-
-
- ofPoint p= players[i]->projectiveToWorld(ofPoint(100,100,(float)(depthmap[2000])));
- //ofPoint p= projectiveToWorld(ofPoint(i,j,(float)depthmap[j*dmw+i]));
-
- if (p.z == 0 || p.z>range) continue; // gets rid of background
-
-
- 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();
- }
-
- }
-
- }
- }
- void drawCloud(){
-
- 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;
-
- for (int i=0;i<depthW;i+=2) {
-
- glBegin(GL_LINES);
-
- for (int j=0;j<depthH;j+=2) {
-
-
- ofPoint p= players[i]->projectiveToWorld(ofPoint(i,j,(float)(depthmap[j*depthW+i])));
- //ofPoint p= projectiveToWorld(ofPoint(i,j,(float)depthmap[j*dmw+i]));
-
- //if (p.z == 0 || p.z>range) continue; // gets rid of background
-
-
- //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();
- for (int i=0;i<players.size();i++) {
- if (players[i]!=NULL) {
- players[i]->stop();
- delete players[i];
- players[i]=NULL;
- }
- }
- drawable=false;
- }
- string audio;
-
- private:
- vector<ofxOpenNI*> players;
- vector<string> filenames;
- ofSoundPlayer soundplayer;
- bool drawable;
-
-};
-
-//however creating losts of ofxOpenNI doesn't seem viable
-//we know we want to play seperate clips
-//however we know that when we stop and start a player it comes back single threaded
-
-class testApp : public ofBaseApp{
-
-public:
- void setup();
- void update();
- void draw();
- void exit();
-
- void keyPressed (int key);
- void keyReleased(int key);
- void mouseMoved(int x, int y );
- void mouseDragged(int x, int y, int button);
- void mousePressed(int x, int y, int button);
- void mouseReleased(int x, int y, int button);
- void windowResized(int w, int h);
-
- void startPlayers(int which);
-
- int numDevices;
- ofxOpenNI openNIPlayers[MAX_DEVICES];
-
- int playing;
-
- ofTrueTypeFont verdana;
-
- ofxXmlSettings XML;
-
- vector<syncOniPlayer> players;
-
- ofxOscReceiver receiver;
-
- bool drawmovies,drawcloud;
- int offset;
-
- ofCamera camera;
- ofNode target;
-
-};
-
-#endif