| 1 | #include <osgProducer/Viewer> |
|---|
| 2 | |
|---|
| 3 | #include <osg/Group> |
|---|
| 4 | #include <osg/Geode> |
|---|
| 5 | |
|---|
| 6 | #include <osgParticle/ExplosionEffect> |
|---|
| 7 | #include <osgParticle/SmokeEffect> |
|---|
| 8 | #include <osgParticle/FireEffect> |
|---|
| 9 | #include <osgParticle/ParticleSystemUpdater> |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | void build_world(osg::Group *root) |
|---|
| 17 | { |
|---|
| 18 | |
|---|
| 19 | osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect; |
|---|
| 20 | osgParticle::SmokeEffect* smoke = new osgParticle::SmokeEffect; |
|---|
| 21 | osgParticle::FireEffect* fire = new osgParticle::FireEffect; |
|---|
| 22 | |
|---|
| 23 | root->addChild(explosion); |
|---|
| 24 | root->addChild(smoke); |
|---|
| 25 | root->addChild(fire); |
|---|
| 26 | |
|---|
| 27 | osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; |
|---|
| 28 | |
|---|
| 29 | psu->addParticleSystem(explosion->getParticleSystem()); |
|---|
| 30 | psu->addParticleSystem(smoke->getParticleSystem()); |
|---|
| 31 | psu->addParticleSystem(fire->getParticleSystem()); |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | root->addChild(psu); |
|---|
| 35 | |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | int main(int argc, char **argv) |
|---|
| 45 | { |
|---|
| 46 | |
|---|
| 47 | osg::ArgumentParser arguments(&argc,argv); |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates use of particle systems."); |
|---|
| 51 | arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] image_file_left_eye image_file_right_eye"); |
|---|
| 52 | arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | osgProducer::Viewer viewer(arguments); |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | viewer.getUsage(*arguments.getApplicationUsage()); |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | if (arguments.read("-h") || arguments.read("--help")) |
|---|
| 66 | { |
|---|
| 67 | arguments.getApplicationUsage()->write(std::cout); |
|---|
| 68 | return 1; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | arguments.reportRemainingOptionsAsUnrecognized(); |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | if (arguments.errors()) |
|---|
| 76 | { |
|---|
| 77 | arguments.writeErrorMessages(std::cout); |
|---|
| 78 | return 1; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | osg::Group *root = new osg::Group; |
|---|
| 82 | build_world(root); |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | viewer.setSceneData(root); |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | viewer.realize(); |
|---|
| 89 | |
|---|
| 90 | while( !viewer.done() ) |
|---|
| 91 | { |
|---|
| 92 | |
|---|
| 93 | viewer.sync(); |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | viewer.update(); |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | viewer.frame(); |
|---|
| 101 | |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | viewer.sync(); |
|---|
| 106 | |
|---|
| 107 | return 0; |
|---|
| 108 | } |
|---|