From Bob Kuehne, "this submission extends the osgViewer::RecordCameraPathHandler to have an optionally-enabled auto-incrementing filename. default behavior is still the same, but there's one new method to enable autoincrementing filenames."
From Robert Osfield, modified the above so that the number increments come after the filename rather than before.
This commit is contained in:
@@ -236,6 +236,8 @@ public:
|
||||
void setKeyEventTogglePlayback(int key) { _keyEventTogglePlayback = key; }
|
||||
int getKeyEventTogglePlayback() const { return _keyEventTogglePlayback; }
|
||||
|
||||
void setAutoIncrementFilename( bool autoinc = true ) { _autoinc = autoinc?0:-1; }
|
||||
|
||||
virtual void getUsage(osg::ApplicationUsage &usage) const;
|
||||
|
||||
bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa);
|
||||
@@ -243,6 +245,7 @@ public:
|
||||
protected:
|
||||
|
||||
std::string _filename;
|
||||
int _autoinc;
|
||||
std::ofstream _fout;
|
||||
|
||||
int _keyEventToggleRecord;
|
||||
|
||||
@@ -15,9 +15,12 @@
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <osgDB/FileNameUtils>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
@@ -368,6 +371,7 @@ bool ThreadingHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIAction
|
||||
|
||||
RecordCameraPathHandler::RecordCameraPathHandler(const std::string& filename):
|
||||
_filename(filename),
|
||||
_autoinc( -1 ),
|
||||
_keyEventToggleRecord('z'),
|
||||
_keyEventTogglePlayback('Z'),
|
||||
_currentlyRecording(false),
|
||||
@@ -448,8 +452,17 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
|
||||
|
||||
if (!_filename.empty())
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Recording camera path to file "<<_filename<<std::endl;
|
||||
_fout.open(_filename.c_str());
|
||||
std::stringstream ss;
|
||||
ss << osgDB::getNameLessExtension(_filename);
|
||||
if ( _autoinc != -1 )
|
||||
{
|
||||
ss << "_"<<std::setfill( '0' ) << std::setw( 2 ) << _autoinc;
|
||||
_autoinc++;
|
||||
}
|
||||
ss << "."<<osgDB::getFileExtension(_filename);
|
||||
|
||||
osg::notify(osg::NOTICE) << "Recording camera path to file " << ss.str() << std::endl;
|
||||
_fout.open( ss.str().c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user