Changeset 3211

Show
Ignore:
Timestamp:
08/02/04 09:25:28 (10 years ago)
Author:
robert
Message:

From Tom Jolly. a couple of small changes to osgParticle.

"The first is with
Particle.cpp. I made a change so that when the lifetime is 0 (lasts
forever) the sizeRange, colorRange, and alphaRange are used to create
a random size, color, and alpha."

"The second change is with range and SectorPlacer?. The distribution of
particles across the sector was not uniform. I added get_random_sqrtf()
function where it is used in SectorPlacer::Place(). This seems to make
the distribution uniform (at least when minimum radius is 0)."

Location:
OpenSceneGraph/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgParticle/SectorPlacer

    r1529 r3211  
    117117    inline void SectorPlacer::place(Particle *P) const 
    118118    { 
    119         float rad = rad_range_.get_random(); 
     119        float rad = rad_range_.get_random_sqrtf(); 
    120120        float phi = phi_range_.get_random(); 
    121121         
  • OpenSceneGraph/trunk/include/osgParticle/range

    r1529 r3211  
    6565        } 
    6666 
     67        /// Get a random square root value between min and max. 
     68        T_ get_random_sqrtf() const 
     69        { 
     70            return minimum + (maximum - minimum) * sqrtf( static_cast<float>(rand()) / static_cast<float>(RAND_MAX) ); 
     71        } 
     72 
    6773    }; 
    6874 
  • OpenSceneGraph/trunk/src/osgParticle/Particle.cpp

    r2778 r3211  
    8787         
    8888    // compute the current values for size, alpha and color. 
    89     current_size_ = si_.get()->interpolate(x, sr_); 
    90     current_alpha_ = ai_.get()->interpolate(x, ar_); 
    91     current_color_ = ci_.get()->interpolate(x, cr_); 
     89    if (lifetime_ <= 0) { 
     90       if (dt == t0_) { 
     91          current_size_ = sr_.get_random(); 
     92          current_alpha_ = ar_.get_random(); 
     93          current_color_ = cr_.get_random(); 
     94       } 
     95    } else { 
     96       current_size_ = si_.get()->interpolate(x, sr_); 
     97       current_alpha_ = ai_.get()->interpolate(x, ar_); 
     98       current_color_ = ci_.get()->interpolate(x, cr_); 
     99    } 
    92100 
    93101    // update position