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/