From 6e447e02cd9a2680bea5bd2dfe1c77fe5ae8efc2 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 26 Jun 2013 11:36:06 +0100 Subject: poper fadeout --- 06_performance/src/main.cpp | 2 +- 06_performance/src/oni.cpp | 90 +++++++++++++++++++++++++++++------------- 06_performance/src/oni.h | 5 +++ 06_performance/src/testApp.cpp | 12 +++++- 06_performance/src/testApp.h | 2 +- 5 files changed, 79 insertions(+), 32 deletions(-) (limited to '06_performance/src') diff --git a/06_performance/src/main.cpp b/06_performance/src/main.cpp index 9343609..733d488 100644 --- a/06_performance/src/main.cpp +++ b/06_performance/src/main.cpp @@ -5,7 +5,7 @@ int main( ){ //ofSetupOpenGL(4080,768, OF_WINDOW); // <-------- setup the GL context - ofSetupOpenGL(1550,296, OF_WINDOW); // <-------- setup the GL context + ofSetupOpenGL(1400,262, OF_WINDOW); // <-------- setup the GL context diff --git a/06_performance/src/oni.cpp b/06_performance/src/oni.cpp index 346adec..20b67bb 100644 --- a/06_performance/src/oni.cpp +++ b/06_performance/src/oni.cpp @@ -31,6 +31,8 @@ void syncOniPlayer::play(){ }; //sleep(2); drawable=true; + startTime=ofGetElapsedTimef(); + playerActive=true; } } void syncOniPlayer::update(){ @@ -48,6 +50,10 @@ int syncOniPlayer::getCurrentFrame(){ if (players.size()) return players[0]->getCurrentFrame(); else return -1; } +float syncOniPlayer::getPosition(){ + if (players.size()) return players[0]->getPosition(); + else return -1.0f; +} void syncOniPlayer::drawWindows(){ if (!drawable) return; for (int i=0;igetDepthGenerator().GetDepthMap(); - const ofPixels& pixels=players[0]->getImagePixels(); - int range=1700; - int dmw=players[0]->getWidth(); - int dmh=players[0]->getHeight(); - if (dmw&&dmh){ - int step=pixels.getWidth()/dmw; - for (int o=0;oprojectiveToWorld(ofPoint(i,j,(float)depthmap[j*dmw+i])); - if (p.z <100 || p.z>range) continue; - //points.push_back(fpoint(p.x, p.y, p.z,pixels[((j*step*dmw)+(i*step))*3],pixels[((j*step*dmw)+(i*step))*3]+1,pixels[((j*step*dmw)+(i*step))*3]+2)); - //fpoint f=fpoint(p.x, p.y, p.z,pixels[((j*step*dmw)+(i*step))*3],pixels[((j*step*dmw)+(i*step))*3]+1,pixels[((j*step*dmw)+(i*step))*3]+2); - //f.draw(life,dx,dy,dz); - if (pointPool.size()) {//take 1st dead particle - points[(*pointPool.begin())].setup(p.x, p.y, p.z, - LUT[pixels[((j*step*dmw)+(i*step))*3]], - LUT[pixels[((j*step*dmw)+(i*step))*3]+1], - LUT[pixels[((j*step*dmw)+(i*step))*3]+2] - ); - pointPool.erase(pointPool.begin()); - } - else {//make a new one - points.push_back(fpoint(p.x, p.y, p.z,pixels[((j*step*dmw)+(i*step))*3],pixels[((j*step*dmw)+(i*step))*3]+1,pixels[((j*step*dmw)+(i*step))*3]+2)); - } - } + + if (playerActive){ + //apply envelope + float attackSeconds=2.0f; + float playOutFraction=0.9f; + float birth; + float clipTime=ofGetElapsedTimef()-startTime; + if (clipTimegetPosition()>playOutFraction) { + //cerr<<"playing out!"<getPosition()-playOutFraction)/(1.0f-playOutFraction))); + //if it reaches the end stop creating points but allow old points to play out + if (players[0]->getPosition()>0.99) playerActive=false; + } + else birth=_birth; + + //cerr<getPosition()<getDepthGenerator().GetDepthMap(); + const ofPixels& pixels=players[0]->getImagePixels(); + int range=1700; + int dmw=players[0]->getWidth(); + int dmh=players[0]->getHeight(); + if (dmw&&dmh){ + int step=pixels.getWidth()/dmw; + for (int o=0;oprojectiveToWorld(ofPoint(i,j,(float)depthmap[j*dmw+i])); + if (p.z <100 || p.z>range) continue; + //points.push_back(fpoint(p.x, p.y, p.z,pixels[((j*step*dmw)+(i*step))*3],pixels[((j*step*dmw)+(i*step))*3]+1,pixels[((j*step*dmw)+(i*step))*3]+2)); + //fpoint f=fpoint(p.x, p.y, p.z,pixels[((j*step*dmw)+(i*step))*3],pixels[((j*step*dmw)+(i*step))*3]+1,pixels[((j*step*dmw)+(i*step))*3]+2); + //f.draw(life,dx,dy,dz); + if (pointPool.size()) {//take 1st dead particle + points[(*pointPool.begin())].setup(p.x, p.y, p.z, + LUT[pixels[((j*step*dmw)+(i*step))*3]], + LUT[pixels[((j*step*dmw)+(i*step))*3]+1], + LUT[pixels[((j*step*dmw)+(i*step))*3]+2] + ); + pointPool.erase(pointPool.begin()); + } + else {//make a new one + points.push_back(fpoint(p.x, p.y, p.z,pixels[((j*step*dmw)+(i*step))*3],pixels[((j*step*dmw)+(i*step))*3]+1,pixels[((j*step*dmw)+(i*step))*3]+2)); + } + } + } } for (int i=0;iplaying&&playing>-1) return &players[playing]; + else return NULL; +} diff --git a/06_performance/src/oni.h b/06_performance/src/oni.h index c858995..73edeee 100644 --- a/06_performance/src/oni.h +++ b/06_performance/src/oni.h @@ -42,6 +42,7 @@ class syncOniPlayer{ gamma=3.0f; LUT=NULL; makeLUT(); + playerActive=false; } ~syncOniPlayer(){ stop(); @@ -60,6 +61,7 @@ class syncOniPlayer{ void update(); void pause(); int getCurrentFrame(); + float getPosition(); int getNumParticles(); void drawWindows(); void drawCloud(int step); @@ -76,6 +78,8 @@ class syncOniPlayer{ set pointPool; float gamma; uint8_t *LUT; + float startTime; + bool playerActive; }; //======================================== class oniManager{ @@ -84,6 +88,7 @@ class oniManager{ void startPlayer(int num); int getNumClips(); int getNumParticles(); + syncOniPlayer* getCurrentPlayer(); void update(); void drawWindows(); void drawCloud(int step); diff --git a/06_performance/src/testApp.cpp b/06_performance/src/testApp.cpp index db45680..4cc47a3 100644 --- a/06_performance/src/testApp.cpp +++ b/06_performance/src/testApp.cpp @@ -562,6 +562,8 @@ void testApp::draw(){ msg+="\n"+ofToString(F_yseg, 4); msg+="\n"+ofToString(narrator.getNumParticles())+" size "+ofToString(F_lineWidth); msg+="\n"+ofToString(xModel)+","+ofToString(yModel)+","+ofToString(zModel)+" * "+ofToString(sModel); + syncOniPlayer *player=narrator.getCurrentPlayer(); + if (player) msg+="\n"+ofToString(player->getCurrentFrame())+","+ofToString(player->getPosition(),2); ofDrawBitmapString(msg,20,20); } } @@ -612,12 +614,18 @@ void testApp::keyPressed (int key){ if(key == 'c'){ zModel-=25; } - if(key == 'y'){ + if(key == 'w'){ sModel*=1.02; } - if(key == 'h'){ + if(key == 's'){ sModel/=1.02; } + if(key == 'q'){ + I_fade1=min(I_fade1+1,255); + } + if(key == 'a'){ + I_fade1=max(I_fade1-1,0); + } if(key == 'h'){ F_particleX-=1; } diff --git a/06_performance/src/testApp.h b/06_performance/src/testApp.h index 4ecc24d..87a0b07 100644 --- a/06_performance/src/testApp.h +++ b/06_performance/src/testApp.h @@ -10,7 +10,7 @@ #include "oni.h" -#define BUFFER_SIZE 1024 +#define BUFFER_SIZE 1024 //was 1024 #define BUFFER_FRAMES 512 /* -- cgit v1.2.3