diff options
Diffstat (limited to 'src/viewport.cpp')
| -rwxr-xr-x | src/viewport.cpp | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp index 4f65a6d..aee712e 100755 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -52,7 +52,7 @@ void unbindTex(ofTexture &tex) { viewport::viewport()
{
-
+
//ctor
}
viewport::viewport(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
@@ -75,13 +75,13 @@ void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) { scale=1.0;
fscale=1.0;
xrot=yrot=zrot=0.0f;
-
+
logo.loadImage("logo.png");
}
-void viewport::draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool dologo){
+void viewport::draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool add, bool dologo, bool col){
- /*
+ /*ool ad
ofNode c=ofNode();
ofNode t=ofNode();
t.setParent(c);
@@ -102,7 +102,7 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa */
rb1.begin();
-
+ glDisable(GL_BLEND);
//can be done with texture offset?
int startx=((w-(w*fscale))/2)+xshift;
@@ -115,52 +115,56 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa rb2.draw(i,j,w*fscale,h*fscale);
}
}
-
+
if (fade>254) ofClear(0,0,0);
else if (fade>0) {
- ofEnableAlphaBlending();
+ glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ofSetColor(0,0,0,fade);
ofRect(0,0,w,h);
- ofDisableAlphaBlending();
+ glDisable(GL_BLEND);
}
-
-
+
+
camera.begin();
-
+
ofPushMatrix();
-
+
ofTranslate(0,0,-1500);
xrot+=xr;
yrot+=yr;
zrot+=zr;
- ofRotateY(yrot);
- ofRotateX(xrot);
ofRotateZ(zrot);
-
+ ofRotateX(xrot);
+ + ofRotateY(yrot);
+
float minstep=1.0f/160.0f;
float step = decimate>minstep?1.0f/decimate:160.0f;
float scale=w/640.0f;
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
+
+ glEnable(GL_BLEND); + if (add) glBlendFunc(GL_ONE,GL_ONE);
+ else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
if (mode==POINTS) {
glEnable(GL_PROGRAM_POINT_SIZE);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
-
+
glPointSize(feat);
glBegin(GL_POINTS);
-
-
+
+
for(float y = 0.0f; y < 480.0f; y += step) {
for(float x = 0.0f; x < 640.0f; x += step) {
ofVec3f pos = kinect->getWorldCoordinateAt(x, y);
if (pos.z == 0 || pos.z>range) continue; // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd
ofColor color = kinect->getColorAt(x,y); //userID);
- glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a);
+ if (col) glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a); + else glColor4ub((unsigned char)255, (unsigned char)255, (unsigned char)255, (unsigned char)255);
glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
}
}
@@ -180,15 +184,16 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa glEnd();
glBegin(GL_LINE_STRIP);
continue;
- } // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd
+ } // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd ofColor color = kinect->getColorAt(x,y); //userID);
- glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a);
+ if (col) glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a); + else glColor4ub((unsigned char)255, (unsigned char)255, (unsigned char)255, (unsigned char)255);
glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
}
glEnd();
}
}
-
+
ofPopMatrix();
camera.end();
@@ -207,13 +212,15 @@ void viewport::draw(int mode,int fade,float decimate, float feat, float xr, floa ofTranslate(ox,oy);
rb2.draw(0,0);
-
+
if (dologo) {
ofEnableAlphaBlending();
logo.draw(0,0,ofGetWidth(),ofGetHeight());
ofDisableAlphaBlending();
}
- ofPopMatrix();
+ ofPopMatrix(); + + glDisable(GL_BLEND);
}
@@ -231,7 +238,7 @@ void viewport::mousePressedEvent(int xs,int ys,float sc,float fs) { yshift=ys;
scale=sc;
fscale=fs;
-
+
}
void viewport::setcam(map<string,float>&settings){
@@ -245,7 +252,7 @@ void viewport::setcam(map<string,float>&settings){ vars["dolly"].set('o','l',settings["dolly"],10,1.0,1.0);
}
-
+
double viewport::getSetting(const string& setting){
|
