summaryrefslogtreecommitdiff
path: root/06_performance/src/oni.cpp
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-06-24 13:41:50 +0100
committerComment <tim@gray.(none)>2013-06-24 13:41:50 +0100
commitff979a86dc8f031c823cd8806324b0e8c4ca069b (patch)
tree73b3e4fa0b6d04f08ae0b64078114a8a36df950e /06_performance/src/oni.cpp
parent5f10387ea9eeb5278f4be2c88049041dcc3530b2 (diff)
particle scaling
Diffstat (limited to '06_performance/src/oni.cpp')
-rw-r--r--06_performance/src/oni.cpp46
1 files changed, 26 insertions, 20 deletions
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<fpoint>::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;i<points.size();i++){
+ if (!points[i].draw(life,dx,dy,dz,size)) {
+ pointPool.insert(i);
+ }
}
+ glEnd();
+ glDisable( GL_BLEND );
+ glDisable(GL_PROGRAM_POINT_SIZE);
}
int syncOniPlayer::getNumParticles(){
- return points.size();
+ return points.size()-pointPool.size();
}
void syncOniPlayer::stop(){
soundplayer.stop();
@@ -195,16 +210,7 @@ int oniManager::getNumParticles(){
}
void oniManager::drawPoints(float size,float birth,float life,float dx,float dy, float dz){
if (players.size()>playing&&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);
}
}
+