From 7c1399cfdd82eb9a387e8fb4aad15b1e17da7f5d Mon Sep 17 00:00:00 2001 From: Comment Date: Sun, 28 Apr 2013 22:51:28 +0100 Subject: nearly ready for rec --- TRRSS_01_rec/src/testApp.cpp | 87 +++++++++++++++++++++++++++++++------------- TRRSS_01_rec/src/testApp.h | 4 ++ 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/TRRSS_01_rec/src/testApp.cpp b/TRRSS_01_rec/src/testApp.cpp index 1c333bf..c43fd2d 100755 --- a/TRRSS_01_rec/src/testApp.cpp +++ b/TRRSS_01_rec/src/testApp.cpp @@ -73,39 +73,76 @@ void testApp::update(){ //-------------------------------------------------------------- void testApp::draw(){ - cam.begin(); + //cam.begin(); //bind texture recordImage //get point data from recordDepth //draw textured polys and allow manipulation + float cloudWidth=1024.0f; + float cloudHeight=768.0f; + ofPushMatrix(); - ofTranslate(320,240,-1000); + ofTranslate((1024/2)-(640/2),(768/2)-(480/2),-500); //ofRotate(0,0,1,180); bindTex(recordImage.getTexture()); int step = 1; - for(int y = step; y < 480; y += step) { - glBegin(GL_QUADS); - for(int x = step; x < 640; x += step) { - ofPoint pos1 = recordUser.getWorldCoordinateAt(x-step, y-step, 0); //userID); - ofPoint pos2 = recordUser.getWorldCoordinateAt(x, y-step, 0); //userID); - ofPoint pos3 = recordUser.getWorldCoordinateAt(x-step, y, 0); //userID); - ofPoint pos4 = recordUser.getWorldCoordinateAt(x, y, 0); //userID); - - if ((guiWin->distMindistMax)&& - (guiWin->distMindistMax)&& - (guiWin->distMindistMax)&& - (guiWin->distMindistMax)) { - - glTexCoord2f(((float)x-step)/640.0f,((float)y-step)/480.0f); - glVertex3f(pos1.x, -pos1.y,pos1.z); - glTexCoord2f(((float)x)/640.0f,((float)y-step)/480.0f); - glVertex3f(pos2.x, -pos2.y,pos2.z); - glTexCoord2f(((float)x)/640.0f,((float)y)/480.0f); - glVertex3f(pos4.x, -pos4.y,pos4.z); - glTexCoord2f(((float)x-step)/640.0f,((float)y)/480.0f); - glVertex3f(pos3.x, -pos3.y,pos3.z); + + if (guiWin->drawPoints) { + // http://stackoverflow.com/questions/1513811/getting-smooth-big-points-in-opengl + glEnable( GL_POINT_SMOOTH ); + glEnable( GL_BLEND ); + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glPointSize( 6.0 ); + + glBegin(GL_POINTS); + glColor3f( 1.0f, 1.0f, 1.0f ); + + for(int y = step; y < 480; y += step) { + + for(int x = step; x < 640; x += step) { + ofPoint pos1 = recordUser.getWorldCoordinateAt(x-step, y-step, 0); //userID); + ofPoint pos2 = recordUser.getWorldCoordinateAt(x, y-step, 0); //userID); + ofPoint pos3 = recordUser.getWorldCoordinateAt(x-step, y, 0); //userID); + ofPoint pos4 = recordUser.getWorldCoordinateAt(x, y, 0); //userID); + + if ((guiWin->distMindistMax)&& + (guiWin->distMindistMax)&& + (guiWin->distMindistMax)&& + (guiWin->distMindistMax)) { + + glVertex3f(pos4.x, pos4.y,pos4.z); + } } + glEnd(); } - glEnd(); + } + else { + for(int y = step; y < 480; y += step) { + glBegin(GL_QUADS); + for(int x = step; x < 640; x += step) { + ofPoint pos1 = recordUser.getWorldCoordinateAt(x-step, y-step, 0); //userID); + ofPoint pos2 = recordUser.getWorldCoordinateAt(x, y-step, 0); //userID); + ofPoint pos3 = recordUser.getWorldCoordinateAt(x-step, y, 0); //userID); + ofPoint pos4 = recordUser.getWorldCoordinateAt(x, y, 0); //userID); + + if ((guiWin->distMindistMax)&& + (guiWin->distMindistMax)&& + (guiWin->distMindistMax)&& + (guiWin->distMindistMax)) { + + glTexCoord2f(((float)x-step)/640.0f,((float)y-step)/480.0f); + glVertex3f(pos1.x, pos1.y,pos1.z); + glTexCoord2f(((float)x)/640.0f,((float)y-step)/480.0f); + glVertex3f(pos2.x, pos2.y,pos2.z); + glTexCoord2f(((float)x)/640.0f,((float)y)/480.0f); + glVertex3f(pos4.x, pos4.y,pos4.z); + glTexCoord2f(((float)x-step)/640.0f,((float)y)/480.0f); + glVertex3f(pos3.x, pos3.y,pos3.z); + } + } + glEnd(); + } + + } ofPopMatrix(); @@ -113,7 +150,7 @@ void testApp::draw(){ //recordImage.draw(0, 0, ofGetWidth(),ofGetHeight()); - cam.end(); + //cam.end(); } diff --git a/TRRSS_01_rec/src/testApp.h b/TRRSS_01_rec/src/testApp.h index 1da9c6e..00316b0 100755 --- a/TRRSS_01_rec/src/testApp.h +++ b/TRRSS_01_rec/src/testApp.h @@ -56,6 +56,8 @@ class guiWindow: public ofxFensterListener{ ofxParameter drawPoints; ofxFloatSlider pSize; ofxParameter pointSize; + ofxToggle iOut; + ofxParameter insideOut; void setup(){ @@ -68,6 +70,8 @@ class guiWindow: public ofxFensterListener{ gui.add(dPoints.setup("draw points",drawPoints)); pointSize=2.0; gui.add(pSize.setup("point size",pointSize,1.0,20.0,255)); + insideOut=false; + gui.add(iOut.setup("inside out",drawPoints)); } void draw() { gui.draw(); } -- cgit v1.2.3