Tidied up CaptureSettings and added command line docs
This commit is contained in:
parent
b6d19d1052
commit
9363aa5a89
@ -2,16 +2,36 @@
|
||||
|
||||
using namespace gsc;
|
||||
|
||||
CaptureSettings::CaptureSettings()
|
||||
CaptureSettings::CaptureSettings():
|
||||
_stereoMode(OFF),
|
||||
_offscreen(false),
|
||||
_width(1024),
|
||||
_height(512),
|
||||
_samples(0),
|
||||
_sampleBuffers(0),
|
||||
_frameRate(60.0),
|
||||
_numberOfFrames(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
CaptureSettings::CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& copyop):
|
||||
osg::Object(cs, copyop),
|
||||
_inputFileName(cs._inputFileName),
|
||||
_outputFileName(cs._outputFileName),
|
||||
_outputDirectoryName(cs._outputDirectoryName),
|
||||
_outputBaseFileName(cs._outputBaseFileName),
|
||||
_outputExtension(cs._outputExtension),
|
||||
_stereoMode(cs._stereoMode),
|
||||
_offscreen(cs._offscreen),
|
||||
_width(cs._width),
|
||||
_height(cs._height),
|
||||
_samples(cs._samples),
|
||||
_sampleBuffers(cs._sampleBuffers),
|
||||
_frameRate(cs._frameRate),
|
||||
_numberOfFrames(cs._numberOfFrames),
|
||||
_eventHandlers(cs._eventHandlers),
|
||||
_properties(cs._properties)
|
||||
{
|
||||
_offscreen = false;
|
||||
_width = 1024;
|
||||
_height = 524;
|
||||
_samples = 0;
|
||||
_sampleBuffers = 0;
|
||||
_stereo = false;
|
||||
_frameRate = 60.0;
|
||||
_numberOfFrames = 0;
|
||||
}
|
||||
|
||||
void CaptureSettings::setOutputFileName(const std::string& filename)
|
||||
@ -125,6 +145,12 @@ REGISTER_OBJECT_WRAPPER( gsc_CaptureSettings,
|
||||
ADD_STRING_SERIALIZER( OutputFileName, "" );
|
||||
ADD_DOUBLE_SERIALIZER( FrameRate, 60.0 );
|
||||
|
||||
BEGIN_ENUM_SERIALIZER( StereoMode, OFF );
|
||||
ADD_ENUM_VALUE( OFF );
|
||||
ADD_ENUM_VALUE( HORIZONTAL_SPLIT );
|
||||
ADD_ENUM_VALUE( VERTICAL_SPLIT );
|
||||
END_ENUM_SERIALIZER(); // _renderTargetImplementation
|
||||
|
||||
ADD_BOOL_SERIALIZER( Offscreen, false );
|
||||
|
||||
ADD_UINT_SERIALIZER( Width, 1024 );
|
||||
@ -132,8 +158,6 @@ REGISTER_OBJECT_WRAPPER( gsc_CaptureSettings,
|
||||
ADD_UINT_SERIALIZER( Samples, 0 );
|
||||
ADD_UINT_SERIALIZER( SampleBuffers, 0 );
|
||||
|
||||
ADD_BOOL_SERIALIZER( Stereo, false );
|
||||
|
||||
ADD_UINT_SERIALIZER( NumberOfFrames, 0 );
|
||||
ADD_USER_SERIALIZER( EventHandlers );
|
||||
ADD_USER_SERIALIZER( Properties );
|
||||
|
@ -16,7 +16,7 @@ class CaptureSettings : public osg::Object
|
||||
{
|
||||
public:
|
||||
CaptureSettings();
|
||||
CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {}
|
||||
CaptureSettings(const CaptureSettings& cs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(gsc, CaptureSettings);
|
||||
|
||||
@ -29,6 +29,16 @@ public:
|
||||
std::string getOutputFileName(unsigned int frameNumber) const;
|
||||
std::string getOutputFileName(unsigned int cameraNumber, unsigned int frameNumber) const;
|
||||
|
||||
enum StereoMode
|
||||
{
|
||||
OFF,
|
||||
HORIZONTAL_SPLIT,
|
||||
VERTICAL_SPLIT
|
||||
};
|
||||
|
||||
void setStereoMode(StereoMode mode) { _stereoMode = mode; }
|
||||
StereoMode getStereoMode() const { return _stereoMode; }
|
||||
|
||||
void setOffscreen(bool o) { _offscreen = o; }
|
||||
bool getOffscreen() const { return _offscreen; }
|
||||
|
||||
@ -44,9 +54,6 @@ public:
|
||||
void setSampleBuffers(unsigned int s) { _sampleBuffers = s; }
|
||||
unsigned int getSampleBuffers() const { return _sampleBuffers; }
|
||||
|
||||
void setStereo(bool on) { _stereo = on; }
|
||||
bool getStereo() const { return _stereo; }
|
||||
|
||||
void setFrameRate(double fr) { _frameRate = fr; }
|
||||
double getFrameRate() const { return _frameRate; }
|
||||
|
||||
@ -91,6 +98,7 @@ protected:
|
||||
std::string _outputBaseFileName;
|
||||
std::string _outputExtension;
|
||||
|
||||
StereoMode _stereoMode;
|
||||
bool _offscreen;
|
||||
|
||||
unsigned int _width;
|
||||
@ -98,8 +106,6 @@ protected:
|
||||
unsigned int _samples;
|
||||
unsigned int _sampleBuffers;
|
||||
|
||||
bool _stereo;
|
||||
|
||||
double _frameRate;
|
||||
unsigned int _numberOfFrames;
|
||||
|
||||
|
@ -66,12 +66,28 @@ int main( int argc, char **argv )
|
||||
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of 3D textures.");
|
||||
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--center x y z","View center");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--eye x y z","Camera eye point");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--up x y z","Camera up vector");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-center x y z","Position to rotatate around");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-axis x y z","Axis to rotate around");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-speed v","Degrees per second");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-i <filename>","Input scene (or presentation) filename.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-o <filename>","Base ouput filename of the images, recommended to use something like Images/image.png");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--cs <filename>","Load pre-generated configuration file for run.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--ouput-cs <filename>","Output configuration file with settings provided on commandline.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-p <filename>","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("-w <width>","Window/output image width");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-h <height>","Window/output image height");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--ms <s>","Number of multi-samples to use when rendering, an enable a single sample buffer.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--samples <s>","Number of multi-samples to use when rendering.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--sampleBuffers <sb>","Number of sample buffers to use when rendering.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-f <fps>","Number of frames per second in simulation time.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-n <frames>","Number of frames to render/images to create.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("-d <time>","Duration of rendering run (duration = frames/fps).");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--center x y z","View center.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--eye x y z","Camera eye point.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--up x y z","Camera up vector.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-center x y z","Position to rotatate around.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-axis x y z","Axis to rotate around.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--rotation-speed v","Degrees per second.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--stereo mode","OFF | HORIZONTAL_SPLIT | VERTICAL_SPLIT");
|
||||
|
||||
osgViewer::Viewer viewer;
|
||||
|
||||
@ -91,7 +107,12 @@ int main( int argc, char **argv )
|
||||
osg::ref_ptr<osg::Object> object = osgDB::readObjectFile(filename);
|
||||
gsc::CaptureSettings* input_cs = dynamic_cast<gsc::CaptureSettings*>(object.get());
|
||||
if (input_cs) { fc = input_cs; readCaptureSettings = true; }
|
||||
else OSG_NOTICE<<"Unable to read CaptureSettings from file: "<<filename<<std::endl;
|
||||
else
|
||||
{
|
||||
OSG_NOTICE<<"Unable to read CaptureSettings from file: "<<filename<<std::endl;
|
||||
if (object.valid()) OSG_NOTICE<<"Object read, "<<object.get()<<", className()="<<object->className()<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (arguments.read("-i",filename)) fc->setInputFileName(filename);
|
||||
if (arguments.read("-o",filename)) fc->setOutputFileName(filename);
|
||||
@ -151,6 +172,14 @@ int main( int argc, char **argv )
|
||||
|
||||
}
|
||||
|
||||
std::string stereoMode;
|
||||
if (arguments.read("--stereo", stereoMode))
|
||||
{
|
||||
if (stereoMode=="HORIZONTAL_SPLIT") fc->setStereoMode(gsc::CaptureSettings::HORIZONTAL_SPLIT);
|
||||
else if (stereoMode=="VERTICAL_SPLIT") fc->setStereoMode(gsc::CaptureSettings::VERTICAL_SPLIT);
|
||||
else if (stereoMode=="OFF") fc->setStereoMode(gsc::CaptureSettings::OFF);
|
||||
}
|
||||
|
||||
if (arguments.read("--offscreen")) fc->setOffscreen(true);
|
||||
if (arguments.read("--screen")) fc->setOffscreen(false);
|
||||
|
||||
@ -173,16 +202,12 @@ int main( int argc, char **argv )
|
||||
fc->setSampleBuffers(1);
|
||||
}
|
||||
|
||||
if (arguments.read("--stereo"))
|
||||
{
|
||||
OSG_NOTICE<<"Enabling stereo"<<std::endl;
|
||||
fc->setStereo(true);
|
||||
}
|
||||
|
||||
if (arguments.read("-f",fps)) fc->setFrameRate(fps);
|
||||
|
||||
if (arguments.read("-n",nframes)) fc->setNumberOfFrames(nframes);
|
||||
|
||||
if (arguments.read("-d",duration)) {}
|
||||
|
||||
|
||||
std::string key;
|
||||
double time;
|
||||
@ -278,13 +303,19 @@ int main( int argc, char **argv )
|
||||
}
|
||||
|
||||
|
||||
|
||||
// setup viewer
|
||||
{
|
||||
osg::ref_ptr<osg::DisplaySettings> ds = new osg::DisplaySettings;
|
||||
|
||||
ds->setStereoMode(osg::DisplaySettings::HORIZONTAL_SPLIT);
|
||||
ds->setStereo(fc->getStereo());
|
||||
osg::DisplaySettings::StereoMode stereoMode = osg::DisplaySettings::HORIZONTAL_SPLIT;
|
||||
switch(fc->getStereoMode())
|
||||
{
|
||||
case(gsc::CaptureSettings::HORIZONTAL_SPLIT): stereoMode = osg::DisplaySettings::HORIZONTAL_SPLIT; break;
|
||||
case(gsc::CaptureSettings::VERTICAL_SPLIT): stereoMode = osg::DisplaySettings::VERTICAL_SPLIT; break;
|
||||
default: break;
|
||||
}
|
||||
ds->setStereoMode(stereoMode);
|
||||
ds->setStereo(fc->getStereoMode()!=gsc::CaptureSettings::OFF);
|
||||
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits(ds.get());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user