ofFbo + ofEasyCam flipping issues?

Hello !

I’m making a 3d wayfinder app and as a part of that I’m writing part of the scene to an ofFbo in order to do some effects and also use ofxPixelHitTest to do some cheap raycasting for interactivity. Everything lines up perfectly using standard ofTranslate / ofRotate but when I add in the camera the ofFbo gets flipped somehow.

Below is a part of my drawing code :

  
  
void testApp::draw()   
{  
               ofBackground( 0 , 0 , 0 ) ;   
		if ( pixelHub->beginFbo() == true )   
		{  
			cam.begin() ;   
				ofPushMatrix() ;  
					ofRotateX ( -90.0f ) ;  
					//Center the map in the screen  
					ofTranslate ( -mapScale/2 , -mapScale/2 , 0 ) ;   
					//Move by the pan amount  
					ofTranslate ( cam.panTranslation.x , cam.panTranslation.y, cam.cameraHeight ) ;   
					//Give a little bit of a perspective on buildings  
					ofRotateY ( 5.0 ) ;   
						for ( int i = 0 ; i < buildings.size() ; i++ )   
						buildings[i]->drawInputMap( 0 , 0 ) ;  
  
				ofPopMatrix() ;   
			cam.end() ;   
			pixelHub->endFbo() ;  
		}  
  
		cam.begin();  
			ofPushMatrix() ;  
				//Same transformations as above   
				ofRotateX ( -90.0f ) ;   
				ofTranslate ( -mapScale/2 , -mapScale/2 , 0 ) ;   
				ofTranslate ( cam.panTranslation.x , cam.panTranslation.y, cam.cameraHeight ) ;  
				ofRotateY ( 5.0 ) ;   
		  
				ofBackground( 0 , 0 , 0 ) ;   
	  
				ofSetColor ( 255 , 255 , 255 ) ;   
				ofFill()  ;   
				//Draw PixelHub  
			  
				ofSetColor ( 50 , 50 , 50 ) ;   
				//Background Square  
				ofEnableAlphaBlending() ;   
	  
				for ( int i = 0 ; i < buildings.size() ; i++ )   
				{  
				    //buildings[i]->draw() ;   
					buildings[i]->drawInputMap( 0 , 0 ) ;   
				}  
			ofPopMatrix() ;  
		 cam.end() ;   
}  
  

And here are some images of the overlapping issue as well the smaller image in the top right corner is the ofFBO the main window is not an ofFbo. The last two images show an overlay of the ofFBO on top of the main window :
http://imgur.com/a/uvsO7

I was able to adjust for the positioning using some hacky ofTranslate / and ofScale ( 0.0f , -1.0f , 0,0f ), but I wasn’t able to fix the misalignment caused by rotating. I came across this post ( http://forum.openframeworks.cc/t/ofviewport-flipping-in-offbo-bug—openframeworksmaster/5443/0 ) but when I tried manually setting invertY to true or false I saw no change. Any help or insight would be fantastic.

I’m using Visual Studio on Windows x64 and the release version of 007 for vs2010 from http://www.openframeworks.cc/download/

Actually Nick Hardeman had a similar issue and his fix worked for me :

http://forum.openframeworks.cc/t/fbo-3d-object-with-moving-camera/5535/0

w00t community

i think this is fixed in github develop already

Doesn’t seem to be fixed in develop. Just tried the following and the FBO flips it…

testApp.h

  
  
    ofFbo fbo;  
    ofEasyCam cam;  
  

testApp.cpp

  
  
//--------------------------------------------------------------  
void testApp::setup(){  
  
    cam.setNearClip(1e-4);  
    cam.setFarClip(100);  
    cam.setDistance(10);  
    fbo.allocate(ofGetWidth(), ofGetHeight());  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
    fbo.begin(false);  
    ofClear(0, 0, 0);  
    cam.begin();  
    ofCircle(4, 4, 0, 0.2);  
    cam.end();  
    fbo.end();  
    fbo.draw(0, 0, ofGetWidth(), ofGetHeight());  
}  
  

yes we reverted the fix cause it was problematic with other cases, we still need to look at it.

@benMcChesney,
this is kind of an annoyng issue.
The easy work around is to add the following line after cam.begin();
ofScale (1,-1,1);

I’d been working on a new implementation of the easyCam as it happens to have a lot of weird behaviors. As soon as I have it completely working I’ll push it to github.

@arturo, do you remember which were the other problematic cases, cause I’d like to address those.

Is there a Github issue for this? I just ran into the same issue (after about 45 minutes of trying to debug my code to find the issue).

mike