#include #include #include #include #include #include #include "UpdateProperty.h" #include "CameraProperty.h" #include "CameraPathProperty.h" #include "EventProperty.h" #include "CaptureSettings.h" #include struct ScreenShot : public osg::Camera::DrawCallback { ScreenShot(GLenum pixelFormat, bool flip): _pixelFormat(pixelFormat), _flip(flip) {} virtual void operator () (osg::RenderInfo& renderInfo) const { if (!_frameCapture) { OSG_NOTICE<<"No FrameCamera assigned"<getFrameStamp()->getFrameNumber(); CameraNumMap::const_iterator itr = _cameraNumMap.find(renderInfo.getCurrentCamera()); std::string outputFileName = (itr!=_cameraNumMap.end()) ? _frameCapture->getOutputFileName(itr->second, frameNumber) : _frameCapture->getOutputFileName(frameNumber); OSG_NOTICE<<"outputFileName="<getViewport() : 0; if (viewport) { OSG_NOTICE<<"Doing read of ="<x()<<", "<y()<<", "<width()<<", "<height()<<" with pixelFormat=0x"<getDrawBuffer()); osg::ref_ptr image = new osg::Image; image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(), _pixelFormat, GL_UNSIGNED_BYTE, 1); if (_flip) image->flipVertical(); osgDB::writeImageFile(*image, outputFileName); } } typedef std::map CameraNumMap; GLenum _pixelFormat; bool _flip; osg::ref_ptr _frameCapture; CameraNumMap _cameraNumMap; }; int main( int argc, char **argv ) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of 3D textures."); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options]"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); arguments.getApplicationUsage()->addCommandLineOption("-i ","Input scene (or presentation) filename."); arguments.getApplicationUsage()->addCommandLineOption("-o ","Base output filename of the images, recommended to use something like Images/image.png"); arguments.getApplicationUsage()->addCommandLineOption("--cs ","Load pre-generated configuration file for run."); arguments.getApplicationUsage()->addCommandLineOption("--ouput-cs ","Output configuration file with settings provided on commandline."); arguments.getApplicationUsage()->addCommandLineOption("-p ","Use specificied camera path file to control camera position."); arguments.getApplicationUsage()->addCommandLineOption("--offscreen","Use an pbuffer to render the images offscreen."); arguments.getApplicationUsage()->addCommandLineOption("--screen","Use an window to render the images."); arguments.getApplicationUsage()->addCommandLineOption("--width ","Window/output image width."); arguments.getApplicationUsage()->addCommandLineOption("--height ","Window/output image height."); arguments.getApplicationUsage()->addCommandLineOption("--screen-distance ","Set the distance of the viewer from the physical screen."); arguments.getApplicationUsage()->addCommandLineOption("--screen-width ","Set the width of the physical screen."); arguments.getApplicationUsage()->addCommandLineOption("--screen-height ","Set the height of the physical screen."); arguments.getApplicationUsage()->addCommandLineOption("--ms ","Number of multi-samples to use when rendering, an enable a single sample buffer."); arguments.getApplicationUsage()->addCommandLineOption("--samples ","Number of multi-samples to use when rendering."); arguments.getApplicationUsage()->addCommandLineOption("--sampleBuffers ","Number of sample buffers to use when rendering."); arguments.getApplicationUsage()->addCommandLineOption("-f ","Number of frames per second in simulation time."); arguments.getApplicationUsage()->addCommandLineOption("-n ","Number of frames to render/images to create."); arguments.getApplicationUsage()->addCommandLineOption("-d