Added support to slideshow3D for -s commandline option allow the size of

the display to be specified.

Also implementaited some code for display position and speed info in
osgProducer::Viewer, not fully implemented yet.
This commit is contained in:
Robert Osfield
2003-11-04 16:38:10 +00:00
parent 8ed0f3ea95
commit 54a8ea33ce
9 changed files with 137 additions and 27 deletions

View File

@@ -715,8 +715,8 @@ bool createWorld(const std::string& inputFile, const std::string& baseName, cons
bool doBumpMapping = true;
int bumpMapSizeWidth = 4097;
int bumpMapSizeHeight = 4097;
int bumpMapSizeWidth = 1024;
int bumpMapSizeHeight = 1024;
// int bumpMapSizeWidth = 512;
// int bumpMapSizeHeight = 512;

View File

@@ -488,12 +488,12 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSS3D::readNode(const std::string& fi
else constructor.setPresentationName("");
xmlFree(key);
}
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"ratio")))
/*else if ((!xmlStrcmp(cur->name, (const xmlChar *)"ratio")))
{
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
if (key) constructor.setPresentationAspectRatio((const char*)key);
xmlFree(key);
}
}*/
else if ((!xmlStrcmp(cur->name, (const xmlChar *)"bgcolor")))
{
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);

View File

@@ -18,10 +18,7 @@ SlideShowConstructor::SlideShowConstructor()
{
_slideDistance = osg::DisplaySettings::instance()->getScreenDistance();
_slideHeight = osg::DisplaySettings::instance()->getScreenHeight();
_slideWidth = _slideHeight*1280.0f/1024.f;
_slideOrigin.set(-_slideWidth*0.5f,_slideDistance,-_slideHeight*0.5f);
_slideWidth = osg::DisplaySettings::instance()->getScreenWidth();
_backgroundColor.set(0.0f,0.0f,0.0f,1.0f);
_textColor.set(1.0f,1.0f,1.0f,1.0f);
@@ -60,6 +57,8 @@ void SlideShowConstructor::setPresentationAspectRatio(const std::string& str)
void SlideShowConstructor::createPresentation()
{
_slideOrigin.set(-_slideWidth*0.5f,_slideDistance,-_slideHeight*0.5f);
_titleHeight = _slideHeight*0.06f;
_titleWidth = _slideWidth*0.8f;
_titleOrigin = _slideOrigin + osg::Vec3(_titlePositionRatios.x()*_slideWidth,_titlePositionRatios.y()*1.0f,_titlePositionRatios.z()*_slideHeight);
@@ -85,6 +84,8 @@ void SlideShowConstructor::createPresentation()
hp->center = slideCenter;
hp->up.set(0.0f,0.0f,1.0f);
std::cout<<" slideCenter "<<slideCenter<<std::endl;
if (_presentationDuration!=0.0)
{
_presentationSwitch->setUserData(new Duration(_presentationDuration));

View File

@@ -87,7 +87,8 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("-a","Turn auto stepping on by default");
arguments.getApplicationUsage()->addCommandLineOption("-d <float>","Time delay in seconds between layers/slides");
arguments.getApplicationUsage()->addCommandLineOption("-d <float>","Time duration in seconds between layers/slides");
arguments.getApplicationUsage()->addCommandLineOption("-s <float> <float> <float>","width, height, distance and of the screen away from the viewer");
// construct the viewer.
@@ -112,6 +113,9 @@ int main( int argc, char **argv )
bool autoSteppingActive = false;
while (arguments.read("-a")) autoSteppingActive = true;
// register the slide event handler - which moves the presentation from slide to slide, layer to layer.
SlideEventHandler* seh = new SlideEventHandler;
@@ -124,6 +128,17 @@ int main( int argc, char **argv )
PointsEventHandler* peh = new PointsEventHandler;
viewer.getEventHandlerList().push_front(peh);
float width, height, distance;
bool sizesSpecified = false;
while (arguments.read("-s", width, height, distance))
{
sizesSpecified = true;
osg::DisplaySettings::instance()->setScreenDistance(distance);
osg::DisplaySettings::instance()->setScreenHeight(height);
osg::DisplaySettings::instance()->setScreenWidth(width);
}
// get details on keyboard and mouse bindings used by the viewer.
viewer.getUsage(*arguments.getApplicationUsage());
@@ -135,7 +150,7 @@ int main( int argc, char **argv )
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
//arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occured when parsing the program aguments.
if (arguments.errors())
@@ -179,6 +194,14 @@ int main( int argc, char **argv )
// create the windows and run the threads.
viewer.realize();
if (sizesSpecified)
{
double vfov = osg::RadiansToDegrees(atan2(height/2.0,distance)*2.0);
double hfov = osg::RadiansToDegrees(atan2(width/2.0,distance)*2.0);
viewer.setLensPerspective( hfov, vfov, 0.1, 1000.0);
}
// set all the sceneview's up so that their left and right add cull masks are set up.
for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin();
itr!=viewer.getSceneHandlerList().end();