Merged changed to osgParticle from Marco Jez, the changes are (quoted from

email from Marco)

"Most relevant news:
1) particle systems now have the "freezeOnCull" property set to false by
default. Since it is an optimization, and using it may cause some unwanted
behaviors if not handled properly, it makes more sense to turn it off by
default.
2) new "LINE" shape mode which uses GL_LINES to draw line segments that
point to the direction of motion.
3) particles can now have a rotation angle and angular velocity.
4) new AngularAccelOperator applies angular acceleration to particles.
5) particle processors such as emitters and programs can have a "start",
"end" and "reset" time coordinate. For example, an emitter may be instructed
to start emitting particles only after a certain time, stop after another
amount of time and then start again.

Update (2) is from Gideon May.
Updates (3) to (5) are from Douglas A. Pouk."
This commit is contained in:
Robert Osfield
2003-09-02 20:39:41 +00:00
parent 763ee70f2f
commit 4761442005
19 changed files with 607 additions and 84 deletions

View File

@@ -45,11 +45,16 @@ namespace osgParticle
class OSGPARTICLE_EXPORT Particle {
public:
enum Shape {
/**
Shape of particles.
NOTE: the LINE shape should be used in conjunction with FIXED alignment mode (see ParticleSystem).
*/
enum Shape {
POINT, // uses GL_POINTS as primitive
QUAD, // uses GL_QUADS as primitive
QUAD_TRIANGLESTRIP, // uses GL_TRIANGLE_STRIP as primitive, but each particle needs a glBegin/glEnd pair
HEXAGON // may save some filling time, but uses more triangles
HEXAGON, // may save some filling time, but uses more triangles
LINE // uses GL_LINES to draw line segments that point to the direction of motion
};
Particle();
@@ -112,6 +117,15 @@ namespace osgParticle
/// Get the previous position (the position before last update).
inline const osg::Vec3 &getPreviousPosition() const;
/// Get the angle vector.
inline const osg::Vec3 &getAngle() const;
/// Get the rotational velocity vector.
inline const osg::Vec3 &getAngularVelocity() const;
/// Get the previous angle vector.
inline const osg::Vec3 &getPreviousAngle() const;
/** Kill the particle on next update
NOTE: after calling this function, the <CODE>isAlive()</CODE> method will still
return true until the particle is updated again.
@@ -164,6 +178,21 @@ namespace osgParticle
/// Transform position and velocity vectors by a matrix.
inline void transformPositionVelocity(const osg::Matrix &xform);
/// Set the angle vector.
inline void setAngle(const osg::Vec3 &a);
/**
Set the angular velocity vector.
Components x, y and z are angles of rotation around the respective axis (in radians).
*/
inline void setAngularVelocity(const osg::Vec3 &v);
/// Add a vector to the angular velocity vector.
inline void addAngularVelocity(const osg::Vec3 &dv);
/// Transform angle and angularVelocity vectors by a matrix.
inline void transformAngleVelocity(const osg::Matrix &xform);
/** Update the particle (don't call this method manually).
This method is called automatically by <CODE>ParticleSystem::update()</CODE>; it
updates the graphical properties of the particle for the current time,
@@ -206,6 +235,10 @@ namespace osgParticle
osg::Vec3 position_;
osg::Vec3 velocity_;
osg::Vec3 prev_angle_;
osg::Vec3 angle_;
osg::Vec3 angular_vel_;
double t0_;
float current_size_;
@@ -295,6 +328,21 @@ namespace osgParticle
return prev_pos_;
}
inline const osg::Vec3 &Particle::getAngle() const
{
return angle_;
}
inline const osg::Vec3 &Particle::getAngularVelocity() const
{
return angular_vel_;
}
inline const osg::Vec3 &Particle::getPreviousAngle() const
{
return prev_angle_;
}
inline void Particle::kill()
{
mustdie_ = true;
@@ -345,9 +393,9 @@ namespace osgParticle
velocity_ = v;
}
inline void Particle::addVelocity(const osg::Vec3 &v)
inline void Particle::addVelocity(const osg::Vec3 &dv)
{
velocity_ += v;
velocity_ += dv;
}
inline void Particle::transformPositionVelocity(const osg::Matrix &xform)
@@ -362,6 +410,33 @@ namespace osgParticle
velocity_ = p1 - position_;
}
inline void Particle::setAngle(const osg::Vec3 &a)
{
angle_ = a;
}
inline void Particle::setAngularVelocity(const osg::Vec3 &v)
{
angular_vel_ = v;
}
inline void Particle::addAngularVelocity(const osg::Vec3 &dv)
{
angular_vel_ += dv;
}
inline void Particle::transformAngleVelocity(const osg::Matrix &xform)
{
// this should be optimized!
osg::Vec3 a1 = angle_ + angular_vel_;
angle_ = xform.preMult(angle_);
a1 = xform.preMult(a1);
angular_vel_ = a1 - angle_;
}
inline float Particle::getMass() const
{
return mass_;
@@ -388,6 +463,9 @@ namespace osgParticle
case QUAD:
glBegin(GL_QUADS);
break;
case LINE:
glBegin(GL_LINES);
break;
default: ;
}
}
@@ -398,6 +476,7 @@ namespace osgParticle
{
case POINT:
case QUAD:
case LINE:
glEnd();
break;
default: ;