summaryrefslogtreecommitdiff
path: root/src
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
parent084c8a9b85b853fa630d5a102cd102b45d543abf (diff)
displaying with overlays and distortion
Diffstat (limited to 'src')
-rw-r--r--src/keyVar.cpp2
-rw-r--r--src/testApp.cpp153
-rw-r--r--src/testApp.h3
-rw-r--r--src/viewpoint.cpp22
-rw-r--r--src/viewpoint.h7
5 files changed, 76 insertions, 111 deletions
diff --git a/src/keyVar.cpp b/src/keyVar.cpp
index ea8b9ff..26e0455 100644
--- a/src/keyVar.cpp
+++ b/src/keyVar.cpp
@@ -5,7 +5,7 @@
*/
#include "keyVar.h"
-#define DEBUG 0
+#define DEBUG 1
void keyVar::set(char _keyInc,char _keyDec,float _val,float _speed,float _accel,float _accelTime){
keyInc=_keyInc;
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);
}
//--------------------------------------------------------------
diff --git a/src/testApp.h b/src/testApp.h
index c8adb7f..69cfa4e 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -22,10 +22,11 @@ have to track how many frames each key has been pressed for
#define CALIBRATE 1
#define DISPLAY 2
+#define NOTHING 3
#include "ofMain.h"
#include "ofx3DModelLoader.h"
-
+#include "mapUtils.h"
#include "viewpoint.h"
class testApp : public ofBaseApp{
diff --git a/src/viewpoint.cpp b/src/viewpoint.cpp
index 249084f..64a2b99 100644
--- a/src/viewpoint.cpp
+++ b/src/viewpoint.cpp
@@ -1,4 +1,5 @@
#include "viewpoint.h"
+#define DEBUG 1
void viewpoint::setup(float w, float h, float x, float y) {
window=ofRectangle(w,h,x,y);
@@ -24,7 +25,7 @@ void viewpoint::setup(float w, float h, float x, float y) {
vars[4].set('u','n',0.0,1.0,3.0,3.0);
vars[5].set('j','h',0.0,1.0,3.0,3.0);
vars[6].set('o','l',0.0,0.2,3.0,3.0);
- vars[7].set('q','a',0,0.1,2.0,3.0);
+ vars[7].set('q','a',0,0.0001,2.0,3.0);
}
//--------------------------------------------------------------
void viewpoint::begin(){
@@ -44,8 +45,9 @@ void viewpoint::end(){
renderFBO.end();
camera.end();
- glPushMatrix();
+ ofPushMatrix();
bindTexture(renderFBO);
+
//draw a grid
//glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
ofNoFill();
@@ -59,28 +61,34 @@ void viewpoint::end(){
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);
+ p0=distort(ofPoint(j,i-(2.0f/gridY)),vars[7].getVal());
+ p1=distort(ofPoint(j,i),vars[7].getVal());
glTexCoord2f((j+1)*0.5,((i-(2.0f/gridY))+1)*0.5);
- glVertex3f(p0.x*xStep,p0.y*yStep,0);
+ 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);
+ glVertex3f(p1.x*xStep,p1.y*yStep,-0.1);
}
+
glEnd();
+ //
}
ofFill();
- glPopMatrix();
+
unbindTexture(renderFBO);
+ ofPopMatrix();
+
}
//--------------------------------------------------------------
void viewpoint::keyPressed(int key){
for (int i=0;i<8;i++) vars[i].keyPressed(key);
+ if (DEBUG) printf("fov: %f distort: %f\n",vars[0].getVal(),vars[7].getVal());
}
//--------------------------------------------------------------
void viewpoint::keyReleased(int key){
diff --git a/src/viewpoint.h b/src/viewpoint.h
index c1a0985..1a46081 100644
--- a/src/viewpoint.h
+++ b/src/viewpoint.h
@@ -8,7 +8,6 @@
*/
#include "ofMain.h"
-
#include "mapUtils.h"
#include "keyVar.h"
@@ -22,12 +21,14 @@ class viewpoint {
void keyPressed(int key);
void keyReleased(int key);
+ ofFbo renderFBO;
+
+ float distortFactor;
+
private:
ofRectangle window;
- float distortFactor;
- ofFbo renderFBO;
double fov,aspect,near,far;