Show
Ignore:
Timestamp:
09/11/08 11:05:16 (6 years ago)
Author:
robert
Message:

Added support for reading source image file names from the command line.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgimagesequence/osgimagesequence.cpp

    r8835 r8841  
    4242// 
    4343 
    44 osg::StateSet* createState() 
     44osg::StateSet* createState(osg::ArgumentParser& arguments) 
    4545{ 
    4646    osg::ref_ptr<osg::ImageSequence> imageSequence = new osg::ImageSequence; 
    47  
    48     imageSequence->setLength(4.0); 
    49     imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posx.png")); 
    50     imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negx.png")); 
    51     imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posy.png")); 
    52     imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negy.png")); 
    53     imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posz.png")); 
    54     imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negz.png")); 
    55      
     47     
     48    if (arguments.argc()>1) 
     49    { 
     50        for(unsigned int i=1; i<arguments.argc(); ++i) 
     51        { 
     52            osg::ref_ptr<osg::Image> image = osgDB::readImageFile(arguments[i]); 
     53            if (image.valid()) 
     54            { 
     55                imageSequence->addImage(image.get()); 
     56            } 
     57        } 
     58        imageSequence->setLength(float(imageSequence->getImages().size())*0.1f); 
     59    } 
     60    else 
     61    { 
     62        imageSequence->setLength(4.0); 
     63        imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posx.png")); 
     64        imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negx.png")); 
     65        imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posy.png")); 
     66        imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negy.png")); 
     67        imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posz.png")); 
     68        imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negz.png")); 
     69    } 
     70         
    5671    // start the image sequence playing 
    5772    imageSequence->play(); 
     
    87102} 
    88103 
    89 osg::Node* createModel() 
     104osg::Node* createModel(osg::ArgumentParser& arguments) 
    90105{ 
    91106 
     
    94109    geode->addDrawable(osg::createTexturedQuadGeometry(osg::Vec3(0.0f,0.0f,0.0), osg::Vec3(1.0f,0.0f,0.0), osg::Vec3(0.0f,0.0f,1.0f))); 
    95110 
    96     geode->setStateSet(createState()); 
     111    geode->setStateSet(createState(arguments)); 
    97112     
    98113    return geode; 
     
    277292    osgViewer::Viewer viewer(arguments); 
    278293 
     294    std::string filename; 
     295    arguments.read("-o",filename); 
     296 
    279297    // create a model from the images and pass it to the viewer. 
    280     viewer.setSceneData(createModel()); 
     298    viewer.setSceneData(createModel(arguments)); 
    281299 
    282300    // pass the model to the MovieEventHandler so it can pick out ImageStream's to manipulate. 
     
    286304 
    287305 
    288     std::string filename; 
    289     if (arguments.read("-o",filename)) 
     306    if (!filename.empty()) 
    290307    { 
    291308        osgDB::writeNodeFile(*viewer.getSceneData(),filename);