summaryrefslogtreecommitdiff
path: root/TRRSS_01_rec/src/testApp.cpp
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-04-28 00:49:39 +0100
committerComment <tim@gray.(none)>2013-04-28 00:49:39 +0100
commit29a366df4f1492a5974db87a215f1a310fc853a2 (patch)
treec7e3ed0f0d5827c6a2d9072220a914b40134093b /TRRSS_01_rec/src/testApp.cpp
initial
Diffstat (limited to 'TRRSS_01_rec/src/testApp.cpp')
-rwxr-xr-xTRRSS_01_rec/src/testApp.cpp164
1 files changed, 164 insertions, 0 deletions
diff --git a/TRRSS_01_rec/src/testApp.cpp b/TRRSS_01_rec/src/testApp.cpp
new file mode 100755
index 0000000..1c333bf
--- /dev/null
+++ b/TRRSS_01_rec/src/testApp.cpp
@@ -0,0 +1,164 @@
+#include "testApp.h"
+//texture binding with normalised coords
+void bindTexture(ofBaseHasTexture &t) {
+ ofTexture &tex = t.getTextureReference();
+ tex.bind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ ofTextureData texData = tex.getTextureData();
+ if(texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB) {
+ glScalef(tex.getWidth(), tex.getHeight(), 1.0f);
+ } else {
+ glScalef(tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f);
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+}
+void unbindTexture(ofBaseHasTexture &t) {
+ t.getTextureReference().unbind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+}
+void bindTex(ofTexture &tex) {
+ tex.bind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ ofTextureData texData = tex.getTextureData();
+ if(texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB) {
+ glScalef(tex.getWidth(), tex.getHeight(), 1.0f);
+ } else {
+ glScalef(tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f);
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+}
+void unbindTex(ofTexture &tex) {
+ tex.unbind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+}
+//--------------------------------------------------------------
+void testApp::setup(){
+ recordContext.setup();
+ recordDepth.setup(&recordContext);
+ recordImage.setup(&recordContext);
+ recordUser.setup(&recordContext);
+ recordUser.setUseCloudPoints(true);
+ recordContext.toggleRegisterViewport();
+
+ guiWin=new guiWindow();
+ ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW);
+ win->setWindowTitle("config");
+ win->addListener(guiWin);
+ guiWin->setup();
+}
+
+//--------------------------------------------------------------
+void testApp::update(){
+ recordContext.update();
+ recordDepth.update();
+ recordImage.update();
+ recordUser.update();
+}
+
+//--------------------------------------------------------------
+void testApp::draw(){
+ cam.begin();
+ //bind texture recordImage
+ //get point data from recordDepth
+ //draw textured polys and allow manipulation
+ ofPushMatrix();
+ ofTranslate(320,240,-1000);
+ //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->distMin<pos1.z&&pos1.z<guiWin->distMax)&&
+ (guiWin->distMin<pos2.z&&pos2.z<guiWin->distMax)&&
+ (guiWin->distMin<pos3.z&&pos3.z<guiWin->distMax)&&
+ (guiWin->distMin<pos4.z&&pos4.z<guiWin->distMax)) {
+
+ 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();
+
+ unbindTex(recordImage.getTexture());
+
+ //recordImage.draw(0, 0, ofGetWidth(),ofGetHeight());
+
+ cam.end();
+
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void testApp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void testApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void testApp::dragEvent(ofDragInfo dragInfo){
+
+}