From ff979a86dc8f031c823cd8806324b0e8c4ca069b Mon Sep 17 00:00:00 2001 From: Comment Date: Mon, 24 Jun 2013 13:41:50 +0100 Subject: particle scaling --- 06_performance/src/oni.cpp | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to '06_performance/src/oni.cpp') diff --git a/06_performance/src/oni.cpp b/06_performance/src/oni.cpp index 024594f..3f028fc 100644 --- a/06_performance/src/oni.cpp +++ b/06_performance/src/oni.cpp @@ -96,8 +96,15 @@ void syncOniPlayer::drawCloud(int step){ return; } -void syncOniPlayer::drawPoints(float birth,float life,float dx,float dy, float dz){ +void syncOniPlayer::drawPoints(float birth,float life,float dx,float dy, float dz,float size){ if (!drawable) return; + glEnable(GL_PROGRAM_POINT_SIZE); + glEnable(GL_POINT_SMOOTH); + glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + glEnable( GL_BLEND ); + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + //glPointSize( size); + glBegin(GL_POINTS); const XnDepthPixel* depthmap=players[0]->getDepthGenerator().GetDepthMap(); const ofPixels& pixels=players[0]->getImagePixels(); int range=1700; @@ -110,21 +117,29 @@ void syncOniPlayer::drawPoints(float birth,float life,float dx,float dy, float d int j=ofRandom(dmh); ofPoint p= players[0]->projectiveToWorld(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)); + //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,pixels[((j*step*dmw)+(i*step))*3],pixels[((j*step*dmw)+(i*step))*3]+1,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)); + } } } - std::list::iterator i = points.begin(); - while (i != points.end()) - { - if (i->draw(life,dx,dy,dz)) i = points.erase(i); - else ++i; - ++i; + for (int i=0;iplaying&&playing>-1) { - glEnable(GL_PROGRAM_POINT_SIZE); - glEnable(GL_POINT_SMOOTH); - glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glPointSize( size); - glBegin(GL_POINTS); - players[playing].drawPoints(birth,life,dx,dy,dz); - glEnd(); - glDisable( GL_BLEND ); - glDisable(GL_PROGRAM_POINT_SIZE); + players[playing].drawPoints(birth,life,dx,dy,dz,size); } } + -- cgit v1.2.3