Show
Ignore:
Timestamp:
02/24/06 14:57:47 (9 years ago)
Author:
robert
Message:

Added debugging code to help pick out instablilities in osgParticle. Debugging
code now commented out.

Files:
1 modified

Legend:

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

    r4805 r5012  
    77#include <osg/PositionAttitudeTransform> 
    88#include <osg/MatrixTransform> 
     9#include <osg/io_utils> 
    910 
    1011#include <osgUtil/Optimizer> 
     
    383384}; 
    384385 
     386// function used in debugging 
     387void insertParticle(osg::Group* root, const osg::Vec3& center, float radius) 
     388{ 
     389    bool handleMovingModels = false; 
     390 
     391    osg::Vec3 position = center +  
     392               osg::Vec3( radius * (((float)rand() / (float)RAND_MAX)-0.5)*2.0, 
     393                          radius * (((float)rand() / (float)RAND_MAX)-0.5)*2.0, 
     394                          0.0f); 
     395 
     396    float scale = 10.0f * ((float)rand() / (float)RAND_MAX); 
     397    float intensity = 1.0f; 
     398 
     399    osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, scale, intensity); 
     400    osgParticle::ExplosionDebrisEffect* explosionDebri = new osgParticle::ExplosionDebrisEffect(position, scale, intensity); 
     401    osgParticle::FireEffect* fire = new osgParticle::FireEffect(position, scale, intensity); 
     402    osgParticle::ParticleEffect* smoke = 0; 
     403    if (handleMovingModels) 
     404        smoke =  new osgParticle::SmokeTrailEffect(position, scale, intensity); 
     405    else 
     406        smoke =  new osgParticle::SmokeEffect(position, scale, intensity); 
     407 
     408    explosion->setWind(wind); 
     409    explosionDebri->setWind(wind); 
     410    smoke->setWind(wind); 
     411    fire->setWind(wind); 
     412 
     413    osg::Group* effectsGroup = new osg::Group; 
     414    effectsGroup->addChild(explosion); 
     415    effectsGroup->addChild(explosionDebri); 
     416    effectsGroup->addChild(smoke); 
     417    effectsGroup->addChild(fire); 
     418 
     419    root->addChild(effectsGroup); 
     420} 
     421 
    385422////////////////////////////////////////////////////////////////////////////// 
    386423// main() 
    387424////////////////////////////////////////////////////////////////////////////// 
    388  
    389425 
    390426int main(int argc, char **argv) 
     
    441477    viewer.realize(); 
    442478 
     479    // osg::Vec3 center = root->getBound().center(); 
     480    // float radius = root->getBound().radius(); 
     481 
    443482    while( !viewer.done() ) 
    444483    { 
    445484        // wait for all cull and draw threads to complete. 
    446485        viewer.sync(); 
     486 
     487        // insertParticle(root, center, radius); 
    447488 
    448489        // update the scene by traversing it with the the update visitor which will