Show
Ignore:
Timestamp:
04/24/06 08:36:26 (9 years ago)
Author:
robert
Message:

Added support for wind.

Files:
1 modified

Legend:

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

    r5102 r5103  
    1616#include <osgProducer/Viewer> 
    1717 
     18#include <osg/MatrixTransform> 
     19#include <osgUtil/TransformCallback> 
    1820#include <osgParticle/PrecipitationEffect> 
     21 
     22class MyGustCallback : public osg::NodeCallback 
     23{ 
     24 
     25    public: 
     26 
     27        MyGustCallback() {} 
     28 
     29        virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) 
     30        { 
     31            osgParticle::PrecipitationEffect* pe = dynamic_cast<osgParticle::PrecipitationEffect*>(node); 
     32             
     33            float value = sin(nv->getFrameStamp()->getReferenceTime()); 
     34            if (value<-0.5) pe->getParameters()->wind.set(5.0,0.0,0.0); 
     35            else pe->getParameters()->wind.set(1.0,0.0,0.0); 
     36         
     37            traverse(node, nv); 
     38        } 
     39}; 
    1940 
    2041#if 0 
     
    120141    while (arguments.read("--particleColour", parameters.particleColour.r(), parameters.particleColour.g(), parameters.particleColour.b(), parameters.particleColour.a())) {} 
    121142 
    122     osg::Vec3 particleVelocity; 
    123     while (arguments.read("--particleVelocity", particleVelocity.x(), particleVelocity.y(), particleVelocity.z() )) parameters.particleVelocity = particleVelocity; 
     143    osg::Vec3 wind; 
     144    while (arguments.read("--wind", wind.x(), wind.y(), wind.z())) parameters.wind = wind; 
     145     
     146    while (arguments.read("--particleVelocity", parameters.particleVelocity)) {} 
    124147 
    125148    while (arguments.read("--nearTransition", parameters.nearTransition )) {} 
     
    181204    } 
    182205     
    183 #if 1 
    184      
     206    // precipitationEffect->setUpdateCallback(new MyGustCallback); 
     207 
    185208    osg::ref_ptr<osg::Group> group = new osg::Group; 
    186209    group->addChild(precipitationEffect.get()); 
     
    189212    // set the scene to render 
    190213    viewer.setSceneData(group.get()); 
    191  
    192 #else     
    193  
    194         loadedModel = createModel(loadedModel.get(), parameters); 
    195  
    196         // set the scene to render 
    197         viewer.setSceneData(loadedModel.get()); 
    198 #endif 
    199214 
    200215    // create the windows and run the threads.