summaryrefslogtreecommitdiff
path: root/06_performance
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-06-24 23:18:03 +0100
committerComment <tim@gray.(none)>2013-06-24 23:18:03 +0100
commit11229ede83c48fab01e6e566155536b5e7e9d762 (patch)
treedcd2671c419bdbddde9191712dc3cf5ab2a98f04 /06_performance
parentff979a86dc8f031c823cd8806324b0e8c4ca069b (diff)
yay
Diffstat (limited to '06_performance')
-rw-r--r--06_performance/src/oni.cpp18
-rw-r--r--06_performance/src/oni.h16
-rw-r--r--06_performance/src/testApp.cpp19
-rw-r--r--06_performance/src/testApp.h2
4 files changed, 42 insertions, 13 deletions
diff --git a/06_performance/src/oni.cpp b/06_performance/src/oni.cpp
index 3f028fc..346adec 100644
--- a/06_performance/src/oni.cpp
+++ b/06_performance/src/oni.cpp
@@ -98,13 +98,13 @@ void syncOniPlayer::drawCloud(int step){
}
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_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);
+ //glBegin(GL_POINTS);
const XnDepthPixel* depthmap=players[0]->getDepthGenerator().GetDepthMap();
const ofPixels& pixels=players[0]->getImagePixels();
int range=1700;
@@ -121,7 +121,11 @@ void syncOniPlayer::drawPoints(float birth,float life,float dx,float dy, float d
//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);
+ 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
@@ -134,9 +138,9 @@ void syncOniPlayer::drawPoints(float birth,float life,float dx,float dy, float d
pointPool.insert(i);
}
}
- glEnd();
+ //glEnd();
glDisable( GL_BLEND );
- glDisable(GL_PROGRAM_POINT_SIZE);
+ //glDisable(GL_PROGRAM_POINT_SIZE);
}
int syncOniPlayer::getNumParticles(){
return points.size()-pointPool.size();
diff --git a/06_performance/src/oni.h b/06_performance/src/oni.h
index 36d216a..c858995 100644
--- a/06_performance/src/oni.h
+++ b/06_performance/src/oni.h
@@ -22,9 +22,11 @@ class fpoint{
float l=ofGetElapsedTimef()-st;
if (life>l) {
glPointSize((1.0f-(l/life))*size);
+ glBegin(GL_POINTS);
glColor3ub(r,g,b);
//glColor4ub(r,g,b,(unsigned char)255); // ((l/life)*255.0f));
glVertex3f(x-(pow(l,2)*dx),y-(pow(l,2)*dy),z-(pow(l,2)*dz));
+ glEnd();
return true;
}
else {
@@ -37,9 +39,21 @@ class syncOniPlayer{
public:
syncOniPlayer() {
drawable=false;
+ gamma=3.0f;
+ LUT=NULL;
+ makeLUT();
}
~syncOniPlayer(){
stop();
+ //if (LUT) delete[] LUT;
+ }
+ void makeLUT(){
+ if (NULL==LUT){
+ LUT=new uint8_t[0xff];
+ }
+ for (int i=0;i<0xFF;i++) {
+ LUT[i]=(uint8_t)(pow(((float)i)/255.0f,gamma)*255.0f);
+ }
}
void addPlayer(string name);
void play();
@@ -60,6 +74,8 @@ class syncOniPlayer{
bool drawable;
vector<fpoint> points;
set<int> pointPool;
+ float gamma;
+ uint8_t *LUT;
};
//========================================
class oniManager{
diff --git a/06_performance/src/testApp.cpp b/06_performance/src/testApp.cpp
index 57749b0..746d52f 100644
--- a/06_performance/src/testApp.cpp
+++ b/06_performance/src/testApp.cpp
@@ -168,7 +168,10 @@ void testApp::setup(){
else printf("no video clips found!\n");
}
}
-}
+
+ xOffs=startX=yOffs=startY=0;
+};
+
@@ -242,6 +245,9 @@ void testApp::update(){
for (int i=0;i<videoclips.size();i++) videoclips[i].update();
narrator.update();
+
+ xOffs*=.95;
+ yOffs*=.95;
}
//--------------------------------------------------------------
@@ -319,8 +325,8 @@ void testApp::draw(){
}
F_xRotation+=(F_xRotate*interval);
- F_yRotation+=(F_yRotate*interval);
- F_zRotation+=(F_zRotate*interval);
+ F_yRotation+=((F_yRotate+xOffs)*interval);
+ F_zRotation+=((F_zRotate+yOffs)*interval);
F_drawFrames=max(1.99f,min(F_drawFrames+(F_drawStep*interval),(float)BUFFER_FRAMES));
ofPushMatrix();
@@ -588,17 +594,18 @@ void testApp::mouseMoved(int x, int y ){
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
-
+ xOffs=x-startX;
+ yOffs=y-startY;
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
-
+ startX=x;
+ startY=y;
}
//--------------------------------------------------------------
void testApp::mouseReleased(){
-
}
diff --git a/06_performance/src/testApp.h b/06_performance/src/testApp.h
index 337e05b..504cc53 100644
--- a/06_performance/src/testApp.h
+++ b/06_performance/src/testApp.h
@@ -184,6 +184,8 @@ class testApp : public ofBaseApp, public ofxMidiListener{
vector<ofVideoPlayer> videoclips;
ofxOscReceiver receiver;
+
+ float xOffs,startX,yOffs,startY;
};
#endif