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/oni.cpp | 90 +++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 28 deletions(-) (limited to '06_performance/src/oni.cpp') 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; +} -- cgit v1.2.3