From Wang Rui, "I've changed it back to _alive, _current_size and _current_alpha, and placed them one by one for setTexCoordPointer() to use.
All size() methods are now renamed to volume(). At present only the CompositePlacer will use it for randomly choose a place according to the volumes of all children. "
This commit is contained in:
@@ -71,7 +71,7 @@ namespace osgParticle
|
||||
inline void place(Particle* P) const;
|
||||
|
||||
/// return the volume of the box
|
||||
inline float size() const;
|
||||
inline float volume() const;
|
||||
|
||||
/// return the control position
|
||||
inline osg::Vec3 getControlPosition() const;
|
||||
@@ -157,7 +157,7 @@ namespace osgParticle
|
||||
P->setPosition(pos);
|
||||
}
|
||||
|
||||
inline float BoxPlacer::size() const
|
||||
inline float BoxPlacer::volume() const
|
||||
{
|
||||
return (_x_range.maximum - _x_range.minimum) *
|
||||
(_y_range.maximum - _y_range.minimum) *
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
inline void place( Particle* P ) const;
|
||||
|
||||
/// return the volume of the box
|
||||
inline float size() const;
|
||||
inline float volume() const;
|
||||
|
||||
/// return the control position
|
||||
inline osg::Vec3 getControlPosition() const;
|
||||
@@ -75,20 +75,20 @@ protected:
|
||||
|
||||
inline void CompositePlacer::place( Particle* P ) const
|
||||
{
|
||||
rangef sizeRange( 0.0f, size() );
|
||||
rangef sizeRange( 0.0f, volume() );
|
||||
float current = 0.0f, selected = sizeRange.get_random();
|
||||
for ( PlacerList::const_iterator itr=_placers.begin(); itr!=_placers.end(); ++itr )
|
||||
{
|
||||
current += (*itr)->size();
|
||||
current += (*itr)->volume();
|
||||
if ( selected<=current ) (*itr)->place( P );
|
||||
}
|
||||
}
|
||||
|
||||
inline float CompositePlacer::size() const
|
||||
inline float CompositePlacer::volume() const
|
||||
{
|
||||
float total_size = 0.0f;
|
||||
for ( PlacerList::const_iterator itr=_placers.begin(); itr!=_placers.end(); ++itr )
|
||||
total_size += (*itr)->size();
|
||||
total_size += (*itr)->volume();
|
||||
return total_size;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace osgParticle {
|
||||
void place(Particle* P) const;
|
||||
|
||||
/// return the length of the multi-segment
|
||||
inline float size() const;
|
||||
inline float volume() const;
|
||||
|
||||
/// return the control position
|
||||
inline osg::Vec3 getControlPosition() const;
|
||||
@@ -130,7 +130,7 @@ namespace osgParticle {
|
||||
recompute_length();
|
||||
}
|
||||
|
||||
inline float MultiSegmentPlacer::size() const
|
||||
inline float MultiSegmentPlacer::volume() const
|
||||
{
|
||||
return _total_length;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace osgParticle
|
||||
inline const osg::Vec4& getCurrentColor() const { return _current_color; }
|
||||
|
||||
/// Get the current alpha
|
||||
inline float getCurrentAlpha() const { return _base_prop.z(); }
|
||||
inline float getCurrentAlpha() const { return _current_alpha; }
|
||||
|
||||
/// Get the s texture coordinate of the bottom left of the particle
|
||||
inline float getSTexCoord() const { return _s_coord; }
|
||||
@@ -302,7 +302,6 @@ namespace osgParticle
|
||||
osg::ref_ptr<Interpolator> _ai;
|
||||
osg::ref_ptr<Interpolator> _ci;
|
||||
|
||||
//bool _alive;
|
||||
bool _mustdie;
|
||||
double _lifeTime;
|
||||
|
||||
@@ -319,8 +318,9 @@ namespace osgParticle
|
||||
|
||||
double _t0;
|
||||
|
||||
//float _current_size;
|
||||
//float _current_alpha;
|
||||
float _alive;
|
||||
float _current_size;
|
||||
float _current_alpha;
|
||||
osg::Vec3 _base_prop; // [0] _alive [1] _current_size [2] _current_alpha
|
||||
osg::Vec4 _current_color;
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace osgParticle
|
||||
|
||||
inline bool Particle::isAlive() const
|
||||
{
|
||||
return _base_prop.x()>0.0;
|
||||
return _alive>0.0f;
|
||||
}
|
||||
|
||||
inline double Particle::getLifeTime() const
|
||||
@@ -597,7 +597,7 @@ namespace osgParticle
|
||||
|
||||
inline float Particle::getCurrentSize() const
|
||||
{
|
||||
return _base_prop.y();
|
||||
return _current_size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace osgParticle
|
||||
/// Place a particle. Must be implemented in descendant classes.
|
||||
virtual void place(Particle* P) const = 0;
|
||||
|
||||
/// Size of the placer. Can be implemented in descendant classes.
|
||||
virtual float size() const { return 1.0f; }
|
||||
/// Volume of the placer. Can be implemented in descendant classes.
|
||||
virtual float volume() const { return 1.0f; }
|
||||
|
||||
/// Return the control position of particles that placer will generate. Must be implemented in descendant classes.
|
||||
virtual osg::Vec3 getControlPosition() const = 0;
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace osgParticle
|
||||
inline void place(Particle* P) const;
|
||||
|
||||
/// return the area of the sector
|
||||
inline float size() const;
|
||||
inline float volume() const;
|
||||
|
||||
/// return the control position
|
||||
inline osg::Vec3 getControlPosition() const;
|
||||
@@ -133,7 +133,7 @@ namespace osgParticle
|
||||
P->setPosition(pos);
|
||||
}
|
||||
|
||||
inline float SectorPlacer::size() const
|
||||
inline float SectorPlacer::volume() const
|
||||
{
|
||||
return 0.5f * (_phi_range.maximum - _phi_range.minimum) *
|
||||
(_rad_range.maximum*_rad_range.maximum - _rad_range.minimum*_rad_range.minimum);
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace osgParticle {
|
||||
inline void place(Particle* P) const;
|
||||
|
||||
/// return the length of the segment
|
||||
inline float size() const;
|
||||
inline float volume() const;
|
||||
|
||||
/// return the control position
|
||||
inline osg::Vec3 getControlPosition() const;
|
||||
@@ -108,7 +108,7 @@ namespace osgParticle {
|
||||
P->setPosition(rangev3(_vertexA, _vertexB).get_random());
|
||||
}
|
||||
|
||||
inline float SegmentPlacer::size() const
|
||||
inline float SegmentPlacer::volume() const
|
||||
{
|
||||
return (_vertexB - _vertexA).length();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user