summaryrefslogtreecommitdiff
path: root/src/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/viewport.cpp')
-rwxr-xr-xsrc/viewport.cpp85
1 files changed, 70 insertions, 15 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 513b954..4f65a6d 100755
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -74,9 +74,13 @@ void viewport::setup(int _w,int _h,int _x,int _y,float _r,int _ox,int _oy) {
yshift=0;
scale=1.0;
fscale=1.0;
+ xrot=yrot=zrot=0.0f;
+
+ logo.loadImage("logo.png");
}
-void viewport::draw(int fade,int decimate){
+void viewport::draw(int mode,int fade,float decimate, float feat, float xr, float yr, float zr, int range, bool dologo){
+
/*
ofNode c=ofNode();
ofNode t=ofNode();
@@ -84,7 +88,7 @@ void viewport::draw(int fade,int decimate){
t.setPosition();
//make target controls relative to rotation
c.rotate(vars["lng"].getVal(), ofVec3f(0, 1, 0));
-*/
+
target.setPosition(vars["targX"].getVal(),vars["targY"].getVal(),vars["targZ"].getVal());
//camera.orbit(vars[5].getVal(), vars[4].getVal(), vars[7].getVal(), target);
camera.setFov(vars["fov"].getVal());
@@ -95,6 +99,7 @@ void viewport::draw(int fade,int decimate){
p += target.getPosition();
camera.setPosition(p);
camera.lookAt(target,ofVec3f(0,1,0).rotate(vars["roll"].getVal(),ofVec3f(0,0,1)).rotate(vars["lng"].readVal(),ofVec3f(0,1,0)));
+ */
rb1.begin();
@@ -122,25 +127,69 @@ void viewport::draw(int fade,int decimate){
camera.begin();
+ ofPushMatrix();
- glBegin(GL_POINTS);
-
- float step = 255.0f/(float)decimate;
+ ofTranslate(0,0,-1500);
+ xrot+=xr;
+ yrot+=yr;
+ zrot+=zr;
+ ofRotateY(yrot);
+ ofRotateX(xrot);
+ ofRotateZ(zrot);
+ 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);
+
+ 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);
+ glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
+ }
+ }
- 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 ) 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);
- glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
- }
+ glEnd();
+ glDisable(GL_PROGRAM_POINT_SIZE);
+ }
+ if (mode==LINES) {
+ glEnable(GL_LINE_SMOOTH);
+ glLineWidth(feat);
+
+ for(float y = 0.0f; y < 480.0f; y += step) {
+ glBegin(GL_LINE_STRIP);
+ for(float x = 0.0f; x < 640.0f; x += 1.0f+(step*0.1)) {
+ ofVec3f pos = kinect->getWorldCoordinateAt(x, y);
+ if (pos.z == 0 || pos.z>range) {
+ glEnd();
+ glBegin(GL_LINE_STRIP);
+ 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);
+ glVertex3f(pos.x*scale, pos.y*scale, pos.z*scale);
+ }
+ glEnd();
+ }
}
-
- glEnd();
+ ofPopMatrix();
camera.end();
glColor3f(1.0f, 1.0f, 1.0f);
@@ -158,6 +207,12 @@ void viewport::draw(int fade,int decimate){
ofTranslate(ox,oy);
rb2.draw(0,0);
+
+ if (dologo) {
+ ofEnableAlphaBlending();
+ logo.draw(0,0,ofGetWidth(),ofGetHeight());
+ ofDisableAlphaBlending();
+ }
ofPopMatrix();
}