From 39bcb5346b1f746399192391b6699e81d0d8ad3a Mon Sep 17 00:00:00 2001 From: Comment Date: Thu, 20 Jun 2013 09:06:40 +0100 Subject: spooky bug fixed, integration nearly right --- 04_playobjects/src/testApp.h | 53 ++---- 06_performance/addons.make | 3 +- .../bin/data/TRSS_nesbitt_recordings.xml | 91 ++++++++++ 06_performance/bin/data/black.mp4 | Bin 0 -> 1531 bytes 06_performance/bin/data/black.png | Bin 0 -> 347 bytes 06_performance/bin/data/verdana.ttf | Bin 0 -> 171792 bytes 06_performance/config.make | 6 +- 06_performance/src/main.cpp | 3 +- 06_performance/src/oni.cpp | 159 +++++++++++++++++- 06_performance/src/oni.h | 47 +++++- 06_performance/src/testApp.cpp | 184 ++++++++++++--------- 06_performance/src/testApp.h | 6 + 12 files changed, 422 insertions(+), 130 deletions(-) create mode 100644 06_performance/bin/data/TRSS_nesbitt_recordings.xml create mode 100644 06_performance/bin/data/black.mp4 create mode 100644 06_performance/bin/data/black.png create mode 100755 06_performance/bin/data/verdana.ttf diff --git a/04_playobjects/src/testApp.h b/04_playobjects/src/testApp.h index 873db31..270245d 100644 --- a/04_playobjects/src/testApp.h +++ b/04_playobjects/src/testApp.h @@ -1,11 +1,8 @@ #ifndef _TEST_APP #define _TEST_APP -#include "ofxOpenNI.h" #include "ofMain.h" #include "ofxXmlSettings.h" -#include "ofxMayaCam.h" - #include "ofxOsc.h" #define OSCPORT 12345 @@ -20,12 +17,8 @@ struct record{ //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(); @@ -86,48 +79,21 @@ class syncOniPlayer{ players[i]->drawDepth(50, 0,520,390); players[i]->drawImage(600, 0,520,390); - int count; - for (int i=0;igetDepthGenerator().GetDepthMap(); - //uint16_t* depthpixels=depthmap.getPixels(); - int range=2500; - - for (int i=0;iprojectiveToWorld(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: "<getDepthGenerator().GetDepthMap(); + const XnDepthPixel* depthmap=players[n]->getDepthGenerator().GetDepthMap(); //uint16_t* depthpixels=depthmap.getPixels(); int range=2500; + + int depthW=players[n]->getWidth(); + int depthH=players[n]->getHeight(); for (int i=0;iprojectiveToWorld(ofPoint(i,j,(float)(depthmap[j*depthW+i]))); + ofPoint p= players[n]->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 + 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); + 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: "< + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#48 tracks +#36 audio, long ones 1,24,36 +#11 segments in poem +# long + take + take + long + take + long seems correct! +# how wrong we can be \ No newline at end of file diff --git a/06_performance/bin/data/black.mp4 b/06_performance/bin/data/black.mp4 new file mode 100644 index 0000000..0da6796 Binary files /dev/null and b/06_performance/bin/data/black.mp4 differ diff --git a/06_performance/bin/data/black.png b/06_performance/bin/data/black.png new file mode 100644 index 0000000..3437bb5 Binary files /dev/null and b/06_performance/bin/data/black.png differ diff --git a/06_performance/bin/data/verdana.ttf b/06_performance/bin/data/verdana.ttf new file mode 100755 index 0000000..8f25a64 Binary files /dev/null and b/06_performance/bin/data/verdana.ttf differ diff --git a/06_performance/config.make b/06_performance/config.make index 261aa2e..e8ff248 100644 --- a/06_performance/config.make +++ b/06_performance/config.make @@ -3,7 +3,7 @@ # OF_ROOT allows to move projects outside apps/* just set this variable to the # absoulte path to the OF root folder -OF_ROOT = ../openFrameworks +OF_ROOT = ../../openFrameworks # USER_CFLAGS allows to pass custom flags to the compiler @@ -17,7 +17,7 @@ USER_CFLAGS = -I $(OF_ROOT)/addons/ofxOpenNI/include/openni -I $(OF_ROOT)/addons # for example libraries like: # USER_LDFLAGS = libs/libawesomelib.a -USER_LDFLAGS = -lusb-1.0 +USER_LDFLAGS = -lusb-1.0 -lOpenNI EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj" @@ -53,4 +53,4 @@ NDK_PLATFORM = android-8 LINUX_ARM7_COMPILER_OPTIMIZATIONS = -march=armv7-a -mtune=cortex-a8 -finline-functions -funroll-all-loops -O3 -funsafe-math-optimizations -mfpu=neon -ftree-vectorize -mfloat-abi=hard -mfpu=vfp - +CXX=colorgcc diff --git a/06_performance/src/main.cpp b/06_performance/src/main.cpp index 58263a2..20767a2 100644 --- a/06_performance/src/main.cpp +++ b/06_performance/src/main.cpp @@ -4,7 +4,8 @@ //======================================================================== int main( ){ - ofSetupOpenGL(4080,768, OF_WINDOW); // <-------- setup the GL context + //ofSetupOpenGL(4080,768, OF_WINDOW); // <-------- setup the GL context + ofSetupOpenGL(1224,232, OF_WINDOW); // <-------- setup the GL context diff --git a/06_performance/src/oni.cpp b/06_performance/src/oni.cpp index a202f41..550d56e 100644 --- a/06_performance/src/oni.cpp +++ b/06_performance/src/oni.cpp @@ -1 +1,158 @@ -#include "oni.h" \ No newline at end of file +#include "oni.h" + +void syncOniPlayer::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 syncOniPlayer::play(){ + for (int i=0;isetSafeThreading(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(2); + drawable=true; + } +} +void syncOniPlayer::update(){ + for (int i=0;iupdate(); + } +} +void syncOniPlayer::pause(){ + for (int i=0;isetSpeed(0.0f); + players[i]->setPaused(true); + } +} +int syncOniPlayer::getCurrentFrame(){ + if (players.size()) return players[0]->getCurrentFrame(); + else return -1; +} +void syncOniPlayer::drawWindows(){ + if (!drawable) return; + for (int i=0;idrawDepth(50, 0,520,390); + players[i]->drawImage(600, 0,520,390); + + + } +} +void syncOniPlayer::drawCloud(int step){ + int count; + for (int n=0;ngetDepthGenerator().GetDepthMap(); + //uint16_t* depthpixels=depthmap.getPixels(); + int range=1700; + + int depthW=players[n]->getWidth(); + int depthH=players[n]->getHeight(); + + for (int i=0;iprojectiveToWorld(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: "<stop(); + delete players[i]; + players[i]=NULL; + } + } + drawable=false; +} +//================= +void oniManager::init(const char* filename){ + playing=-1; + int numDevices=1; + string f=string(filename); + if( !XML.loadFile(f) ){ + printf("unable to load recordings, check data/ folder\n"); + }else{ + if(XML.pushTag("TRSS")) { + int num=XML.getNumTags("rec"); + if(num) { + for (int i=0;inewplayer){ + if (playing>-1) players[playing].stop(); + usleep(100000); + playing=newplayer; + players[playing].play(); + } +} +void oniManager::update(){ + if (players.size()>playing&&playing>-1) players[playing].update(); +} +void oniManager::drawWindows(){ + if (players.size()>playing&&playing>-1) players[playing].drawWindows(); +} +void oniManager::drawCloud(int step){ + if (players.size()>playing&&playing>-1) players[playing].drawCloud(step); +} +void oniManager::previous(){ + int newp=(playing+1)%players.size(); + startPlayer(newp); +} +void oniManager::next(){ + int newp=playing-1<0?players.size()-1:playing-1; + startPlayer(newp); +} \ No newline at end of file diff --git a/06_performance/src/oni.h b/06_performance/src/oni.h index ccb1417..158d513 100644 --- a/06_performance/src/oni.h +++ b/06_performance/src/oni.h @@ -1 +1,46 @@ -#include "ofxOpenNI.h" \ No newline at end of file +#include "ofMain.h" +#include "ofxXmlSettings.h" +#include "ofxOpenNI.h" + + + +//in order to play different clips it seems necessary to have a player per clip +class syncOniPlayer{ + public: + syncOniPlayer() { + drawable=false; + } + ~syncOniPlayer(){ + stop(); + } + void addPlayer(string name); + void play(); + void update(); + void pause(); + int getCurrentFrame(); + void drawWindows(); + void drawCloud(int step); + void stop(); + string audio; + + private: + vector players; + vector filenames; + ofSoundPlayer soundplayer; + bool drawable; + +}; +//======================================== +class oniManager{ + public: + void init(const char* filename); + void startPlayer(int num); + void update(); + void drawWindows(); + void drawCloud(int step); + void previous(); + void next(); + int playing; + ofxXmlSettings XML; + vector players; +}; \ No newline at end of file diff --git a/06_performance/src/testApp.cpp b/06_performance/src/testApp.cpp index d41071a..ac1391b 100644 --- a/06_performance/src/testApp.cpp +++ b/06_performance/src/testApp.cpp @@ -17,11 +17,11 @@ void testApp::setup(){ midiIn.listPorts(); - midiIn.openPort(0); //this was 1 on linux + midiIn.openPort(1); //this was 1 on linux midiIn.addListener(this); midiOut.listPorts(); - midiOut.openPort(0); //this was 1 on linux + midiOut.openPort(1); //this was 1 on linux // 0 output channeLs, // 2 input channels @@ -60,7 +60,7 @@ void testApp::setup(){ F_movieSpeed=0.0; //blendImage.loadImage("blend01.png"); - blendImage.loadMovie("blend01.mov"); + blendImage.loadMovie("blend.mp4"); blendImage.play(); blendImage.setLoopState(OF_LOOP_NORMAL); blendImage.setSpeed(F_movieSpeed); @@ -95,8 +95,8 @@ void testApp::setup(){ F_yRotate=0; F_zRotate=0; - F_xRotation=0; - F_yRotation=180; + F_xRotation=180; + F_yRotation=180; //was 180 F_zRotation=0; F_particleAmount=100; @@ -141,6 +141,11 @@ void testApp::setup(){ fullScreen=false; setMidiState(); + + target.setPosition(0,0,0); + camera.setPosition(0,0,-700); + camera.lookAt(target,ofVec3f(0,1,0)); + narrator.init("TRSS_nesbitt_recordings.xml"); } @@ -171,7 +176,9 @@ void testApp::update(){ I_moviePlaying=I_movieSource; } blendImage.setSpeed(F_movieSpeed); - blendImage.idleMovie(); + //blendImage.idleMovie(); + + narrator.update(); } //-------------------------------------------------------------- @@ -247,86 +254,95 @@ void testApp::draw(){ F_drawFrames=max(1.99f,min(F_drawFrames+(F_drawStep*interval),(float)BUFFER_FRAMES)); ofPushMatrix(); - ofTranslate(hw,hh); - ofRotateX(F_xRotation); - ofRotateY(F_yRotation); - ofRotateZ(F_zRotation); - - - if (inputMode==GRABBER) { - ofSetColor(I_fade2,I_fade2,I_fade2); - ofPushMatrix(); - ofRotateX(90); - ofRotateZ(-90); - outTexture.draw(hw,-hh,-ofGetWidth(),ofGetHeight()); - ofPopMatrix(); - } + //ofTranslate(hw,hh); + camera.begin(); + ofRotateX(F_xRotation); + ofRotateY(F_yRotation); + ofRotateZ(F_zRotation); - GLfloat fogColor[4] = {0,0,0, 1.0}; - glFogi(GL_FOG_MODE, GL_LINEAR); - glFogfv(GL_FOG_COLOR, fogColor); - glFogf(GL_FOG_DENSITY,1.0 ); - glHint(GL_FOG_HINT, GL_DONT_CARE); - glFogf(GL_FOG_START, ofGetWidth()*(0.25+F_drawDecay)); - glFogf(GL_FOG_END, ofGetWidth()*(0.75+F_drawDecay)); - glEnable(GL_FOG); - - //reverse draw order when looking from back - int jStart=0; - int jEnd=F_drawFrames-1; - int jStep=1; - float F_yseg=F_yRotation; - while (F_yseg<-90) F_yseg+=360; - while (F_yseg>270) F_yseg-=360; - if (F_yseg>90) { - jStart=jEnd; - jEnd=0; - jStep=-1; - if (draworder) { - draworder=false; - //printf("switched to reverse order\n"); + /* + if (inputMode==GRABBER) { + ofSetColor(I_fade2,I_fade2,I_fade2); + ofPushMatrix(); + ofRotateX(90); + ofRotateZ(-90); + outTexture.draw(hw,-hh,-ofGetWidth(),ofGetHeight()); + ofPopMatrix(); + } + */ + GLfloat fogColor[4] = {0,0,0, 1.0}; + glFogi(GL_FOG_MODE, GL_LINEAR); + glFogfv(GL_FOG_COLOR, fogColor); + glFogf(GL_FOG_DENSITY,1.0 ); + glHint(GL_FOG_HINT, GL_DONT_CARE); + glFogf(GL_FOG_START, ofGetWidth()*(0.25+F_drawDecay)); + glFogf(GL_FOG_END, ofGetWidth()*(0.75+F_drawDecay)); + glEnable(GL_FOG); + + //reverse draw order when looking from back + int jStart=0; + int jEnd=F_drawFrames-1; + int jStep=1; + float F_yseg=F_yRotation; + while (F_yseg<-90) F_yseg+=360; + while (F_yseg>270) F_yseg-=360; + if (F_yseg>90) { + jStart=jEnd; + jEnd=0; + jStep=-1; + if (draworder) { + draworder=false; + //printf("switched to reverse order\n"); + } + } + else if (!draworder) { + draworder=true; + //printf("switched to normal order\n"); } - } - else if (!draworder) { - draworder=true; - //printf("switched to normal order\n"); - } - for (int j=jStart;j!=jEnd;j+=jStep) { - int fB=(thisFFTbuffer+j)%BUFFER_FRAMES; + for (int j=jStart;j!=jEnd;j+=jStep) { + int fB=(thisFFTbuffer+j)%BUFFER_FRAMES; + + ofPushMatrix(); //coordinate transform for FFT draw direction + ofTranslate(0,0,(j*zStep)-hw); + ofRotateX(F_drawAxis); + + ofFill(); + ofSetColor(0,0,0); + if (B_fill) { + glBegin(GL_QUAD_STRIP); + for (int i = 0; i < lFFTanalyzer.nAverages-1; i++){ + glVertex3f((i*xStep)-hw,-(FFTbuffer[0][i][fB] * F_scale),0); + glVertex3f((i*xStep)-hw,0,0); + } + for (int i =lFFTanalyzer.nAverages, k=lFFTanalyzer.nAverages-1; i < lFFTanalyzer.nAverages+rFFTanalyzer.nAverages; i++, k--){ + glVertex3f((i*xStep)-hw,-(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); + glVertex3f((i*xStep)-hw,0,0); + } + glEnd(); + } + + ofNoFill(); + ofSetLineWidth(F_lineWidth); + ofSetColor(I_fade1,I_fade1,I_fade1); + glBegin(GL_LINE_STRIP); + for (int i = 0; i < lFFTanalyzer.nAverages; i++){ + glVertex3f((i*xStep)-hw,-(FFTbuffer[0][i][fB] * F_scale),0); + } + for (int i =lFFTanalyzer.nAverages, k=lFFTanalyzer.nAverages-1; i < lFFTanalyzer.nAverages+rFFTanalyzer.nAverages; i++, k--){ + glVertex3f((i*xStep)-hw,-(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); + } + glEnd(); + ofPopMatrix(); + } - ofPushMatrix(); //coordinate transform for FFT draw direction - ofTranslate(0,0,(j*zStep)-hw); - ofRotateX(F_drawAxis); + ofPushMatrix(); + ofTranslate(0,150,-1050); + narrator.drawCloud(2); + ofPopMatrix(); - ofFill(); - ofSetColor(0,0,0); - if (B_fill) { - glBegin(GL_QUAD_STRIP); - for (int i = 0; i < lFFTanalyzer.nAverages-1; i++){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[0][i][fB] * F_scale),0); - glVertex3f((i*xStep)-hw,0,0); - } - for (int i =lFFTanalyzer.nAverages, k=lFFTanalyzer.nAverages-1; i < lFFTanalyzer.nAverages+rFFTanalyzer.nAverages; i++, k--){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); - glVertex3f((i*xStep)-hw,0,0); - } - glEnd(); - } + camera.end(); - ofNoFill(); - ofSetLineWidth(F_lineWidth); - ofSetColor(I_fade1,I_fade1,I_fade1); - glBegin(GL_LINE_STRIP); - for (int i = 0; i < lFFTanalyzer.nAverages; i++){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[0][i][fB] * F_scale),0); - } - for (int i =lFFTanalyzer.nAverages, k=lFFTanalyzer.nAverages-1; i < lFFTanalyzer.nAverages+rFFTanalyzer.nAverages; i++, k--){ - glVertex3f((i*xStep)-hw,-(FFTbuffer[1][(lFFTanalyzer.nAverages+rFFTanalyzer.nAverages)-(i+1)][fB] * F_scale),0); - } - glEnd(); - ofPopMatrix(); - } ofPopMatrix(); renderImage.end(); @@ -447,6 +463,8 @@ void testApp::draw(){ glPopMatrix(); */ + + if (showFPS) { ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); ofDrawBitmapString(ofToString(F_xRotation, 4)+" "+ofToString(F_yRotation, 4)+" "+ofToString(F_zRotation, 4),20,30); @@ -464,6 +482,12 @@ void testApp::keyPressed (int key){ fullScreen=!fullScreen; ofSetFullscreen(fullScreen); } + if(key == ','){ + narrator.previous(); + } + if(key == '.'){ + narrator.next(); + } } //-------------------------------------------------------------- diff --git a/06_performance/src/testApp.h b/06_performance/src/testApp.h index cca9e20..b1c086c 100644 --- a/06_performance/src/testApp.h +++ b/06_performance/src/testApp.h @@ -5,6 +5,8 @@ #include "fft.h" #include "FFTOctaveAnalyzer.h" +#include "oni.h" + #define BUFFER_SIZE 1024 #define BUFFER_FRAMES 512 @@ -157,6 +159,10 @@ class testApp : public ofBaseApp, public ofxMidiListener{ ofImage blanker; + + ofCamera camera; + ofNode target; + oniManager narrator; }; #endif -- cgit v1.2.3