From Wang Rui, "A modified version is attached. The blank while generating is in fact

used to avoid dual update traversals of the scene, which is not
allowed in my application (but I forgot the reason ;-) Now the blank
problem will disappear.

Inactive mode is also available, using the --inactive mode and
--camera-eye and --camera-hpr to set camera position:

./osgposter --output-poster --poster output.bmp --tilesize 800 600
--finalsize 8000 6000 cow.osg --inactive --camera-eye 0 0 20
"
This commit is contained in:
Robert Osfield 2010-12-14 08:53:20 +00:00
parent 3145837629
commit c0937c1614

View File

@ -255,7 +255,7 @@ int main( int argc, char** argv )
int posterWidth = 640*2, posterHeight = 480*2;
std::string posterName = "poster.bmp", extName = "bmp";
osg::Vec4 bgColor(0.2f, 0.2f, 0.6f, 1.0f);
osg::Camera::RenderTargetImplementation renderImplementation = osg::Camera::FRAME_BUFFER;
osg::Camera::RenderTargetImplementation renderImplementation = osg::Camera::FRAME_BUFFER_OBJECT;
while ( arguments.read("--inactive") ) { activeMode = false; }
while ( arguments.read("--color", bgColor.r(), bgColor.g(), bgColor.b()) ) {}
@ -330,16 +330,36 @@ int main( int argc, char** argv )
printer->setOutputPosterName( posterName );
}
// Create root and start the viewer
#if 0
// While recording sub-images of the poster, the scene will always be traversed twice, from its two
// parent node: root and camera. Sometimes this may not be so comfortable.
// To prevent this behaviour, we can use a switch node to enable one parent and disable the other.
// However, the solution also needs to be used with care, as the window will go blank while taking
// snapshots and recover later.
osg::ref_ptr<osg::Switch> root = new osg::Switch;
root->addChild( scene, true );
root->addChild( camera.get(), false );
#else
osg::ref_ptr<osg::Group> root = new osg::Group;
root->addChild( scene );
root->addChild( camera.get() );
#endif
osgViewer::Viewer viewer;
viewer.setUpViewInWindow( 100, 100, tileWidth, tileHeight );
viewer.setSceneData( root.get() );
viewer.getDatabasePager()->setDoPreCompile( false );
if ( renderImplementation==osg::Camera::FRAME_BUFFER )
{
// FRAME_BUFFER requires the window resolution equal or greater than the to-be-copied size
viewer.setUpViewInWindow( 100, 100, tileWidth, tileHeight );
}
else
{
// We want to see the console output, so just render in a window
viewer.setUpViewInWindow( 100, 100, 800, 600 );
}
if ( activeMode )
{
viewer.addEventHandler( new PrintPosterHandler(printer.get()) );