summaryrefslogtreecommitdiff
path: root/src/testApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2011-12-26 17:02:09 +0000
committerTim Redfern <tim@eclectronics.org>2011-12-26 17:02:09 +0000
commit86c462a8d5b9517738161eede77ccc6703af779b (patch)
tree9c68ec3805ffe11713041fa8c7c00718f1f79030 /src/testApp.cpp
parent084c8a9b85b853fa630d5a102cd102b45d543abf (diff)
displaying with overlays and distortion
Diffstat (limited to 'src/testApp.cpp')
-rw-r--r--src/testApp.cpp153
1 files changed, 54 insertions, 99 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 581687f..8ff0865 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -30,8 +30,8 @@ void testApp::setup(){
//load the bottle model - the 3ds and the texture file need to be in the same folder
bottle.loadModel("bottle.3DS", 1);
board.loadModel("box.3DS", 1);
- //bottle.setRotation(0, 180, 1, 0, 0);
- //board.setRotation(0, 180, 1, 0, 0);
+ bottle.setRotation(0, 180, 1, 0, 0);
+ board.setRotation(0, 180, 1, 0, 0);
//you can create as many rotations as you want
//choose which axis you want it to effect
@@ -47,7 +47,7 @@ void testApp::setup(){
texture.loadMovie("gradblend01.mov");
texture.play();
- mode=CALIBRATE;
+ mode=NOTHING;
views=new viewpoint[1];
@@ -78,49 +78,13 @@ void testApp::draw(){
//glEnable(GL_LIGHTING);
//ofRectangle vp=ofRectangle(0,0,ofGetWidth(),ofGetHeight());
//camera.setFov(fov);
- views[0].begin();
-
-
- glPushMatrix();
-
- /*
- //fake back wall
- ofSetColor(220, 20, 20);
- glBegin(GL_QUADS);
- glVertex3f(0.0, ofGetHeight(), -600);
- glVertex3f(ofGetWidth(), ofGetHeight(), -600);
- glVertex3f(ofGetWidth(), 0, -600);
- glVertex3f(0, 0, -600);
- glEnd();
-
- //fake wall
- ofSetColor(50, 150, 50);
- glBegin(GL_QUADS);
- glVertex3f(0.0, ofGetHeight(), 0);
- glVertex3f(ofGetWidth(), ofGetHeight(), 0);
- glVertex3f(ofGetWidth(), ofGetHeight(), -600);
- glVertex3f(0, ofGetHeight(), -600);
- glEnd();
- */
- //draw in middle of the screen
- //glPushMatrix();
- //glTranslatef(ofGetWidth()/2,ofGetHeight()/2,0);
-/*
- //lets tumble the world with the mouse
- glPushMatrix();
+ views[0].begin();
- //tumble according to mouse
- glRotatef(-mouseY,1,0,0);
- glRotatef(mouseX,0,1,0);
- glTranslatef(-ofGetWidth()/2,-ofGetHeight()/2,0);
-*/
ofSetColor(255, 255, 255, 255);
ofFill();
-
-
switch(mode) {
case CALIBRATE:
@@ -143,7 +107,7 @@ void testApp::draw(){
}
}
- //glEnd();
+ glEnd();
/*
@@ -155,7 +119,7 @@ void testApp::draw(){
glEnd();
*/
glPopMatrix();
- glFrontFace(GL_CCW);
+ //glFrontFace(GL_CCW);
bottle.draw();
break;
@@ -167,82 +131,70 @@ void testApp::draw(){
unbindTexture(texture);
break;
}
- glPopMatrix();
+ //glPopMatrix();
views[0].end();
- //texture.getTextureReference().bind();
-
-
-/*
- glBegin(GL_QUAD_STRIP);
- glTexCoord2f (0.0, 0.0);
- glVertex3f(ofGetWidth()/4,ofGetHeight()/4,0);
- glTexCoord2f (0.0, 1.0);
- glVertex3f(ofGetWidth()/4,(3*ofGetHeight())/4,0);
- glTexCoord2f (1.0, 0.0);
- glVertex3f((3*ofGetWidth())/4,ofGetHeight()/4,0);
- glTexCoord2f (1.0, 1.0);
- glVertex3f((3*ofGetWidth())/4,(3*ofGetHeight())/4,0);
- glEnd();
- */
+ /*
- //texture.getTextureReference().unbind();
+ glPopMatrix();
+ views[0].renderFBO.draw(0,0);
-/*
- renderFBO.end();
+ glPushMatrix();
- //glPopMatrix();
+ */
- //renderFBO.draw(0,0);
+ if (mode!=NOTHING){
+
+
+ bindTexture(views[0].renderFBO);
+ glPushMatrix();
+ //draw a grid
+ //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
+ ofNoFill();
+
+ ofSetLineWidth(1.0);
+ //ofSetColor(I_fade1,I_fade1,I_fade1);
+ int gridX=50;
+ int gridY=50;
+ int xStep=ofGetWidth()/2;
+ int yStep=ofGetHeight()/2;
+ ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+
+ for (float i = -1; i < 1.001; i+=(2.0f/gridY)){
+ glBegin(GL_QUAD_STRIP);
+ ofPoint p0;
+ ofPoint p1;
+ for (float j = -1; j < 1.001; j+=(2.0f/gridX)){
+ p0=distort(ofPoint(j,i-(2.0f/gridY)),views[0].distortFactor);
+ p1=distort(ofPoint(j,i),views[0].distortFactor);
+ glTexCoord2f((j+1)*0.5,((i-(2.0f/gridY))+1)*0.5);
+ glVertex3f(p0.x*xStep,p0.y*yStep,-0.1);
+ glTexCoord2f((j+1)*0.5,(i+1)*0.5);
+ glVertex3f(p1.x*xStep,p1.y*yStep,-0.1);
+ }
+ glEnd();
+ }
- glPushMatrix();
+ ofFill();
- //renderFBO.getTextureReference().bind();
- bindTexture(renderFBO);
- //draw a grid
- //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
- ofNoFill();
-
- ofSetLineWidth(1.0);
- //ofSetColor(I_fade1,I_fade1,I_fade1);
- int gridX=50;
- int gridY=50;
- int xStep=ofGetWidth()/2;
- int yStep=ofGetHeight()/2;
- ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
-
- for (float i = -1; i < 1.001; i+=(2.0f/gridY)){
- glBegin(GL_QUAD_STRIP);
- ofPoint p0;
- ofPoint p1;
- for (float j = -1; j < 1.001; j+=(2.0f/gridX)){
- p0=distort(ofPoint(j,i-(2.0f/gridY)),distortFactor);
- p1=distort(ofPoint(j,i),distortFactor);
- glTexCoord2f((j+1)*0.5,((i-(2.0f/gridY))+1)*0.5);
- glVertex3f(p0.x*xStep,p0.y*yStep,0);
- glTexCoord2f((j+1)*0.5,(i+1)*0.5);
- glVertex3f(p1.x*xStep,p1.y*yStep,0);
- }
- glEnd();
- }
- ofFill();
- glPopMatrix();
+ //renderFBO.getTextureReference().unbind();
+ unbindTexture(views[0].renderFBO);
+ glPopMatrix();
+ }
- //renderFBO.getTextureReference().unbind();
- unbindTexture(renderFBO);
- ofSetHexColor(0x000000);
+ ofSetHexColor(0xFFFFFF);
ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate(), 2), 10, 15);
// add polygons here
//glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
- */
+
}
@@ -256,13 +208,16 @@ void testApp::keyPressed(int key){
case '2':
mode=DISPLAY;
break;
+ case '3':
+ mode=NOTHING;
+ break;
}
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
-
+ views[activeView].keyReleased(key);
}
//--------------------------------------------------------------