Show
Ignore:
Timestamp:
01/10/07 14:52:22 (7 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osgparticleeffects
osgphotoalbum
osgpick
osgpoints
osgpointsprite
osgprecipitation
osgprerender
osgprerendercubemap
osgreflect
osgscalarbar
osgscribe
osgsequence
osgplanets

Files:
1 modified

Legend:

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

    r5381 r5954  
    1414#include <osgUtil/Optimizer> 
    1515#include <osgUtil/CullVisitor> 
    16 #include <osgProducer/Viewer> 
     16#include <osgViewer/Viewer> 
    1717 
    1818#include <osg/MatrixTransform> 
    1919#include <osgUtil/TransformCallback> 
    2020#include <osgParticle/PrecipitationEffect> 
     21 
     22#include <iostream> 
    2123 
    2224class MyGustCallback : public osg::NodeCallback 
     
    5759    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); 
    5860    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    59     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    60     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    61     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    62     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    63     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    64     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    65     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    66     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    67     arguments.getApplicationUsage()->addCommandLineOption("",""); 
    68     arguments.getApplicationUsage()->addCommandLineOption("",""); 
     61    arguments.getApplicationUsage()->addCommandLineOption("--snow <density>","Set the snow with a density between 0 and 1.0"); 
     62    arguments.getApplicationUsage()->addCommandLineOption("--rain <density>",""); 
     63    arguments.getApplicationUsage()->addCommandLineOption("--particleSize <size>",""); 
     64    arguments.getApplicationUsage()->addCommandLineOption("--particleColour <red> <green> <blue> <alpha>",""); 
     65    arguments.getApplicationUsage()->addCommandLineOption("--wind <x> <y> <z>","Set the wind speed in model coordinates"); 
     66    arguments.getApplicationUsage()->addCommandLineOption("--particleSpeed <float>","Set the particle speed"); 
     67    arguments.getApplicationUsage()->addCommandLineOption("--nearTransition <distance>","Set the near transistion distance"); 
     68    arguments.getApplicationUsage()->addCommandLineOption("--farTransition  <distance>","Set the far transistion distance"); 
     69    arguments.getApplicationUsage()->addCommandLineOption("--particleDensity <density>","Set the particle density"); 
     70    arguments.getApplicationUsage()->addCommandLineOption("--cellSize <x> <y> <z>","Set the cell size in model coordinates"); 
     71    arguments.getApplicationUsage()->addCommandLineOption("--fogDensity <density>","Set the fog density"); 
     72    arguments.getApplicationUsage()->addCommandLineOption("--fogColour <red> <green> <blue> <alpha>","Set fog colour."); 
     73    arguments.getApplicationUsage()->addCommandLineOption("-useFarLineSegments","Switch on the use of line segments"); 
    6974     
    7075 
    7176    // construct the viewer. 
    72     osgProducer::Viewer viewer(arguments); 
    73  
    74     // set up the value with sensible default event handlers. 
    75     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    76  
    77     // get details on keyboard and mouse bindings used by the viewer. 
    78     viewer.getUsage(*arguments.getApplicationUsage()); 
     77    osgViewer::Viewer viewer; 
    7978 
    8079    osg::ref_ptr<osgParticle::PrecipitationEffect> precipitationEffect = new osgParticle::PrecipitationEffect; 
     
    119118 
    120119     
    121     viewer.setClearColor( precipitationEffect->getFog()->getColor() ); 
     120    viewer.getCamera()->setClearColor( precipitationEffect->getFog()->getColor() ); 
    122121 
    123122 
     
    126125    { 
    127126        arguments.getApplicationUsage()->write(std::cout); 
    128         return 1; 
    129     } 
    130  
    131     // any option left unread are converted into errors to write out later. 
    132     arguments.reportRemainingOptionsAsUnrecognized(); 
    133  
    134     // report any errors if they have occured when parsing the program aguments. 
    135     if (arguments.errors()) 
    136     { 
    137         arguments.writeErrorMessages(std::cout); 
    138127        return 1; 
    139128    } 
     
    171160    viewer.setSceneData(group.get()); 
    172161 
    173     // create the windows and run the threads. 
    174     viewer.realize(); 
    175  
    176     while( !viewer.done() ) 
    177     { 
    178         // wait for all cull and draw threads to complete. 
    179         viewer.sync(); 
    180  
    181         // update the scene by traversing it with the the update visitor which will 
    182         // call all node update callbacks and animations. 
    183         viewer.update(); 
    184           
    185         // fire off the cull and draw traversals of the scene. 
    186         viewer.frame(); 
    187          
    188     } 
    189      
    190     // wait for all cull and draw threads to complete. 
    191     viewer.sync(); 
    192  
    193     // run a clean up frame to delete all OpenGL objects. 
    194     viewer.cleanup_frame(); 
    195  
    196     // wait for all the clean up frame to complete. 
    197     viewer.sync(); 
    198  
    199     return 0; 
     162    return viewer.run(); 
    200163} 
    201164