diff options
Diffstat (limited to 'src/testApp.cpp')
| -rw-r--r-- | src/testApp.cpp | 129 |
1 files changed, 11 insertions, 118 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp index 439f668..581687f 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -1,4 +1,5 @@ #include "testApp.h" + GLfloat lightOnePosition[] = {40.0, 40, 100.0, 0.0}; GLfloat lightOneColor[] = {0.99, 0.99, 0.99, 0.5}; @@ -46,30 +47,14 @@ void testApp::setup(){ texture.loadMovie("gradblend01.mov"); texture.play(); - distortFactor=0.0; - - renderFBO.allocate(ofGetWidth(),ofGetHeight(),GL_RGB); - mode=CALIBRATE; - //approx 200 x 108 x 60 - //275:492 - //vfov = sin t/2 = 30/200 = 0.15 - fov=17.25; - aspect=1.79; - near=0; - far=3000; + views=new viewpoint[1]; - cx=0; - cy=0; - cz=-100; - - crx=cry=0; - - ex=0; - ey=0; - ez=0; + //todo: read this from xml + views[0].setup(ofGetWidth(),ofGetHeight(),0,0); + activeView=0; } @@ -93,15 +78,9 @@ void testApp::draw(){ //glEnable(GL_LIGHTING); //ofRectangle vp=ofRectangle(0,0,ofGetWidth(),ofGetHeight()); //camera.setFov(fov); - camera.begin(); - camera.setPosition(cx, cy, cz); - ofRotateY(cry); - ofRotateX(crx); - camera.setFov(fov); - ofVec3f lookAt; - lookAt.set(ex,ey,ez); - camera.lookAt(lookAt); - + views[0].begin(); + + glPushMatrix(); /* @@ -140,8 +119,7 @@ void testApp::draw(){ ofSetColor(255, 255, 255, 255); ofFill(); - //renderFBO.begin(); //render to FOB - ofClear(0,0,0); + switch(mode) { case CALIBRATE: @@ -190,7 +168,7 @@ void testApp::draw(){ break; } glPopMatrix(); - camera.end(); + views[0].end(); @@ -270,70 +248,15 @@ void testApp::draw(){ //-------------------------------------------------------------- void testApp::keyPressed(int key){ + views[activeView].keyPressed(key); switch (key) { - case 'q': - distortFactor-=0.001f; - break; - case 'a': - distortFactor+=0.001f; - break; - case 'w': - fov*=0.99; - break; - case 's': - fov*=1.01; - break; case '1': mode=CALIBRATE; break; case '2': mode=DISPLAY; break; - - //nav stuff - case 'g': - ex+=0.1; - break; - case 'd': - ex-=0.1; - break; - case 'r': - ey+=0.1; - break; - case 'v': - ey-=0.1; - break; - case 'c': - ez+=0.1; - break; - case 't': - ez-=0.1; - break; - - case 'h': - crx+1; - break; - case 'j': - cry-=1; - break; - case 'u': - //rotate camera in Y - break; - case 'n': - //rotate camera in Y - break; - - case 'o': - //dolly IN - break; - case 'l': - //dolly OUT - break; - - - } - printf("fov: %f, mode: %d, distortion: %f\n",fov,mode,distortFactor); } @@ -376,34 +299,4 @@ void testApp::gotMessage(ofMessage msg){ void testApp::dragEvent(ofDragInfo dragInfo){ } -void testApp::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 testApp::unbindTexture(ofBaseHasTexture &t) { - t.getTextureReference().unbind(); - - glMatrixMode(GL_TEXTURE); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); -} -ofPoint testApp::distort(ofPoint pt,float d){ - //normalised coords -1..1, d - float r=pow(pow(pow(pt.x,2.0f)+pow(pt.y,2.0f),0.5f),1.0f+d); - float a=atan2f(pt.x,pt.y); - return ofPoint(r*sin(a),r*cos(a)); -}; |
