Moved osgParticle across to standard OSG coding style.
This commit is contained in:
parent
6211eb7b48
commit
6b5238c294
@ -327,14 +327,14 @@ public:
|
||||
}
|
||||
if (numGroupsFound==parents.size() && numGroupsFound==1 && insertGroup)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"PickHandler::pick(,) hit node's parent is a single osg::Group so we can simple the insert the particle effects group here."<<std::endl;
|
||||
osg::notify(osg::INFO)<<"PickHandler::pick(,) hit node's parent is a single osg::Group so we can simple the insert the particle effects group here."<<std::endl;
|
||||
|
||||
// just reuse the existing group.
|
||||
insertGroup->addChild(effectsGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"PickHandler::pick(,) hit node doesn't have an appropriate osg::Group node to insert particle effects into, inserting a new osg::Group."<<std::endl;
|
||||
osg::notify(osg::INFO)<<"PickHandler::pick(,) hit node doesn't have an appropriate osg::Group node to insert particle effects into, inserting a new osg::Group."<<std::endl;
|
||||
insertGroup = new osg::Group;
|
||||
for(osg::Node::ParentList::iterator itr=parents.begin();
|
||||
itr!=parents.end();
|
||||
@ -360,7 +360,7 @@ public:
|
||||
else
|
||||
{
|
||||
// when we don't have moving models we can simple insert the particle effect into the root of the scene graph
|
||||
osg::notify(osg::NOTICE)<<"PickHandler::pick(,) adding particle effects to root node."<<std::endl;
|
||||
osg::notify(osg::INFO)<<"PickHandler::pick(,) adding particle effects to root node."<<std::endl;
|
||||
root->addChild(effectsGroup);
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_ACCELOPERATOR_
|
||||
#define OSGPARTICLE_ACCELOPERATOR_ 1
|
||||
#ifndef OSGPARTICLE_ACCELOPERATOR
|
||||
#define OSGPARTICLE_ACCELOPERATOR 1
|
||||
|
||||
#include <osgParticle/ModularProgram>
|
||||
#include <osgParticle/Operator>
|
||||
@ -31,15 +31,15 @@ namespace osgParticle
|
||||
class AccelOperator: public Operator {
|
||||
public:
|
||||
inline AccelOperator();
|
||||
inline AccelOperator(const AccelOperator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline AccelOperator(const AccelOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, AccelOperator);
|
||||
|
||||
/// Get the acceleration vector.
|
||||
inline const osg::Vec3 &getAcceleration() const;
|
||||
inline const osg::Vec3& getAcceleration() const;
|
||||
|
||||
/// Set the acceleration vector.
|
||||
inline void setAcceleration(const osg::Vec3 &v);
|
||||
inline void setAcceleration(const osg::Vec3& v);
|
||||
|
||||
/** Quickly set the acceleration vector to the gravity on earth (0, 0, -9.81).
|
||||
The acceleration will be multiplied by the <CODE>scale</CODE> parameter.
|
||||
@ -47,7 +47,7 @@ namespace osgParticle
|
||||
inline void setToGravity(float scale = 1);
|
||||
|
||||
/// Apply the acceleration to a particle. Do not call this method manually.
|
||||
inline void operate(Particle *P, double dt);
|
||||
inline void operate(Particle* P, double dt);
|
||||
|
||||
/// Perform some initializations. Do not call this method manually.
|
||||
inline void beginOperate(Program *prg);
|
||||
@ -57,48 +57,48 @@ namespace osgParticle
|
||||
AccelOperator &operator=(const AccelOperator &) { return *this; }
|
||||
|
||||
private:
|
||||
osg::Vec3 accel_;
|
||||
osg::Vec3 xf_accel_;
|
||||
osg::Vec3 _accel;
|
||||
osg::Vec3 _xf_accel;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline AccelOperator::AccelOperator()
|
||||
: Operator(), accel_(0, 0, 0)
|
||||
: Operator(), _accel(0, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
inline AccelOperator::AccelOperator(const AccelOperator ©, const osg::CopyOp ©op)
|
||||
: Operator(copy, copyop), accel_(copy.accel_)
|
||||
inline AccelOperator::AccelOperator(const AccelOperator& copy, const osg::CopyOp& copyop)
|
||||
: Operator(copy, copyop), _accel(copy._accel)
|
||||
{
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &AccelOperator::getAcceleration() const
|
||||
inline const osg::Vec3& AccelOperator::getAcceleration() const
|
||||
{
|
||||
return accel_;
|
||||
return _accel;
|
||||
}
|
||||
|
||||
inline void AccelOperator::setAcceleration(const osg::Vec3 &v)
|
||||
inline void AccelOperator::setAcceleration(const osg::Vec3& v)
|
||||
{
|
||||
accel_ = v;
|
||||
_accel = v;
|
||||
}
|
||||
|
||||
inline void AccelOperator::setToGravity(float scale)
|
||||
{
|
||||
accel_.set(0, 0, -9.80665f * scale);
|
||||
_accel.set(0, 0, -9.80665f * scale);
|
||||
}
|
||||
|
||||
inline void AccelOperator::operate(Particle *P, double dt)
|
||||
inline void AccelOperator::operate(Particle* P, double dt)
|
||||
{
|
||||
P->addVelocity(xf_accel_ * dt);
|
||||
P->addVelocity(_xf_accel * dt);
|
||||
}
|
||||
|
||||
inline void AccelOperator::beginOperate(Program *prg)
|
||||
{
|
||||
if (prg->getReferenceFrame() == ModularProgram::RELATIVE_RF) {
|
||||
xf_accel_ = prg->rotateLocalToWorld(accel_);
|
||||
_xf_accel = prg->rotateLocalToWorld(_accel);
|
||||
} else {
|
||||
xf_accel_ = accel_;
|
||||
_xf_accel = _accel;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_ANGULARACCELOPERATOR_
|
||||
#define OSGPARTICLE_ANGULARACCELOPERATOR_ 1
|
||||
#ifndef OSGPARTICLE_ANGULARACCELOPERATOR
|
||||
#define OSGPARTICLE_ANGULARACCELOPERATOR 1
|
||||
|
||||
#include <osgParticle/ModularProgram>
|
||||
#include <osgParticle/Operator>
|
||||
@ -32,64 +32,64 @@ namespace osgParticle
|
||||
class AngularAccelOperator: public Operator {
|
||||
public:
|
||||
inline AngularAccelOperator();
|
||||
inline AngularAccelOperator(const AngularAccelOperator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline AngularAccelOperator(const AngularAccelOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, AngularAccelOperator);
|
||||
|
||||
/// Get the angular acceleration vector.
|
||||
inline const osg::Vec3 &getAngularAcceleration() const;
|
||||
inline const osg::Vec3& getAngularAcceleration() const;
|
||||
|
||||
/// Set the angular acceleration vector.
|
||||
inline void setAngularAcceleration(const osg::Vec3 &v);
|
||||
inline void setAngularAcceleration(const osg::Vec3& v);
|
||||
|
||||
/// Apply the angular acceleration to a particle. Do not call this method manually.
|
||||
inline void operate(Particle *P, double dt);
|
||||
inline void operate(Particle* P, double dt);
|
||||
|
||||
/// Perform some initializations. Do not call this method manually.
|
||||
inline void beginOperate(Program *prg);
|
||||
|
||||
protected:
|
||||
virtual ~AngularAccelOperator() {}
|
||||
AngularAccelOperator &operator=(const AngularAccelOperator &) { return *this; }
|
||||
AngularAccelOperator& operator=(const AngularAccelOperator& ) { return *this; }
|
||||
|
||||
private:
|
||||
osg::Vec3 angular_accel_;
|
||||
osg::Vec3 xf_angular_accel_;
|
||||
osg::Vec3 _angul_araccel;
|
||||
osg::Vec3 _xf_angul_araccel;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline AngularAccelOperator::AngularAccelOperator()
|
||||
: Operator(), angular_accel_(0, 0, 0)
|
||||
: Operator(), _angul_araccel(0, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
inline AngularAccelOperator::AngularAccelOperator(const AngularAccelOperator ©, const osg::CopyOp ©op)
|
||||
: Operator(copy, copyop), angular_accel_(copy.angular_accel_)
|
||||
inline AngularAccelOperator::AngularAccelOperator(const AngularAccelOperator& copy, const osg::CopyOp& copyop)
|
||||
: Operator(copy, copyop), _angul_araccel(copy._angul_araccel)
|
||||
{
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &AngularAccelOperator::getAngularAcceleration() const
|
||||
inline const osg::Vec3& AngularAccelOperator::getAngularAcceleration() const
|
||||
{
|
||||
return angular_accel_;
|
||||
return _angul_araccel;
|
||||
}
|
||||
|
||||
inline void AngularAccelOperator::setAngularAcceleration(const osg::Vec3 &v)
|
||||
inline void AngularAccelOperator::setAngularAcceleration(const osg::Vec3& v)
|
||||
{
|
||||
angular_accel_ = v;
|
||||
_angul_araccel = v;
|
||||
}
|
||||
|
||||
inline void AngularAccelOperator::operate(Particle *P, double dt)
|
||||
inline void AngularAccelOperator::operate(Particle* P, double dt)
|
||||
{
|
||||
P->addAngularVelocity(xf_angular_accel_ * dt);
|
||||
P->addAngularVelocity(_xf_angul_araccel * dt);
|
||||
}
|
||||
|
||||
inline void AngularAccelOperator::beginOperate(Program *prg)
|
||||
{
|
||||
if (prg->getReferenceFrame() == ModularProgram::RELATIVE_RF) {
|
||||
xf_angular_accel_ = prg->rotateLocalToWorld(angular_accel_);
|
||||
_xf_angul_araccel = prg->rotateLocalToWorld(_angul_araccel);
|
||||
} else {
|
||||
xf_angular_accel_ = angular_accel_;
|
||||
_xf_angul_araccel = _angul_araccel;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_CENTEREDPLACER_
|
||||
#define OSGPARTICLE_CENTEREDPLACER_ 1
|
||||
#ifndef OSGPARTICLE_CENTERED_PLACER
|
||||
#define OSGPARTICLE_CENTERED_PLACER 1
|
||||
|
||||
#include <osgParticle/Placer>
|
||||
|
||||
@ -29,17 +29,17 @@ namespace osgParticle
|
||||
class CenteredPlacer: public Placer {
|
||||
public:
|
||||
inline CenteredPlacer();
|
||||
inline CenteredPlacer(const CenteredPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline CenteredPlacer(const CenteredPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "CenteredPlacer"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Placer *>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "CenteredPlacer"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Placer* >(obj) != 0; }
|
||||
|
||||
/// Get the center point.
|
||||
inline const osg::Vec3 &getCenter() const;
|
||||
inline const osg::Vec3& getCenter() const;
|
||||
|
||||
/// Set the center point.
|
||||
inline void setCenter(const osg::Vec3 &v);
|
||||
inline void setCenter(const osg::Vec3& v);
|
||||
|
||||
/// Set the center point.
|
||||
inline void setCenter(float x, float y, float z);
|
||||
@ -58,17 +58,17 @@ namespace osgParticle
|
||||
{
|
||||
}
|
||||
|
||||
inline CenteredPlacer::CenteredPlacer(const CenteredPlacer ©, const osg::CopyOp ©op)
|
||||
inline CenteredPlacer::CenteredPlacer(const CenteredPlacer& copy, const osg::CopyOp& copyop)
|
||||
: Placer(copy, copyop), center_(copy.center_)
|
||||
{
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &CenteredPlacer::getCenter() const
|
||||
inline const osg::Vec3& CenteredPlacer::getCenter() const
|
||||
{
|
||||
return center_;
|
||||
}
|
||||
|
||||
inline void CenteredPlacer::setCenter(const osg::Vec3 &v)
|
||||
inline void CenteredPlacer::setCenter(const osg::Vec3& v)
|
||||
{
|
||||
center_ = v;
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_COUNTER_
|
||||
#define OSGPARTICLE_COUNTER_ 1
|
||||
#ifndef OSGPARTICLE_COUNTER
|
||||
#define OSGPARTICLE_COUNTER 1
|
||||
|
||||
#include <osg/CopyOp>
|
||||
#include <osg/Object>
|
||||
@ -24,11 +24,11 @@ namespace osgParticle
|
||||
class Counter: public osg::Object {
|
||||
public:
|
||||
inline Counter();
|
||||
inline Counter(const Counter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline Counter(const Counter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "Counter"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Counter *>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "Counter"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Counter* >(obj) != 0; }
|
||||
|
||||
virtual int numParticlesToCreate(double dt) const = 0;
|
||||
|
||||
@ -44,7 +44,7 @@ namespace osgParticle
|
||||
{
|
||||
}
|
||||
|
||||
inline Counter::Counter(const Counter ©, const osg::CopyOp ©op)
|
||||
inline Counter::Counter(const Counter& copy, const osg::CopyOp& copyop)
|
||||
: osg::Object(copy, copyop)
|
||||
{
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_EMITTER_
|
||||
#define OSGPARTICLE_EMITTER_ 1
|
||||
#ifndef OSGPARTICLE_EMITTER
|
||||
#define OSGPARTICLE_EMITTER 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/ParticleProcessor>
|
||||
@ -35,18 +35,18 @@ namespace osgParticle
|
||||
class OSGPARTICLE_EXPORT Emitter: public ParticleProcessor {
|
||||
public:
|
||||
Emitter();
|
||||
Emitter(const Emitter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
Emitter(const Emitter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "Emitter"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Emitter*>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "Emitter"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Emitter*>(obj) != 0; }
|
||||
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
|
||||
|
||||
/// Get the particle template.
|
||||
inline const Particle &getParticleTemplate() const;
|
||||
inline const Particle& getParticleTemplate() const;
|
||||
|
||||
/// Set the particle template (particle is copied).
|
||||
inline void setParticleTemplate(const Particle &p);
|
||||
inline void setParticleTemplate(const Particle& p);
|
||||
|
||||
/// Return whether the particle system's default template should be used.
|
||||
inline bool getUseDefaultTemplate() const;
|
||||
@ -59,37 +59,37 @@ namespace osgParticle
|
||||
|
||||
protected:
|
||||
virtual ~Emitter() {}
|
||||
Emitter &operator=(const Emitter &) { return *this; }
|
||||
Emitter& operator=(const Emitter&) { return *this; }
|
||||
|
||||
inline void process(double dt);
|
||||
|
||||
virtual void emit(double dt) = 0;
|
||||
|
||||
bool usedeftemp_;
|
||||
Particle ptemp_;
|
||||
bool _usedeftemp;
|
||||
Particle _ptemp;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline const Particle &Emitter::getParticleTemplate() const
|
||||
inline const Particle& Emitter::getParticleTemplate() const
|
||||
{
|
||||
return ptemp_;
|
||||
return _ptemp;
|
||||
}
|
||||
|
||||
inline void Emitter::setParticleTemplate(const Particle &p)
|
||||
inline void Emitter::setParticleTemplate(const Particle& p)
|
||||
{
|
||||
ptemp_ = p;
|
||||
usedeftemp_ = false;
|
||||
_ptemp = p;
|
||||
_usedeftemp = false;
|
||||
}
|
||||
|
||||
inline bool Emitter::getUseDefaultTemplate() const
|
||||
{
|
||||
return usedeftemp_;
|
||||
return _usedeftemp;
|
||||
}
|
||||
|
||||
inline void Emitter::setUseDefaultTemplate(bool v)
|
||||
{
|
||||
usedeftemp_ = v;
|
||||
_usedeftemp = v;
|
||||
}
|
||||
|
||||
inline void Emitter::process(double dt)
|
||||
|
@ -11,8 +11,8 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGPARTICLE_FireEffect
|
||||
#define OSGPARTICLE_FireEffect
|
||||
#ifndef OSGPARTICLE_FIREEFFECT
|
||||
#define OSGPARTICLE_FIREEFFECT
|
||||
|
||||
#include <osgParticle/ParticleEffect>
|
||||
#include <osgParticle/ModularEmitter>
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_FLUIDFRICTIONOPERATOR_
|
||||
#define OSGPARTICLE_FLUIDFRICTIONOPERATOR_ 1
|
||||
#ifndef OSGPARTICLE_FLUIDFRICTIONOPERATOR
|
||||
#define OSGPARTICLE_FLUIDFRICTIONOPERATOR 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/Operator>
|
||||
@ -37,7 +37,7 @@ namespace osgParticle
|
||||
public:
|
||||
|
||||
FluidFrictionOperator();
|
||||
FluidFrictionOperator(const FluidFrictionOperator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
FluidFrictionOperator(const FluidFrictionOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, FluidFrictionOperator);
|
||||
|
||||
@ -72,47 +72,47 @@ namespace osgParticle
|
||||
inline void setFluidToWater();
|
||||
|
||||
/// Apply the friction forces to a particle. Do not call this method manually.
|
||||
void operate(Particle *P, double dt);
|
||||
void operate(Particle* P, double dt);
|
||||
|
||||
/// Perform some initializations. Do not call this method manually.
|
||||
inline void beginOperate(Program *prg);
|
||||
inline void beginOperate(Program* prg);
|
||||
|
||||
protected:
|
||||
virtual ~FluidFrictionOperator() {}
|
||||
FluidFrictionOperator &operator=(const FluidFrictionOperator &) { return *this; }
|
||||
|
||||
private:
|
||||
float A_;
|
||||
float B_;
|
||||
float density_;
|
||||
float viscosity_;
|
||||
float ovr_rad_;
|
||||
float _coeff_A;
|
||||
float _coeff_B;
|
||||
float _density;
|
||||
float _viscosity;
|
||||
float _ovr_rad;
|
||||
osg::Vec3 _wind;
|
||||
Program *current_program_;
|
||||
Program* _current_program;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline float FluidFrictionOperator::getFluidDensity() const
|
||||
{
|
||||
return density_;
|
||||
return _density;
|
||||
}
|
||||
|
||||
inline float FluidFrictionOperator::getFluidViscosity() const
|
||||
{
|
||||
return viscosity_;
|
||||
return _viscosity;
|
||||
}
|
||||
|
||||
inline void FluidFrictionOperator::setFluidDensity(float d)
|
||||
{
|
||||
density_ = d;
|
||||
B_ = 0.2f * osg::PI * density_;
|
||||
_density = d;
|
||||
_coeff_B = 0.2f * osg::PI * _density;
|
||||
}
|
||||
|
||||
inline void FluidFrictionOperator::setFluidViscosity(float v)
|
||||
{
|
||||
viscosity_ = v;
|
||||
A_ = 6 * osg::PI * viscosity_;
|
||||
_viscosity = v;
|
||||
_coeff_A = 6 * osg::PI * _viscosity;
|
||||
}
|
||||
|
||||
inline void FluidFrictionOperator::setFluidToAir()
|
||||
@ -129,17 +129,17 @@ namespace osgParticle
|
||||
|
||||
inline float FluidFrictionOperator::getOverrideRadius() const
|
||||
{
|
||||
return ovr_rad_;
|
||||
return _ovr_rad;
|
||||
}
|
||||
|
||||
inline void FluidFrictionOperator::setOverrideRadius(float r)
|
||||
{
|
||||
ovr_rad_ = r;
|
||||
_ovr_rad = r;
|
||||
}
|
||||
|
||||
inline void FluidFrictionOperator::beginOperate(Program *prg)
|
||||
inline void FluidFrictionOperator::beginOperate(Program* prg)
|
||||
{
|
||||
current_program_ = prg;
|
||||
_current_program = prg;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,8 +11,8 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGPARTICLE_FLUIDPROGRAM_
|
||||
#define OSGPARTICLE_FLUIDPROGRAM_ 1
|
||||
#ifndef OSGPARTICLE_FLUIDPROGRAM
|
||||
#define OSGPARTICLE_FLUIDPROGRAM 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/Program>
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_FORCEOPERATOR_
|
||||
#define OSGPARTICLE_FORCEOPERATOR_ 1
|
||||
#ifndef OSGPARTICLE_FORCEOPERATOR
|
||||
#define OSGPARTICLE_FORCEOPERATOR 1
|
||||
|
||||
#include <osgParticle/ModularProgram>
|
||||
#include <osgParticle/Operator>
|
||||
@ -33,64 +33,64 @@ namespace osgParticle
|
||||
class ForceOperator: public Operator {
|
||||
public:
|
||||
inline ForceOperator();
|
||||
inline ForceOperator(const ForceOperator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline ForceOperator(const ForceOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, ForceOperator);
|
||||
|
||||
/// Get the force vector.
|
||||
inline const osg::Vec3 &getForce() const;
|
||||
inline const osg::Vec3& getForce() const;
|
||||
|
||||
/// Set the force vector.
|
||||
inline void setForce(const osg::Vec3 &f);
|
||||
inline void setForce(const osg::Vec3& f);
|
||||
|
||||
/// Apply the force to a particle. Do not call this method manually.
|
||||
inline void operate(Particle *P, double dt);
|
||||
inline void operate(Particle* P, double dt);
|
||||
|
||||
/// Perform some initialization. Do not call this method manually.
|
||||
inline void beginOperate(Program *prg);
|
||||
|
||||
protected:
|
||||
virtual ~ForceOperator() {};
|
||||
ForceOperator &operator=(const ForceOperator &) { return *this; }
|
||||
ForceOperator& operator=(const ForceOperator&) { return *this; }
|
||||
|
||||
private:
|
||||
osg::Vec3 force_;
|
||||
osg::Vec3 xf_force_;
|
||||
osg::Vec3 _force;
|
||||
osg::Vec3 _xf_force;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline ForceOperator::ForceOperator()
|
||||
: Operator(), force_(0, 0, 0)
|
||||
: Operator(), _force(0, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
inline ForceOperator::ForceOperator(const ForceOperator ©, const osg::CopyOp ©op)
|
||||
: Operator(copy, copyop), force_(copy.force_)
|
||||
inline ForceOperator::ForceOperator(const ForceOperator& copy, const osg::CopyOp& copyop)
|
||||
: Operator(copy, copyop), _force(copy._force)
|
||||
{
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &ForceOperator::getForce() const
|
||||
inline const osg::Vec3& ForceOperator::getForce() const
|
||||
{
|
||||
return force_;
|
||||
return _force;
|
||||
}
|
||||
|
||||
inline void ForceOperator::setForce(const osg::Vec3 &v)
|
||||
inline void ForceOperator::setForce(const osg::Vec3& v)
|
||||
{
|
||||
force_ = v;
|
||||
_force = v;
|
||||
}
|
||||
|
||||
inline void ForceOperator::operate(Particle *P, double dt)
|
||||
inline void ForceOperator::operate(Particle* P, double dt)
|
||||
{
|
||||
P->addVelocity(xf_force_ * (P->getMassInv() * dt));
|
||||
P->addVelocity(_xf_force * (P->getMassInv() * dt));
|
||||
}
|
||||
|
||||
inline void ForceOperator::beginOperate(Program *prg)
|
||||
{
|
||||
if (prg->getReferenceFrame() == ModularProgram::RELATIVE_RF) {
|
||||
xf_force_ = prg->rotateLocalToWorld(force_);
|
||||
_xf_force = prg->rotateLocalToWorld(_force);
|
||||
} else {
|
||||
xf_force_ = force_;
|
||||
_xf_force = _force;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_INTERPOLATOR_
|
||||
#define OSGPARTICLE_INTERPOLATOR_
|
||||
#ifndef OSGPARTICLE_INTERPOLATOR
|
||||
#define OSGPARTICLE_INTERPOLATOR
|
||||
|
||||
#include <osgParticle/range>
|
||||
|
||||
@ -32,18 +32,18 @@ namespace osgParticle
|
||||
Interpolator()
|
||||
: osg::Object() {}
|
||||
|
||||
Interpolator(const Interpolator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY)
|
||||
Interpolator(const Interpolator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
|
||||
: osg::Object(copy, copyop) {}
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "Interpolator"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Interpolator *>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "Interpolator"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Interpolator* >(obj) != 0; }
|
||||
|
||||
/// Interpolate between floats. Must be overriden in descendant classes.
|
||||
virtual float interpolate(float t, float y1, float y2) const = 0;
|
||||
|
||||
/// Interpolate between 2-dimensional vectors. Default behavior is to interpolate each component separately.
|
||||
virtual osg::Vec2 interpolate(float t, const osg::Vec2 &y1, const osg::Vec2 &y2) const
|
||||
virtual osg::Vec2 interpolate(float t, const osg::Vec2& y1, const osg::Vec2& y2) const
|
||||
{
|
||||
return osg::Vec2(
|
||||
interpolate(t, y1.x(), y2.x()),
|
||||
@ -52,7 +52,7 @@ namespace osgParticle
|
||||
}
|
||||
|
||||
/// Interpolate between 3-dimensional vectors. Default behavior is to interpolate each component separately.
|
||||
virtual osg::Vec3 interpolate(float t, const osg::Vec3 &y1, const osg::Vec3 &y2) const
|
||||
virtual osg::Vec3 interpolate(float t, const osg::Vec3& y1, const osg::Vec3& y2) const
|
||||
{
|
||||
return osg::Vec3(
|
||||
interpolate(t, y1.x(), y2.x()),
|
||||
@ -62,7 +62,7 @@ namespace osgParticle
|
||||
}
|
||||
|
||||
/// Interpolate between 4-dimensional vectors. Default behavior is to interpolate each component separately.
|
||||
virtual osg::Vec4 interpolate(float t, const osg::Vec4 &y1, const osg::Vec4 &y2) const
|
||||
virtual osg::Vec4 interpolate(float t, const osg::Vec4& y1, const osg::Vec4& y2) const
|
||||
{
|
||||
return osg::Vec4(
|
||||
interpolate(t, y1.x(), y2.x()),
|
||||
@ -72,8 +72,8 @@ namespace osgParticle
|
||||
);
|
||||
}
|
||||
|
||||
template<class T_>
|
||||
T_ interpolate(float t, const range<T_> &r) const
|
||||
template<class ValueType>
|
||||
ValueType interpolate(float t, const range<ValueType>& r) const
|
||||
{
|
||||
return interpolate(t, r.minimum, r.maximum);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_LINEARINTERPOLATOR_
|
||||
#define OSGPARTICLE_LINEARINTERPOLATOR_
|
||||
#ifndef OSGPARTICLE_LINEARINTERPOLATOR
|
||||
#define OSGPARTICLE_LINEARINTERPOLATOR
|
||||
|
||||
#include <osgParticle/Interpolator>
|
||||
|
||||
@ -26,12 +26,13 @@ namespace osgParticle
|
||||
{
|
||||
|
||||
/// A linear interpolator.
|
||||
class LinearInterpolator: public Interpolator {
|
||||
class LinearInterpolator: public Interpolator
|
||||
{
|
||||
public:
|
||||
LinearInterpolator()
|
||||
: Interpolator() {}
|
||||
|
||||
LinearInterpolator(const LinearInterpolator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY)
|
||||
LinearInterpolator(const LinearInterpolator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
|
||||
: Interpolator(copy, copyop) {}
|
||||
|
||||
META_Object(osgParticle, LinearInterpolator);
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_MODULAREMITTER_
|
||||
#define OSGPARTICLE_MODULAREMITTER_ 1
|
||||
#ifndef OSGPARTICLE_MODULAREMITTER
|
||||
#define OSGPARTICLE_MODULAREMITTER 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/Emitter>
|
||||
@ -44,27 +44,27 @@ namespace osgParticle
|
||||
class OSGPARTICLE_EXPORT ModularEmitter: public Emitter {
|
||||
public:
|
||||
ModularEmitter();
|
||||
ModularEmitter(const ModularEmitter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
ModularEmitter(const ModularEmitter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Node(osgParticle,ModularEmitter);
|
||||
|
||||
/// Get the counter object.
|
||||
inline Counter *getCounter();
|
||||
inline Counter* getCounter();
|
||||
|
||||
/// Get the const Counter object.
|
||||
inline const Counter *getCounter() const;
|
||||
inline const Counter* getCounter() const;
|
||||
|
||||
/// Set the Counter object.
|
||||
inline void setCounter(Counter *c);
|
||||
inline void setCounter(Counter* c);
|
||||
|
||||
/// Get the Placer object.
|
||||
inline Placer *getPlacer();
|
||||
inline Placer* getPlacer();
|
||||
|
||||
/// Get the const Placer object.
|
||||
inline const Placer *getPlacer() const;
|
||||
inline const Placer* getPlacer() const;
|
||||
|
||||
/// Set the Placer object.
|
||||
inline void setPlacer(Placer *p);
|
||||
inline void setPlacer(Placer* p);
|
||||
|
||||
/// Get the Shooter object.
|
||||
inline Shooter *getShooter();
|
||||
@ -82,56 +82,56 @@ namespace osgParticle
|
||||
virtual void emit(double dt);
|
||||
|
||||
private:
|
||||
osg::ref_ptr<Counter> counter_;
|
||||
osg::ref_ptr<Placer> placer_;
|
||||
osg::ref_ptr<Shooter> shooter_;
|
||||
osg::ref_ptr<Counter> _counter;
|
||||
osg::ref_ptr<Placer> _placer;
|
||||
osg::ref_ptr<Shooter> _shooter;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline Counter *ModularEmitter::getCounter()
|
||||
inline Counter* ModularEmitter::getCounter()
|
||||
{
|
||||
return counter_.get();
|
||||
return _counter.get();
|
||||
}
|
||||
|
||||
inline const Counter *ModularEmitter::getCounter() const
|
||||
inline const Counter* ModularEmitter::getCounter() const
|
||||
{
|
||||
return counter_.get();
|
||||
return _counter.get();
|
||||
}
|
||||
|
||||
inline void ModularEmitter::setCounter(Counter *c)
|
||||
inline void ModularEmitter::setCounter(Counter* c)
|
||||
{
|
||||
counter_ = c;
|
||||
_counter = c;
|
||||
}
|
||||
|
||||
inline Placer *ModularEmitter::getPlacer()
|
||||
inline Placer* ModularEmitter::getPlacer()
|
||||
{
|
||||
return placer_.get();
|
||||
return _placer.get();
|
||||
}
|
||||
|
||||
inline const Placer *ModularEmitter::getPlacer() const
|
||||
inline const Placer* ModularEmitter::getPlacer() const
|
||||
{
|
||||
return placer_.get();
|
||||
return _placer.get();
|
||||
}
|
||||
|
||||
inline void ModularEmitter::setPlacer(Placer *p)
|
||||
inline void ModularEmitter::setPlacer(Placer* p)
|
||||
{
|
||||
placer_ = p;
|
||||
_placer = p;
|
||||
}
|
||||
|
||||
inline Shooter *ModularEmitter::getShooter()
|
||||
{
|
||||
return shooter_.get();
|
||||
return _shooter.get();
|
||||
}
|
||||
|
||||
inline const Shooter *ModularEmitter::getShooter() const
|
||||
{
|
||||
return shooter_.get();
|
||||
return _shooter.get();
|
||||
}
|
||||
|
||||
inline void ModularEmitter::setShooter(Shooter *s)
|
||||
{
|
||||
shooter_ = s;
|
||||
_shooter = s;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_MODULARPROGRAM_
|
||||
#define OSGPARTICLE_MODULARPROGRAM_ 1
|
||||
#ifndef OSGPARTICLE_MODULARPROGRAM
|
||||
#define OSGPARTICLE_MODULARPROGRAM 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/Program>
|
||||
@ -35,7 +35,7 @@ namespace osgParticle
|
||||
class OSGPARTICLE_EXPORT ModularProgram: public Program {
|
||||
public:
|
||||
ModularProgram();
|
||||
ModularProgram(const ModularProgram ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
ModularProgram(const ModularProgram& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Node(osgParticle,ModularProgram);
|
||||
|
||||
@ -43,54 +43,54 @@ namespace osgParticle
|
||||
inline int numOperators() const;
|
||||
|
||||
/// Add an operator to the list.
|
||||
inline void addOperator(Operator *o);
|
||||
inline void addOperator(Operator* o);
|
||||
|
||||
/// Get a pointer to an operator in the list.
|
||||
inline Operator *getOperator(int i);
|
||||
inline Operator* getOperator(int i);
|
||||
|
||||
/// Get a const pointer to an operator in the list.
|
||||
inline const Operator *getOperator(int i) const;
|
||||
inline const Operator* getOperator(int i) const;
|
||||
|
||||
/// Remove an operator from the list.
|
||||
inline void removeOperator(int i);
|
||||
|
||||
protected:
|
||||
virtual ~ModularProgram() {}
|
||||
ModularProgram &operator=(const ModularProgram &) { return *this; }
|
||||
ModularProgram& operator=(const ModularProgram&) { return *this; }
|
||||
|
||||
void execute(double dt);
|
||||
|
||||
private:
|
||||
typedef std::vector<osg::ref_ptr<Operator> > Operator_vector;
|
||||
|
||||
Operator_vector operators_;
|
||||
Operator_vector _operators;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline int ModularProgram::numOperators() const
|
||||
{
|
||||
return static_cast<int>(operators_.size());
|
||||
return static_cast<int>(_operators.size());
|
||||
}
|
||||
|
||||
inline void ModularProgram::addOperator(Operator *o)
|
||||
inline void ModularProgram::addOperator(Operator* o)
|
||||
{
|
||||
operators_.push_back(o);
|
||||
_operators.push_back(o);
|
||||
}
|
||||
|
||||
inline Operator *ModularProgram::getOperator(int i)
|
||||
inline Operator* ModularProgram::getOperator(int i)
|
||||
{
|
||||
return operators_[i].get();
|
||||
return _operators[i].get();
|
||||
}
|
||||
|
||||
inline const Operator *ModularProgram::getOperator(int i) const
|
||||
inline const Operator* ModularProgram::getOperator(int i) const
|
||||
{
|
||||
return operators_[i].get();
|
||||
return _operators[i].get();
|
||||
}
|
||||
|
||||
inline void ModularProgram::removeOperator(int i)
|
||||
{
|
||||
operators_.erase(operators_.begin()+i);
|
||||
_operators.erase(_operators.begin()+i);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_MULTISEGMENTPLACER_
|
||||
#define OSGPARTICLE_MULTISEGMENTPLACER_ 1
|
||||
#ifndef OSGPARTICLE_MULTISEGMENT_PLACER
|
||||
#define OSGPARTICLE_MULTISEGMENT_PLACER 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/Placer>
|
||||
@ -36,7 +36,7 @@ namespace osgParticle {
|
||||
class OSGPARTICLE_EXPORT MultiSegmentPlacer: public Placer {
|
||||
public:
|
||||
MultiSegmentPlacer();
|
||||
MultiSegmentPlacer(const MultiSegmentPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
MultiSegmentPlacer(const MultiSegmentPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, MultiSegmentPlacer);
|
||||
|
||||
@ -44,16 +44,16 @@ namespace osgParticle {
|
||||
inline int numVertices() const;
|
||||
|
||||
/// Get a vertex.
|
||||
inline const osg::Vec3 &getVertex(int i) const;
|
||||
inline const osg::Vec3& getVertex(int i) const;
|
||||
|
||||
/// Set a vertex.
|
||||
inline void setVertex(int i, const osg::Vec3 &v);
|
||||
inline void setVertex(int i, const osg::Vec3& v);
|
||||
|
||||
/// Set a vertex.
|
||||
inline void setVertex(int i, float x, float y, float z);
|
||||
|
||||
/// Add a vertex.
|
||||
inline void addVertex(const osg::Vec3 &v);
|
||||
inline void addVertex(const osg::Vec3& v);
|
||||
|
||||
/// Add a vertex.
|
||||
inline void addVertex(float x, float y, float z);
|
||||
@ -62,18 +62,18 @@ namespace osgParticle {
|
||||
inline void removeVertex(int i);
|
||||
|
||||
/// Place a partice. Called automatically by <CODE>ModularEmitter</CODE>, do not call this method manually.
|
||||
void place(Particle *P) const;
|
||||
void place(Particle* P) const;
|
||||
|
||||
protected:
|
||||
virtual ~MultiSegmentPlacer() {}
|
||||
MultiSegmentPlacer &operator=(const MultiSegmentPlacer &) { return *this; }
|
||||
MultiSegmentPlacer& operator=(const MultiSegmentPlacer&) { return *this; }
|
||||
|
||||
private:
|
||||
typedef std::pair<osg::Vec3, float> Vertex_data;
|
||||
typedef std::vector<Vertex_data> Vertex_vector;
|
||||
|
||||
Vertex_vector vx_;
|
||||
float total_length_;
|
||||
Vertex_vector _vx;
|
||||
float _total_length;
|
||||
|
||||
void recompute_length();
|
||||
};
|
||||
@ -83,34 +83,34 @@ namespace osgParticle {
|
||||
|
||||
inline int MultiSegmentPlacer::numVertices() const
|
||||
{
|
||||
return static_cast<int>(vx_.size());
|
||||
return static_cast<int>(_vx.size());
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &MultiSegmentPlacer::getVertex(int i) const
|
||||
inline const osg::Vec3& MultiSegmentPlacer::getVertex(int i) const
|
||||
{
|
||||
return vx_[i].first;
|
||||
return _vx[i].first;
|
||||
}
|
||||
|
||||
inline void MultiSegmentPlacer::setVertex(int i, const osg::Vec3 &v)
|
||||
inline void MultiSegmentPlacer::setVertex(int i, const osg::Vec3& v)
|
||||
{
|
||||
vx_[i].first = v;
|
||||
_vx[i].first = v;
|
||||
recompute_length();
|
||||
}
|
||||
|
||||
inline void MultiSegmentPlacer::setVertex(int i, float x, float y, float z)
|
||||
{
|
||||
vx_[i].first.set(x, y, z);
|
||||
_vx[i].first.set(x, y, z);
|
||||
recompute_length();
|
||||
}
|
||||
|
||||
inline void MultiSegmentPlacer::addVertex(const osg::Vec3 &v)
|
||||
inline void MultiSegmentPlacer::addVertex(const osg::Vec3& v)
|
||||
{
|
||||
float l = 0;
|
||||
if (vx_.size() > 0) {
|
||||
l = (v - vx_.back().first).length();
|
||||
if (_vx.size() > 0) {
|
||||
l = (v - _vx.back().first).length();
|
||||
}
|
||||
total_length_ += l;
|
||||
vx_.push_back(std::make_pair(v, total_length_));
|
||||
_total_length += l;
|
||||
_vx.push_back(std::make_pair(v, _total_length));
|
||||
}
|
||||
|
||||
inline void MultiSegmentPlacer::addVertex(float x, float y, float z)
|
||||
@ -120,7 +120,7 @@ namespace osgParticle {
|
||||
|
||||
inline void MultiSegmentPlacer::removeVertex(int i)
|
||||
{
|
||||
vx_.erase(vx_.begin()+i);
|
||||
_vx.erase(_vx.begin()+i);
|
||||
recompute_length();
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_OPERATOR_
|
||||
#define OSGPARTICLE_OPERATOR_ 1
|
||||
#ifndef OSGPARTICLE_OPERATOR
|
||||
#define OSGPARTICLE_OPERATOR 1
|
||||
|
||||
#include <osgParticle/Program>
|
||||
|
||||
@ -35,11 +35,11 @@ namespace osgParticle
|
||||
class Operator: public osg::Object {
|
||||
public:
|
||||
inline Operator();
|
||||
inline Operator(const Operator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline Operator(const Operator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "Operator"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Operator *>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "Operator"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Operator* >(obj) != 0; }
|
||||
|
||||
/// Get whether this operator is enabled.
|
||||
inline bool isEnabled() const;
|
||||
@ -53,7 +53,7 @@ namespace osgParticle
|
||||
consist of modifying the particle's velocity vector. The <CODE>dt</CODE> parameter is
|
||||
the time elapsed from last operation.
|
||||
*/
|
||||
virtual void operate(Particle *P, double dt) = 0;
|
||||
virtual void operate(Particle* P, double dt) = 0;
|
||||
|
||||
/** Do something before processing particles via the <CODE>operate()</CODE> method.
|
||||
Overriding this method could be necessary to query the calling <CODE>Program</CODE> object
|
||||
@ -70,29 +70,29 @@ namespace osgParticle
|
||||
Operator &operator=(const Operator &) { return *this; }
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
bool _enabled;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline Operator::Operator()
|
||||
: osg::Object(), enabled_(true)
|
||||
: osg::Object(), _enabled(true)
|
||||
{
|
||||
}
|
||||
|
||||
inline Operator::Operator(const Operator ©, const osg::CopyOp ©op)
|
||||
: osg::Object(copy, copyop), enabled_(copy.enabled_)
|
||||
inline Operator::Operator(const Operator& copy, const osg::CopyOp& copyop)
|
||||
: osg::Object(copy, copyop), _enabled(copy._enabled)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool Operator::isEnabled() const
|
||||
{
|
||||
return enabled_;
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
inline void Operator::setEnabled(bool v)
|
||||
{
|
||||
enabled_ = v;
|
||||
_enabled = v;
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_PARTICLE_
|
||||
#define OSGPARTICLE_PARTICLE_ 1
|
||||
#ifndef OSGPARTICLE_PARTICLE
|
||||
#define OSGPARTICLE_PARTICLE 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/Interpolator>
|
||||
@ -52,7 +52,7 @@ namespace osgParticle
|
||||
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
|
||||
QUAD_TRIANGLESTRIP, // uses GL_TRI_angleSTRIP as primitive, but each particle needs a glBegin/glEnd pair
|
||||
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
|
||||
};
|
||||
@ -75,22 +75,22 @@ namespace osgParticle
|
||||
inline double getAge() const;
|
||||
|
||||
/// Get the minimum and maximum values for polygon size.
|
||||
inline const rangef &getSizeRange() const;
|
||||
inline const rangef& getSizeRange() const;
|
||||
|
||||
/// Get the minimum and maximum values for alpha.
|
||||
inline const rangef &getAlphaRange() const;
|
||||
inline const rangef& getAlphaRange() const;
|
||||
|
||||
/// Get the minimum and maximum values for color.
|
||||
inline const rangev4 &getColorRange() const;
|
||||
inline const rangev4& getColorRange() const;
|
||||
|
||||
/// Get the interpolator for computing the size of polygons.
|
||||
inline const Interpolator *getSizeInterpolator() const;
|
||||
inline const Interpolator* getSizeInterpolator() const;
|
||||
|
||||
/// Get the interpolator for computing alpha values.
|
||||
inline const Interpolator *getAlphaInterpolator() const;
|
||||
inline const Interpolator* getAlphaInterpolator() const;
|
||||
|
||||
/// Get the interpolator for computing color values.
|
||||
inline const Interpolator *getColorInterpolator() const;
|
||||
inline const Interpolator* getColorInterpolator() const;
|
||||
|
||||
/** Get the physical radius of the particle.
|
||||
For built-in operators to work correctly, lengths must be expressed in meters.
|
||||
@ -106,25 +106,25 @@ namespace osgParticle
|
||||
inline float getMassInv() const;
|
||||
|
||||
/// Get the position vector.
|
||||
inline const osg::Vec3 &getPosition() const;
|
||||
inline const osg::Vec3& getPosition() const;
|
||||
|
||||
/** Get the velocity vector.
|
||||
For built-in operators to work correctly, remember that velocity components are expressed
|
||||
in meters per second.
|
||||
*/
|
||||
inline const osg::Vec3 &getVelocity() const;
|
||||
inline const osg::Vec3& getVelocity() const;
|
||||
|
||||
/// Get the previous position (the position before last update).
|
||||
inline const osg::Vec3 &getPreviousPosition() const;
|
||||
inline const osg::Vec3& getPreviousPosition() const;
|
||||
|
||||
/// Get the angle vector.
|
||||
inline const osg::Vec3 &getAngle() const;
|
||||
inline const osg::Vec3& getAngle() const;
|
||||
|
||||
/// Get the rotational velocity vector.
|
||||
inline const osg::Vec3 &getAngularVelocity() const;
|
||||
inline const osg::Vec3& getAngularVelocity() const;
|
||||
|
||||
/// Get the previous angle vector.
|
||||
inline const osg::Vec3 &getPreviousAngle() const;
|
||||
inline const osg::Vec3& getPreviousAngle() const;
|
||||
|
||||
/** Kill the particle on next update
|
||||
NOTE: after calling this function, the <CODE>isAlive()</CODE> method will still
|
||||
@ -136,22 +136,22 @@ namespace osgParticle
|
||||
inline void setLifeTime(double t);
|
||||
|
||||
/// Set the minimum and maximum values for polygon size.
|
||||
inline void setSizeRange(const rangef &r);
|
||||
inline void setSizeRange(const rangef& r);
|
||||
|
||||
/// Set the minimum and maximum values for alpha.
|
||||
inline void setAlphaRange(const rangef &r);
|
||||
inline void setAlphaRange(const rangef& r);
|
||||
|
||||
/// Set the minimum and maximum values for color.
|
||||
inline void setColorRange(const rangev4 &r);
|
||||
inline void setColorRange(const rangev4& r);
|
||||
|
||||
/// Set the interpolator for computing size values.
|
||||
inline void setSizeInterpolator(Interpolator *ri);
|
||||
inline void setSizeInterpolator(Interpolator* ri);
|
||||
|
||||
/// Set the interpolator for computing alpha values.
|
||||
inline void setAlphaInterpolator(Interpolator *ai);
|
||||
inline void setAlphaInterpolator(Interpolator* ai);
|
||||
|
||||
/// Set the interpolator for computing color values.
|
||||
inline void setColorInterpolator(Interpolator *ci);
|
||||
inline void setColorInterpolator(Interpolator* ci);
|
||||
|
||||
/** Set the physical radius of the particle.
|
||||
For built-in operators to work correctly, lengths must be expressed in meters.
|
||||
@ -164,34 +164,34 @@ namespace osgParticle
|
||||
inline void setMass(float m);
|
||||
|
||||
/// Set the position vector.
|
||||
inline void setPosition(const osg::Vec3 &p);
|
||||
inline void setPosition(const osg::Vec3& p);
|
||||
|
||||
/** Set the velocity vector.
|
||||
For built-in operators to work correctly, remember that velocity components are expressed
|
||||
in meters per second.
|
||||
*/
|
||||
inline void setVelocity(const osg::Vec3 &v);
|
||||
inline void setVelocity(const osg::Vec3& v);
|
||||
|
||||
/// Add a vector to the velocity vector.
|
||||
inline void addVelocity(const osg::Vec3 &dv);
|
||||
inline void addVelocity(const osg::Vec3& dv);
|
||||
|
||||
/// Transform position and velocity vectors by a matrix.
|
||||
inline void transformPositionVelocity(const osg::Matrix &xform);
|
||||
inline void transformPositionVelocity(const osg::Matrix& xform);
|
||||
|
||||
/// Set the angle vector.
|
||||
inline void setAngle(const osg::Vec3 &a);
|
||||
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);
|
||||
inline void setAngularVelocity(const osg::Vec3& v);
|
||||
|
||||
/// Add a vector to the angular velocity vector.
|
||||
inline void addAngularVelocity(const osg::Vec3 &dv);
|
||||
inline void addAngularVelocity(const osg::Vec3& dv);
|
||||
|
||||
/// Transform angle and angularVelocity vectors by a matrix.
|
||||
inline void transformAngleVelocity(const osg::Matrix &xform);
|
||||
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
|
||||
@ -205,7 +205,7 @@ namespace osgParticle
|
||||
inline void beginRender() const;
|
||||
|
||||
/// Render the particle. Called automatically by particle systems.
|
||||
void render(const osg::Vec3 &xpos, const osg::Vec3 &px, const osg::Vec3 &py, float scale = 1.0f) const;
|
||||
void render(const osg::Vec3& xpos, const osg::Vec3& px, const osg::Vec3& py, float scale = 1.0f) const;
|
||||
|
||||
/// Perform some post-rendering tasks. Called automatically by particle systems.
|
||||
inline void endRender() const;
|
||||
@ -217,255 +217,255 @@ namespace osgParticle
|
||||
inline void setTextureTile(int sTile, int tTile, int numTiles = 0);
|
||||
|
||||
private:
|
||||
Shape shape_;
|
||||
Shape _shape;
|
||||
|
||||
rangef sr_;
|
||||
rangef ar_;
|
||||
rangev4 cr_;
|
||||
rangef _sr;
|
||||
rangef _ar;
|
||||
rangev4 _cr;
|
||||
|
||||
osg::ref_ptr<Interpolator> si_;
|
||||
osg::ref_ptr<Interpolator> ai_;
|
||||
osg::ref_ptr<Interpolator> ci_;
|
||||
osg::ref_ptr<Interpolator> _si;
|
||||
osg::ref_ptr<Interpolator> _ai;
|
||||
osg::ref_ptr<Interpolator> _ci;
|
||||
|
||||
bool alive_;
|
||||
bool mustdie_;
|
||||
double lifetime_;
|
||||
bool _alive;
|
||||
bool _mustdie;
|
||||
double _lifeTime;
|
||||
|
||||
float radius_;
|
||||
float mass_;
|
||||
float massinv_;
|
||||
osg::Vec3 prev_pos_;
|
||||
osg::Vec3 position_;
|
||||
osg::Vec3 velocity_;
|
||||
float _radius;
|
||||
float _mass;
|
||||
float _massinv;
|
||||
osg::Vec3 _prev_pos;
|
||||
osg::Vec3 _position;
|
||||
osg::Vec3 _velocity;
|
||||
|
||||
osg::Vec3 prev_angle_;
|
||||
osg::Vec3 angle_;
|
||||
osg::Vec3 angular_vel_;
|
||||
osg::Vec3 _prev_angle;
|
||||
osg::Vec3 _angle;
|
||||
osg::Vec3 _angul_arvel;
|
||||
|
||||
double t0_;
|
||||
double _t0;
|
||||
|
||||
float current_size_;
|
||||
float current_alpha_;
|
||||
osg::Vec4 current_color_;
|
||||
float _current_size;
|
||||
float _current_alpha;
|
||||
osg::Vec4 _current_color;
|
||||
|
||||
float s_tile_;
|
||||
float t_tile_;
|
||||
int num_tile_;
|
||||
int cur_tile_;
|
||||
float s_coord_;
|
||||
float t_coord_;
|
||||
float _s_tile;
|
||||
float _t_tile;
|
||||
int _num_tile;
|
||||
int _cur_tile;
|
||||
float _s_coord;
|
||||
float _t_coord;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline Particle::Shape Particle::getShape() const
|
||||
{
|
||||
return shape_;
|
||||
return _shape;
|
||||
}
|
||||
|
||||
inline void Particle::setShape(Shape s)
|
||||
{
|
||||
shape_ = s;
|
||||
_shape = s;
|
||||
}
|
||||
|
||||
inline bool Particle::isAlive() const
|
||||
{
|
||||
return alive_;
|
||||
return _alive;
|
||||
}
|
||||
|
||||
inline double Particle::getLifeTime() const
|
||||
{
|
||||
return lifetime_;
|
||||
return _lifeTime;
|
||||
}
|
||||
|
||||
inline double Particle::getAge() const
|
||||
{
|
||||
return t0_;
|
||||
return _t0;
|
||||
}
|
||||
|
||||
inline float Particle::getRadius() const
|
||||
{
|
||||
return radius_;
|
||||
return _radius;
|
||||
}
|
||||
|
||||
inline void Particle::setRadius(float r)
|
||||
{
|
||||
radius_ = r;
|
||||
_radius = r;
|
||||
}
|
||||
|
||||
inline const rangef &Particle::getSizeRange() const
|
||||
inline const rangef& Particle::getSizeRange() const
|
||||
{
|
||||
return sr_;
|
||||
return _sr;
|
||||
}
|
||||
|
||||
inline const rangef &Particle::getAlphaRange() const
|
||||
inline const rangef& Particle::getAlphaRange() const
|
||||
{
|
||||
return ar_;
|
||||
return _ar;
|
||||
}
|
||||
|
||||
inline const rangev4 &Particle::getColorRange() const
|
||||
inline const rangev4& Particle::getColorRange() const
|
||||
{
|
||||
return cr_;
|
||||
return _cr;
|
||||
}
|
||||
|
||||
inline const Interpolator *Particle::getSizeInterpolator() const
|
||||
inline const Interpolator* Particle::getSizeInterpolator() const
|
||||
{
|
||||
return si_.get();
|
||||
return _si.get();
|
||||
}
|
||||
|
||||
inline const Interpolator *Particle::getAlphaInterpolator() const
|
||||
inline const Interpolator* Particle::getAlphaInterpolator() const
|
||||
{
|
||||
return ai_.get();
|
||||
return _ai.get();
|
||||
}
|
||||
|
||||
inline const Interpolator *Particle::getColorInterpolator() const
|
||||
inline const Interpolator* Particle::getColorInterpolator() const
|
||||
{
|
||||
return ci_.get();
|
||||
return _ci.get();
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &Particle::getPosition() const
|
||||
inline const osg::Vec3& Particle::getPosition() const
|
||||
{
|
||||
return position_;
|
||||
return _position;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &Particle::getVelocity() const
|
||||
inline const osg::Vec3& Particle::getVelocity() const
|
||||
{
|
||||
return velocity_;
|
||||
return _velocity;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &Particle::getPreviousPosition() const
|
||||
inline const osg::Vec3& Particle::getPreviousPosition() const
|
||||
{
|
||||
return prev_pos_;
|
||||
return _prev_pos;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &Particle::getAngle() const
|
||||
inline const osg::Vec3& Particle::getAngle() const
|
||||
{
|
||||
return angle_;
|
||||
return _angle;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &Particle::getAngularVelocity() const
|
||||
inline const osg::Vec3& Particle::getAngularVelocity() const
|
||||
{
|
||||
return angular_vel_;
|
||||
return _angul_arvel;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &Particle::getPreviousAngle() const
|
||||
inline const osg::Vec3& Particle::getPreviousAngle() const
|
||||
{
|
||||
return prev_angle_;
|
||||
return _prev_angle;
|
||||
}
|
||||
|
||||
inline void Particle::kill()
|
||||
{
|
||||
mustdie_ = true;
|
||||
_mustdie = true;
|
||||
}
|
||||
|
||||
inline void Particle::setLifeTime(double t)
|
||||
{
|
||||
lifetime_ = t;
|
||||
_lifeTime = t;
|
||||
}
|
||||
|
||||
inline void Particle::setSizeRange(const rangef &r)
|
||||
inline void Particle::setSizeRange(const rangef& r)
|
||||
{
|
||||
sr_ = r;
|
||||
_sr = r;
|
||||
}
|
||||
|
||||
inline void Particle::setAlphaRange(const rangef &r)
|
||||
inline void Particle::setAlphaRange(const rangef& r)
|
||||
{
|
||||
ar_ = r;
|
||||
_ar = r;
|
||||
}
|
||||
|
||||
inline void Particle::setColorRange(const rangev4 &r)
|
||||
inline void Particle::setColorRange(const rangev4& r)
|
||||
{
|
||||
cr_ = r;
|
||||
_cr = r;
|
||||
}
|
||||
|
||||
inline void Particle::setSizeInterpolator(Interpolator *ri)
|
||||
inline void Particle::setSizeInterpolator(Interpolator* ri)
|
||||
{
|
||||
si_ = ri;
|
||||
_si = ri;
|
||||
}
|
||||
|
||||
inline void Particle::setAlphaInterpolator(Interpolator *ai)
|
||||
inline void Particle::setAlphaInterpolator(Interpolator* ai)
|
||||
{
|
||||
ai_ = ai;
|
||||
_ai = ai;
|
||||
}
|
||||
|
||||
inline void Particle::setColorInterpolator(Interpolator *ci)
|
||||
inline void Particle::setColorInterpolator(Interpolator* ci)
|
||||
{
|
||||
ci_ = ci;
|
||||
_ci = ci;
|
||||
}
|
||||
|
||||
inline void Particle::setPosition(const osg::Vec3 &p)
|
||||
inline void Particle::setPosition(const osg::Vec3& p)
|
||||
{
|
||||
position_ = p;
|
||||
_position = p;
|
||||
}
|
||||
|
||||
inline void Particle::setVelocity(const osg::Vec3 &v)
|
||||
inline void Particle::setVelocity(const osg::Vec3& v)
|
||||
{
|
||||
velocity_ = v;
|
||||
_velocity = v;
|
||||
}
|
||||
|
||||
inline void Particle::addVelocity(const osg::Vec3 &dv)
|
||||
inline void Particle::addVelocity(const osg::Vec3& dv)
|
||||
{
|
||||
velocity_ += dv;
|
||||
_velocity += dv;
|
||||
}
|
||||
|
||||
inline void Particle::transformPositionVelocity(const osg::Matrix &xform)
|
||||
inline void Particle::transformPositionVelocity(const osg::Matrix& xform)
|
||||
{
|
||||
// this should be optimized!
|
||||
|
||||
osg::Vec3 p1 = position_ + velocity_;
|
||||
osg::Vec3 p1 = _position + _velocity;
|
||||
|
||||
position_ = xform.preMult(position_);
|
||||
_position = xform.preMult(_position);
|
||||
p1 = xform.preMult(p1);
|
||||
|
||||
velocity_ = p1 - position_;
|
||||
_velocity = p1 - _position;
|
||||
}
|
||||
|
||||
inline void Particle::setAngle(const osg::Vec3 &a)
|
||||
inline void Particle::setAngle(const osg::Vec3& a)
|
||||
{
|
||||
angle_ = a;
|
||||
_angle = a;
|
||||
}
|
||||
|
||||
inline void Particle::setAngularVelocity(const osg::Vec3 &v)
|
||||
inline void Particle::setAngularVelocity(const osg::Vec3& v)
|
||||
{
|
||||
angular_vel_ = v;
|
||||
_angul_arvel = v;
|
||||
}
|
||||
|
||||
inline void Particle::addAngularVelocity(const osg::Vec3 &dv)
|
||||
inline void Particle::addAngularVelocity(const osg::Vec3& dv)
|
||||
{
|
||||
angular_vel_ += dv;
|
||||
_angul_arvel += dv;
|
||||
}
|
||||
|
||||
inline void Particle::transformAngleVelocity(const osg::Matrix &xform)
|
||||
inline void Particle::transformAngleVelocity(const osg::Matrix& xform)
|
||||
{
|
||||
// this should be optimized!
|
||||
|
||||
osg::Vec3 a1 = angle_ + angular_vel_;
|
||||
osg::Vec3 a1 = _angle + _angul_arvel;
|
||||
|
||||
angle_ = xform.preMult(angle_);
|
||||
_angle = xform.preMult(_angle);
|
||||
a1 = xform.preMult(a1);
|
||||
|
||||
angular_vel_ = a1 - angle_;
|
||||
_angul_arvel = a1 - _angle;
|
||||
}
|
||||
|
||||
inline float Particle::getMass() const
|
||||
{
|
||||
return mass_;
|
||||
return _mass;
|
||||
}
|
||||
|
||||
inline float Particle::getMassInv() const
|
||||
{
|
||||
return massinv_;
|
||||
return _massinv;
|
||||
}
|
||||
|
||||
inline void Particle::setMass(float m)
|
||||
{
|
||||
mass_ = m;
|
||||
massinv_ = 1 / m;
|
||||
_mass = m;
|
||||
_massinv = 1 / m;
|
||||
}
|
||||
|
||||
inline void Particle::beginRender() const
|
||||
{
|
||||
switch (shape_)
|
||||
switch (_shape)
|
||||
{
|
||||
case POINT:
|
||||
glBegin(GL_POINTS);
|
||||
@ -482,7 +482,7 @@ namespace osgParticle
|
||||
|
||||
inline void Particle::endRender() const
|
||||
{
|
||||
switch (shape_)
|
||||
switch (_shape)
|
||||
{
|
||||
case POINT:
|
||||
case QUAD:
|
||||
@ -495,20 +495,20 @@ namespace osgParticle
|
||||
|
||||
inline float Particle::getCurrentSize() const
|
||||
{
|
||||
return current_size_;
|
||||
return _current_size;
|
||||
}
|
||||
|
||||
inline void Particle::setTextureTile(int sTile, int tTile, int numTiles)
|
||||
{
|
||||
s_tile_ = 1.0f / static_cast<float>(sTile);
|
||||
t_tile_ = 1.0f / static_cast<float>(tTile);
|
||||
_s_tile = 1.0f / static_cast<float>(sTile);
|
||||
_t_tile = 1.0f / static_cast<float>(tTile);
|
||||
if (numTiles <= 0)
|
||||
{
|
||||
num_tile_ = sTile * tTile;
|
||||
_num_tile = sTile * tTile;
|
||||
}
|
||||
else
|
||||
{
|
||||
num_tile_ = numTiles;
|
||||
_num_tile = numTiles;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,9 +37,9 @@ namespace osgParticle
|
||||
ParticleEffect(const ParticleEffect& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "ParticleEffect"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const ParticleEffect*>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "ParticleEffect"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ParticleEffect*>(obj) != 0; }
|
||||
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
|
||||
|
||||
void setUseLocalParticleSystem(bool local);
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_PARTICLEPROCESSOR_
|
||||
#define OSGPARTICLE_PARTICLEPROCESSOR_ 1
|
||||
#ifndef OSGPARTICLE_PARTICLEPROCESSOR
|
||||
#define OSGPARTICLE_PARTICLEPROCESSOR 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/ParticleSystem>
|
||||
@ -41,19 +41,14 @@ namespace osgParticle
|
||||
enum ReferenceFrame {
|
||||
RELATIVE_RF,
|
||||
ABSOLUTE_RF
|
||||
#ifdef USE_DEPRECATED_API
|
||||
,
|
||||
RELATIVE_RF_TO_PARENTS=RELATIVE_RF,
|
||||
RELATIVE_RF_TO_ABSOLUTE=ABSOLUTE_RF,
|
||||
#endif
|
||||
};
|
||||
|
||||
ParticleProcessor();
|
||||
ParticleProcessor(const ParticleProcessor ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
ParticleProcessor(const ParticleProcessor& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "ParticleProcessor"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const ParticleProcessor*>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "ParticleProcessor"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ParticleProcessor*>(obj) != 0; }
|
||||
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
|
||||
|
||||
/// Get the reference frame.
|
||||
@ -69,13 +64,13 @@ namespace osgParticle
|
||||
inline void setEnabled(bool v);
|
||||
|
||||
/// Get a pointer to the destination particle system.
|
||||
inline ParticleSystem *getParticleSystem();
|
||||
inline ParticleSystem* getParticleSystem();
|
||||
|
||||
/// Get a const pointer to the destination particle system.
|
||||
inline const ParticleSystem *getParticleSystem() const;
|
||||
inline const ParticleSystem* getParticleSystem() const;
|
||||
|
||||
/// Set the destination particle system.
|
||||
inline void setParticleSystem(ParticleSystem *ps);
|
||||
inline void setParticleSystem(ParticleSystem* ps);
|
||||
|
||||
/// Set the endless flag of this processor.
|
||||
inline void setEndless(bool type);
|
||||
@ -116,142 +111,143 @@ namespace osgParticle
|
||||
*/
|
||||
inline bool isAlive() const;
|
||||
|
||||
void traverse(osg::NodeVisitor &nv);
|
||||
void traverse(osg::NodeVisitor& nv);
|
||||
|
||||
/// Get the current local-to-world transformation matrix (valid only during cull traversal).
|
||||
inline const osg::Matrix &getLocalToWorldMatrix();
|
||||
inline const osg::Matrix& getLocalToWorldMatrix();
|
||||
|
||||
/// Get the current world-to-local transformation matrix (valid only during cull traversal).
|
||||
inline const osg::Matrix &getWorldToLocalMatrix();
|
||||
inline const osg::Matrix& getWorldToLocalMatrix();
|
||||
|
||||
/// Transform a point from local to world coordinates (valid only during cull traversal).
|
||||
inline osg::Vec3 transformLocalToWorld(const osg::Vec3 &P);
|
||||
inline osg::Vec3 transformLocalToWorld(const osg::Vec3& P);
|
||||
|
||||
/// Transform a vector from local to world coordinates, discarding translation (valid only during cull traversal).
|
||||
inline osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P);
|
||||
inline osg::Vec3 rotateLocalToWorld(const osg::Vec3& P);
|
||||
|
||||
/// Transform a point from world to local coordinates (valid only during cull traversal).
|
||||
inline osg::Vec3 transformWorldToLocal(const osg::Vec3 &P);
|
||||
inline osg::Vec3 transformWorldToLocal(const osg::Vec3& P);
|
||||
|
||||
/// Transform a vector from world to local coordinates, discarding translation (valid only during cull traversal).
|
||||
inline osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P);
|
||||
inline osg::Vec3 rotateWorldToLocal(const osg::Vec3& P);
|
||||
|
||||
protected:
|
||||
virtual ~ParticleProcessor() {}
|
||||
ParticleProcessor &operator=(const ParticleProcessor &) { return *this; }
|
||||
ParticleProcessor& operator=(const ParticleProcessor&) { return *this; }
|
||||
|
||||
inline bool computeBound() const;
|
||||
|
||||
virtual void process(double dt) = 0;
|
||||
|
||||
private:
|
||||
ReferenceFrame rf_;
|
||||
bool enabled_;
|
||||
double t0_;
|
||||
osg::ref_ptr<ParticleSystem> ps_;
|
||||
bool need_ltw_matrix_;
|
||||
bool need_wtl_matrix_;
|
||||
osg::Matrix ltw_matrix_;
|
||||
osg::Matrix wtl_matrix_;
|
||||
osg::NodeVisitor *current_nodevisitor_;
|
||||
ReferenceFrame _rf;
|
||||
bool _enabled;
|
||||
double _t0;
|
||||
osg::ref_ptr<ParticleSystem> _ps;
|
||||
bool _need_ltw_matrix;
|
||||
bool _need_wtl_matrix;
|
||||
osg::Matrix _ltw_matrix;
|
||||
osg::Matrix _wtl_matrix;
|
||||
osg::NodeVisitor* _current_nodevisitor;
|
||||
|
||||
bool endless_;
|
||||
bool _endless;
|
||||
|
||||
double lifeTime_;
|
||||
double startTime_;
|
||||
double currentTime_;
|
||||
double resetTime_;
|
||||
double _lifeTime;
|
||||
double _startTime;
|
||||
double _currentTime;
|
||||
double _resetTime;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline ParticleProcessor::ReferenceFrame ParticleProcessor::getReferenceFrame() const
|
||||
{
|
||||
return rf_;
|
||||
return _rf;
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setReferenceFrame(ReferenceFrame rf)
|
||||
{
|
||||
rf_ = rf;
|
||||
_rf = rf;
|
||||
}
|
||||
|
||||
inline bool ParticleProcessor::isEnabled() const
|
||||
{
|
||||
return enabled_;
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setEnabled(bool v)
|
||||
{
|
||||
enabled_ = v;
|
||||
if (enabled_) {
|
||||
t0_ = -1;
|
||||
currentTime_ = 0;
|
||||
}
|
||||
_enabled = v;
|
||||
if (_enabled)
|
||||
{
|
||||
_t0 = -1;
|
||||
_currentTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline ParticleSystem *ParticleProcessor::getParticleSystem()
|
||||
inline ParticleSystem* ParticleProcessor::getParticleSystem()
|
||||
{
|
||||
return ps_.get();
|
||||
return _ps.get();
|
||||
}
|
||||
|
||||
inline const ParticleSystem *ParticleProcessor::getParticleSystem() const
|
||||
inline const ParticleSystem* ParticleProcessor::getParticleSystem() const
|
||||
{
|
||||
return ps_.get();
|
||||
return _ps.get();
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setParticleSystem(ParticleSystem *ps)
|
||||
inline void ParticleProcessor::setParticleSystem(ParticleSystem* ps)
|
||||
{
|
||||
ps_ = ps;
|
||||
_ps = ps;
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setEndless(bool type)
|
||||
{
|
||||
endless_ = type;
|
||||
_endless = type;
|
||||
}
|
||||
|
||||
inline bool ParticleProcessor::isEndless() const
|
||||
{
|
||||
return endless_;
|
||||
return _endless;
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setLifeTime(double t)
|
||||
{
|
||||
lifeTime_ = t;
|
||||
}
|
||||
_lifeTime = t;
|
||||
}
|
||||
|
||||
inline double ParticleProcessor::getLifeTime() const
|
||||
{
|
||||
return lifeTime_;
|
||||
}
|
||||
|
||||
return _lifeTime;
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setStartTime(double t)
|
||||
{
|
||||
startTime_ = t;
|
||||
}
|
||||
_startTime = t;
|
||||
}
|
||||
|
||||
inline double ParticleProcessor::getStartTime() const
|
||||
{
|
||||
return startTime_;
|
||||
}
|
||||
return _startTime;
|
||||
}
|
||||
inline void ParticleProcessor::setCurrentTime(double t)
|
||||
{
|
||||
currentTime_ = t;
|
||||
}
|
||||
_currentTime = t;
|
||||
}
|
||||
|
||||
inline double ParticleProcessor::getCurrentTime() const
|
||||
{
|
||||
return currentTime_;
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setResetTime(double t)
|
||||
{
|
||||
resetTime_ = t;
|
||||
}
|
||||
|
||||
inline double ParticleProcessor::getResetTime() const
|
||||
{
|
||||
return resetTime_;
|
||||
}
|
||||
return _currentTime;
|
||||
}
|
||||
|
||||
inline void ParticleProcessor::setResetTime(double t)
|
||||
{
|
||||
_resetTime = t;
|
||||
}
|
||||
|
||||
inline double ParticleProcessor::getResetTime() const
|
||||
{
|
||||
return _resetTime;
|
||||
}
|
||||
|
||||
inline bool ParticleProcessor::computeBound() const
|
||||
{
|
||||
@ -260,45 +256,45 @@ namespace osgParticle
|
||||
return true;
|
||||
}
|
||||
|
||||
inline const osg::Matrix &ParticleProcessor::getLocalToWorldMatrix()
|
||||
inline const osg::Matrix& ParticleProcessor::getLocalToWorldMatrix()
|
||||
{
|
||||
if (need_ltw_matrix_) {
|
||||
ltw_matrix_ = osg::Matrix::identity();
|
||||
//current_nodevisitor_->getLocalToWorldMatrix(ltw_matrix_, this);
|
||||
ltw_matrix_ = osg::computeLocalToWorld(current_nodevisitor_->getNodePath());
|
||||
need_ltw_matrix_ = false;
|
||||
if (_need_ltw_matrix) {
|
||||
_ltw_matrix = osg::Matrix::identity();
|
||||
//_current_nodevisitor->getLocalToWorldMatrix(_ltw_matrix, this);
|
||||
_ltw_matrix = osg::computeLocalToWorld(_current_nodevisitor->getNodePath());
|
||||
_need_ltw_matrix = false;
|
||||
}
|
||||
return ltw_matrix_;
|
||||
return _ltw_matrix;
|
||||
}
|
||||
|
||||
inline const osg::Matrix &ParticleProcessor::getWorldToLocalMatrix()
|
||||
inline const osg::Matrix& ParticleProcessor::getWorldToLocalMatrix()
|
||||
{
|
||||
if (need_wtl_matrix_) {
|
||||
wtl_matrix_ = osg::Matrix::identity();
|
||||
//current_nodevisitor_->getWorldToLocalMatrix(wtl_matrix_, this);
|
||||
wtl_matrix_ = osg::computeWorldToLocal(current_nodevisitor_->getNodePath());
|
||||
need_wtl_matrix_ = false;
|
||||
if (_need_wtl_matrix) {
|
||||
_wtl_matrix = osg::Matrix::identity();
|
||||
//_current_nodevisitor->getWorldToLocalMatrix(_wtl_matrix, this);
|
||||
_wtl_matrix = osg::computeWorldToLocal(_current_nodevisitor->getNodePath());
|
||||
_need_wtl_matrix = false;
|
||||
}
|
||||
return wtl_matrix_;
|
||||
return _wtl_matrix;
|
||||
}
|
||||
|
||||
inline osg::Vec3 ParticleProcessor::transformLocalToWorld(const osg::Vec3 &P)
|
||||
inline osg::Vec3 ParticleProcessor::transformLocalToWorld(const osg::Vec3& P)
|
||||
{
|
||||
return getLocalToWorldMatrix().preMult(P);
|
||||
}
|
||||
|
||||
inline osg::Vec3 ParticleProcessor::transformWorldToLocal(const osg::Vec3 &P)
|
||||
inline osg::Vec3 ParticleProcessor::transformWorldToLocal(const osg::Vec3& P)
|
||||
{
|
||||
return getWorldToLocalMatrix().preMult(P);
|
||||
}
|
||||
|
||||
inline osg::Vec3 ParticleProcessor::rotateLocalToWorld(const osg::Vec3 &P)
|
||||
inline osg::Vec3 ParticleProcessor::rotateLocalToWorld(const osg::Vec3& P)
|
||||
{
|
||||
return getLocalToWorldMatrix().preMult(P) -
|
||||
getLocalToWorldMatrix().preMult(osg::Vec3(0, 0, 0));
|
||||
}
|
||||
|
||||
inline osg::Vec3 ParticleProcessor::rotateWorldToLocal(const osg::Vec3 &P)
|
||||
inline osg::Vec3 ParticleProcessor::rotateWorldToLocal(const osg::Vec3& P)
|
||||
{
|
||||
return getWorldToLocalMatrix().preMult(P) -
|
||||
getWorldToLocalMatrix().preMult(osg::Vec3(0, 0, 0));
|
||||
@ -306,7 +302,7 @@ namespace osgParticle
|
||||
|
||||
inline bool ParticleProcessor::isAlive() const
|
||||
{
|
||||
return currentTime_ < (lifeTime_ + startTime_);
|
||||
return _currentTime < (_lifeTime + _startTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_PARTICLESYSTEM_
|
||||
#define OSGPARTICLE_PARTICLESYSTEM_ 1
|
||||
#ifndef OSGPARTICLE_PARTICLESYSTEM
|
||||
#define OSGPARTICLE_PARTICLESYSTEM 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/Particle>
|
||||
@ -48,7 +48,7 @@ namespace osgParticle
|
||||
};
|
||||
|
||||
ParticleSystem();
|
||||
ParticleSystem(const ParticleSystem ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
ParticleSystem(const ParticleSystem& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, ParticleSystem);
|
||||
|
||||
@ -59,28 +59,28 @@ namespace osgParticle
|
||||
inline void setParticleAlignment(Alignment a);
|
||||
|
||||
/// Get the X-axis alignment vector.
|
||||
inline const osg::Vec3 &getAlignVectorX() const;
|
||||
inline const osg::Vec3& getAlignVectorX() const;
|
||||
|
||||
/// Set the X-axis alignment vector.
|
||||
inline void setAlignVectorX(const osg::Vec3 &v);
|
||||
inline void setAlignVectorX(const osg::Vec3& v);
|
||||
|
||||
/// Get the Y-axis alignment vector.
|
||||
inline const osg::Vec3 &getAlignVectorY() const;
|
||||
inline const osg::Vec3& getAlignVectorY() const;
|
||||
|
||||
/// Set the Y-axis alignment vector.
|
||||
inline void setAlignVectorY(const osg::Vec3 &v);
|
||||
inline void setAlignVectorY(const osg::Vec3& v);
|
||||
|
||||
/// Set the alignment vectors.
|
||||
inline void setAlignVectors(const osg::Vec3 &X, const osg::Vec3 &Y);
|
||||
inline void setAlignVectors(const osg::Vec3& X, const osg::Vec3& Y);
|
||||
|
||||
/// Get the default bounding box
|
||||
inline const osg::BoundingBox &getDefaultBoundingBox() const;
|
||||
inline const osg::BoundingBox& getDefaultBoundingBox() const;
|
||||
|
||||
/** Set the default bounding box.
|
||||
The default bounding box is used when a real bounding box cannot be computed, for example
|
||||
because no particles has been updated yet.
|
||||
*/
|
||||
inline void setDefaultBoundingBox(const osg::BoundingBox &bbox);
|
||||
inline void setDefaultBoundingBox(const osg::BoundingBox& bbox);
|
||||
|
||||
/// Get the double pass rendering flag.
|
||||
inline bool getDoublePassRendering() const;
|
||||
@ -112,13 +112,13 @@ namespace osgParticle
|
||||
inline bool areAllParticlesDead() const { return numDeadParticles()==numParticles(); }
|
||||
|
||||
/// Get a pointer to the i-th particle.
|
||||
inline Particle *getParticle(int i);
|
||||
inline Particle* getParticle(int i);
|
||||
|
||||
/// Get a const pointer to the i-th particle.
|
||||
inline const Particle *getParticle(int i) const;
|
||||
inline const Particle* getParticle(int i) const;
|
||||
|
||||
/// Create a new particle from the specified template (or the default one if <CODE>ptemplate</CODE> is null).
|
||||
inline virtual Particle *createParticle(const Particle *ptemplate);
|
||||
inline virtual Particle* createParticle(const Particle* ptemplate);
|
||||
|
||||
/// Destroy the i-th particle.
|
||||
inline virtual void destroyParticle(int i);
|
||||
@ -127,13 +127,13 @@ namespace osgParticle
|
||||
inline int getLastFrameNumber() const;
|
||||
|
||||
/// Get a reference to the default particle template.
|
||||
inline Particle &getDefaultParticleTemplate();
|
||||
inline Particle& getDefaultParticleTemplate();
|
||||
|
||||
/// Get a const reference to the default particle template.
|
||||
inline const Particle &getDefaultParticleTemplate() const;
|
||||
inline const Particle& getDefaultParticleTemplate() const;
|
||||
|
||||
/// Set the default particle template (particle is copied).
|
||||
inline void setDefaultParticleTemplate(const Particle &p);
|
||||
inline void setDefaultParticleTemplate(const Particle& p);
|
||||
|
||||
/// Get whether the particle system can freeze when culled
|
||||
inline bool getFreezeOnCull() const;
|
||||
@ -144,7 +144,7 @@ namespace osgParticle
|
||||
/** A useful method to set the most common <CODE>StateAttribute</CODE>'s in one call.
|
||||
If <CODE>texturefile</CODE> is empty, then texturing is turned off.
|
||||
*/
|
||||
void setDefaultAttributes(const std::string &texturefile = "", bool emissive_particles = true, bool lighting = false, int texture_unit = 0);
|
||||
void setDefaultAttributes(const std::string& texturefile = "", bool emissive_particles = true, bool lighting = false, int texture_unit = 0);
|
||||
|
||||
/// (<B>EXPERIMENTAL</B>) Get the level of detail.
|
||||
inline int getLevelOfDetail() const;
|
||||
@ -157,46 +157,46 @@ namespace osgParticle
|
||||
/// Update the particles. Don't call this directly, use a <CODE>ParticleSystemUpdater</CODE> instead.
|
||||
virtual void update(double dt);
|
||||
|
||||
virtual void drawImplementation(osg::State &state) const;
|
||||
virtual void drawImplementation(osg::State& state) const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~ParticleSystem();
|
||||
|
||||
ParticleSystem &operator=(const ParticleSystem &) { return *this; }
|
||||
ParticleSystem& operator=(const ParticleSystem&) { return *this; }
|
||||
|
||||
inline virtual bool computeBound() const;
|
||||
inline void update_bounds(const osg::Vec3 &p, float r);
|
||||
void single_pass_render(osg::State &state, const osg::Matrix &modelview) const;
|
||||
inline void update_bounds(const osg::Vec3& p, float r);
|
||||
void single_pass_render(osg::State& state, const osg::Matrix& modelview) const;
|
||||
|
||||
private:
|
||||
typedef std::vector<Particle> Particle_vector;
|
||||
typedef std::stack<Particle*> Death_stack;
|
||||
|
||||
Particle_vector particles_;
|
||||
Death_stack deadparts_;
|
||||
Particle_vector _particles;
|
||||
Death_stack _deadparts;
|
||||
|
||||
osg::BoundingBox def_bbox_;
|
||||
osg::BoundingBox _def_bbox;
|
||||
|
||||
Alignment alignment_;
|
||||
osg::Vec3 align_X_axis_;
|
||||
osg::Vec3 align_Y_axis_;
|
||||
Alignment _alignment;
|
||||
osg::Vec3 _align_X_axis;
|
||||
osg::Vec3 _align_Y_axis;
|
||||
|
||||
bool doublepass_;
|
||||
bool frozen_;
|
||||
bool _doublepass;
|
||||
bool _frozen;
|
||||
|
||||
osg::Vec3 bmin_;
|
||||
osg::Vec3 bmax_;
|
||||
osg::Vec3 _bmin;
|
||||
osg::Vec3 _bmax;
|
||||
|
||||
bool reset_bounds_flag_;
|
||||
bool bounds_computed_;
|
||||
bool _reset_bounds_flag;
|
||||
bool _bounds_computed;
|
||||
|
||||
Particle def_ptemp_;
|
||||
mutable int last_frame_;
|
||||
bool freeze_on_cull_;
|
||||
Particle _def_ptemp;
|
||||
mutable int _last_frame;
|
||||
bool _freeze_on_cull;
|
||||
|
||||
int detail_;
|
||||
mutable int draw_count_;
|
||||
int _detail;
|
||||
mutable int _draw_count;
|
||||
|
||||
};
|
||||
|
||||
@ -204,189 +204,189 @@ namespace osgParticle
|
||||
|
||||
inline ParticleSystem::Alignment ParticleSystem::getParticleAlignment() const
|
||||
{
|
||||
return alignment_;
|
||||
return _alignment;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setParticleAlignment(Alignment a)
|
||||
{
|
||||
alignment_ = a;
|
||||
_alignment = a;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &ParticleSystem::getAlignVectorX() const
|
||||
inline const osg::Vec3& ParticleSystem::getAlignVectorX() const
|
||||
{
|
||||
return align_X_axis_;
|
||||
return _align_X_axis;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setAlignVectorX(const osg::Vec3 &v)
|
||||
inline void ParticleSystem::setAlignVectorX(const osg::Vec3& v)
|
||||
{
|
||||
align_X_axis_ = v;
|
||||
_align_X_axis = v;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &ParticleSystem::getAlignVectorY() const
|
||||
inline const osg::Vec3& ParticleSystem::getAlignVectorY() const
|
||||
{
|
||||
return align_Y_axis_;
|
||||
return _align_Y_axis;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setAlignVectorY(const osg::Vec3 &v)
|
||||
inline void ParticleSystem::setAlignVectorY(const osg::Vec3& v)
|
||||
{
|
||||
align_Y_axis_ = v;
|
||||
_align_Y_axis = v;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setAlignVectors(const osg::Vec3 &X, const osg::Vec3 &Y)
|
||||
inline void ParticleSystem::setAlignVectors(const osg::Vec3& X, const osg::Vec3& Y)
|
||||
{
|
||||
align_X_axis_ = X;
|
||||
align_Y_axis_ = Y;
|
||||
_align_X_axis = X;
|
||||
_align_Y_axis = Y;
|
||||
}
|
||||
|
||||
inline bool ParticleSystem::isFrozen() const
|
||||
{
|
||||
return frozen_;
|
||||
return _frozen;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setFrozen(bool v)
|
||||
{
|
||||
frozen_ = v;
|
||||
_frozen = v;
|
||||
}
|
||||
|
||||
inline const osg::BoundingBox &ParticleSystem::getDefaultBoundingBox() const
|
||||
inline const osg::BoundingBox& ParticleSystem::getDefaultBoundingBox() const
|
||||
{
|
||||
return def_bbox_;
|
||||
return _def_bbox;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setDefaultBoundingBox(const osg::BoundingBox &bbox)
|
||||
inline void ParticleSystem::setDefaultBoundingBox(const osg::BoundingBox& bbox)
|
||||
{
|
||||
def_bbox_ = bbox;
|
||||
_def_bbox = bbox;
|
||||
}
|
||||
|
||||
inline bool ParticleSystem::getDoublePassRendering() const
|
||||
{
|
||||
return doublepass_;
|
||||
return _doublepass;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setDoublePassRendering(bool v)
|
||||
{
|
||||
doublepass_ = v;
|
||||
_doublepass = v;
|
||||
}
|
||||
|
||||
inline int ParticleSystem::numParticles() const
|
||||
{
|
||||
return static_cast<int>(particles_.size());
|
||||
return static_cast<int>(_particles.size());
|
||||
}
|
||||
|
||||
inline int ParticleSystem::numDeadParticles() const
|
||||
{
|
||||
return static_cast<int>(deadparts_.size());
|
||||
return static_cast<int>(_deadparts.size());
|
||||
}
|
||||
|
||||
inline Particle *ParticleSystem::getParticle(int i)
|
||||
inline Particle* ParticleSystem::getParticle(int i)
|
||||
{
|
||||
return &particles_[i];
|
||||
return &_particles[i];
|
||||
}
|
||||
|
||||
inline const Particle *ParticleSystem::getParticle(int i) const
|
||||
inline const Particle* ParticleSystem::getParticle(int i) const
|
||||
{
|
||||
return &particles_[i];
|
||||
return &_particles[i];
|
||||
}
|
||||
|
||||
inline void ParticleSystem::destroyParticle(int i)
|
||||
{
|
||||
particles_[i].kill();
|
||||
_particles[i].kill();
|
||||
}
|
||||
|
||||
inline int ParticleSystem::getLastFrameNumber() const
|
||||
{
|
||||
return last_frame_;
|
||||
return _last_frame;
|
||||
}
|
||||
|
||||
inline bool ParticleSystem::computeBound() const
|
||||
{
|
||||
if (!bounds_computed_) {
|
||||
_bbox = def_bbox_;
|
||||
if (!_bounds_computed) {
|
||||
_bbox = _def_bbox;
|
||||
} else {
|
||||
_bbox._min = bmin_;
|
||||
_bbox._max = bmax_;
|
||||
_bbox._min = _bmin;
|
||||
_bbox._max = _bmax;
|
||||
}
|
||||
_bbox_computed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::update_bounds(const osg::Vec3 &p, float r)
|
||||
inline void ParticleSystem::update_bounds(const osg::Vec3& p, float r)
|
||||
{
|
||||
if (reset_bounds_flag_) {
|
||||
reset_bounds_flag_ = false;
|
||||
bmin_ = p;
|
||||
bmax_ = p;
|
||||
if (_reset_bounds_flag) {
|
||||
_reset_bounds_flag = false;
|
||||
_bmin = p;
|
||||
_bmax = p;
|
||||
} else {
|
||||
if (p.x() - r < bmin_.x()) bmin_.x() = p.x() - r;
|
||||
if (p.y() - r < bmin_.y()) bmin_.y() = p.y() - r;
|
||||
if (p.z() - r < bmin_.z()) bmin_.z() = p.z() - r;
|
||||
if (p.x() + r > bmax_.x()) bmax_.x() = p.x() + r;
|
||||
if (p.y() + r > bmax_.y()) bmax_.y() = p.y() + r;
|
||||
if (p.z() + r > bmax_.z()) bmax_.z() = p.z() + r;
|
||||
if (p.x() - r < _bmin.x()) _bmin.x() = p.x() - r;
|
||||
if (p.y() - r < _bmin.y()) _bmin.y() = p.y() - r;
|
||||
if (p.z() - r < _bmin.z()) _bmin.z() = p.z() - r;
|
||||
if (p.x() + r > _bmax.x()) _bmax.x() = p.x() + r;
|
||||
if (p.y() + r > _bmax.y()) _bmax.y() = p.y() + r;
|
||||
if (p.z() + r > _bmax.z()) _bmax.z() = p.z() + r;
|
||||
|
||||
if (!bounds_computed_)
|
||||
bounds_computed_ = true;
|
||||
if (!_bounds_computed)
|
||||
_bounds_computed = true;
|
||||
}
|
||||
}
|
||||
|
||||
inline Particle &ParticleSystem::getDefaultParticleTemplate()
|
||||
inline Particle& ParticleSystem::getDefaultParticleTemplate()
|
||||
{
|
||||
return def_ptemp_;
|
||||
return _def_ptemp;
|
||||
}
|
||||
|
||||
inline const Particle &ParticleSystem::getDefaultParticleTemplate() const
|
||||
inline const Particle& ParticleSystem::getDefaultParticleTemplate() const
|
||||
{
|
||||
return def_ptemp_;
|
||||
return _def_ptemp;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setDefaultParticleTemplate(const Particle &p)
|
||||
inline void ParticleSystem::setDefaultParticleTemplate(const Particle& p)
|
||||
{
|
||||
def_ptemp_ = p;
|
||||
_def_ptemp = p;
|
||||
}
|
||||
|
||||
inline bool ParticleSystem::getFreezeOnCull() const
|
||||
{
|
||||
return freeze_on_cull_;
|
||||
return _freeze_on_cull;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setFreezeOnCull(bool v)
|
||||
{
|
||||
freeze_on_cull_ = v;
|
||||
_freeze_on_cull = v;
|
||||
}
|
||||
|
||||
inline int ParticleSystem::getLevelOfDetail() const
|
||||
{
|
||||
return detail_;
|
||||
return _detail;
|
||||
}
|
||||
|
||||
inline void ParticleSystem::setLevelOfDetail(int v)
|
||||
{
|
||||
if (v < 1) v = 1;
|
||||
detail_ = v;
|
||||
_detail = v;
|
||||
}
|
||||
|
||||
// I'm not sure this function should be inlined...
|
||||
|
||||
inline Particle *ParticleSystem::createParticle(const Particle *ptemplate)
|
||||
inline Particle* ParticleSystem::createParticle(const Particle* ptemplate)
|
||||
{
|
||||
// is there any dead particle?
|
||||
if (!deadparts_.empty()) {
|
||||
if (!_deadparts.empty()) {
|
||||
|
||||
// retrieve a pointer to the last dead particle
|
||||
Particle *P = deadparts_.top();
|
||||
Particle* P = _deadparts.top();
|
||||
|
||||
// create a new (alive) particle in the same place
|
||||
*P = Particle(ptemplate? *ptemplate: def_ptemp_);
|
||||
*P = Particle(ptemplate? *ptemplate: _def_ptemp);
|
||||
|
||||
// remove the pointer from the death stack
|
||||
deadparts_.pop();
|
||||
_deadparts.pop();
|
||||
return P;
|
||||
|
||||
} else {
|
||||
|
||||
// add a new particle to the vector
|
||||
particles_.push_back(Particle(ptemplate? *ptemplate: def_ptemp_));
|
||||
return &particles_.back();
|
||||
_particles.push_back(Particle(ptemplate? *ptemplate: _def_ptemp));
|
||||
return &_particles.back();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_PARTICLESYSTEMUPDATER_
|
||||
#define OSGPARTICLE_PARTICLESYSTEMUPDATER_ 1
|
||||
#ifndef OSGPARTICLE_PARTICLESYSTEMUPDATER
|
||||
#define OSGPARTICLE_PARTICLESYSTEMUPDATER 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/ParticleSystem>
|
||||
@ -39,21 +39,21 @@ namespace osgParticle
|
||||
class OSGPARTICLE_EXPORT ParticleSystemUpdater: public osg::Node {
|
||||
public:
|
||||
ParticleSystemUpdater();
|
||||
ParticleSystemUpdater(const ParticleSystemUpdater ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
ParticleSystemUpdater(const ParticleSystemUpdater& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Node(osgParticle,ParticleSystemUpdater);
|
||||
|
||||
/// Add a particle system to the list.
|
||||
inline bool addParticleSystem(ParticleSystem *ps);
|
||||
inline bool addParticleSystem(ParticleSystem* ps);
|
||||
|
||||
/// Remove a particle system from the list (by pointer).
|
||||
inline bool removeParticleSystem(ParticleSystem *ps);
|
||||
inline bool removeParticleSystem(ParticleSystem* ps);
|
||||
|
||||
/// Remove a particle system(s) from the list (by index).
|
||||
inline bool removeParticleSystem(unsigned int i, unsigned int numParticleSystemsToRemove=1);
|
||||
|
||||
/// Replace ParticleSystem with another ParticleSystem.
|
||||
inline bool replaceParticleSystem(ParticleSystem *origPS, ParticleSystem *newPS);
|
||||
inline bool replaceParticleSystem(ParticleSystem* origPS, ParticleSystem* newPS);
|
||||
|
||||
/// set a particle system by index.
|
||||
inline bool setParticleSystem( unsigned int i, ParticleSystem* ps );
|
||||
@ -73,7 +73,7 @@ namespace osgParticle
|
||||
/// get index number of ParticleSystem.
|
||||
inline unsigned int getParticleSystemIndex( const ParticleSystem* ps ) const;
|
||||
|
||||
virtual void traverse(osg::NodeVisitor &nv);
|
||||
virtual void traverse(osg::NodeVisitor& nv);
|
||||
|
||||
protected:
|
||||
virtual ~ParticleSystemUpdater() {}
|
||||
@ -84,8 +84,8 @@ namespace osgParticle
|
||||
private:
|
||||
typedef std::vector<osg::ref_ptr<ParticleSystem> > ParticleSystem_Vector;
|
||||
|
||||
ParticleSystem_Vector psv_;
|
||||
double t0_;
|
||||
ParticleSystem_Vector _psv;
|
||||
double _t0;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
@ -97,43 +97,43 @@ namespace osgParticle
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::addParticleSystem(ParticleSystem *ps)
|
||||
inline bool ParticleSystemUpdater::addParticleSystem(ParticleSystem* ps)
|
||||
{
|
||||
psv_.push_back(ps);
|
||||
_psv.push_back(ps);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::removeParticleSystem(ParticleSystem *ps)
|
||||
inline bool ParticleSystemUpdater::removeParticleSystem(ParticleSystem* ps)
|
||||
{
|
||||
unsigned int i = getParticleSystemIndex( ps );
|
||||
if( i >= psv_.size() ) return false;
|
||||
if( i >= _psv.size() ) return false;
|
||||
removeParticleSystem( i );
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::removeParticleSystem(unsigned int pos, unsigned int numParticleSystemsToRemove)
|
||||
{
|
||||
if( (pos < psv_.size()) && (numParticleSystemsToRemove > 0) )
|
||||
if( (pos < _psv.size()) && (numParticleSystemsToRemove > 0) )
|
||||
{
|
||||
unsigned int endOfRemoveRange = pos + numParticleSystemsToRemove;
|
||||
if( endOfRemoveRange > psv_.size() )
|
||||
if( endOfRemoveRange > _psv.size() )
|
||||
{
|
||||
osg::notify(osg::DEBUG_INFO)<<"Warning: ParticleSystem::removeParticleSystem(i,numParticleSystemsToRemove) has been passed an excessive number"<<std::endl;
|
||||
osg::notify(osg::DEBUG_INFO)<<" of ParticleSystems to remove, trimming just to end of ParticleSystem list."<<std::endl;
|
||||
endOfRemoveRange = psv_.size();
|
||||
endOfRemoveRange = _psv.size();
|
||||
}
|
||||
psv_.erase(psv_.begin()+pos, psv_.begin()+endOfRemoveRange);
|
||||
_psv.erase(_psv.begin()+pos, _psv.begin()+endOfRemoveRange);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::replaceParticleSystem( ParticleSystem *origPS, ParticleSystem* newPS )
|
||||
inline bool ParticleSystemUpdater::replaceParticleSystem( ParticleSystem* origPS, ParticleSystem* newPS )
|
||||
{
|
||||
if( (newPS == NULL) || (origPS == newPS) ) return false;
|
||||
|
||||
unsigned int pos = getParticleSystemIndex( origPS );
|
||||
if( pos < psv_.size() )
|
||||
if( pos < _psv.size() )
|
||||
{
|
||||
return setParticleSystem( pos, newPS );
|
||||
}
|
||||
@ -142,9 +142,9 @@ namespace osgParticle
|
||||
|
||||
inline bool ParticleSystemUpdater::setParticleSystem( unsigned int i, ParticleSystem* ps )
|
||||
{
|
||||
if( (i < psv_.size()) && ps )
|
||||
if( (i < _psv.size()) && ps )
|
||||
{
|
||||
psv_[i] = ps;
|
||||
_psv[i] = ps;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -152,23 +152,23 @@ namespace osgParticle
|
||||
|
||||
inline unsigned int ParticleSystemUpdater::getNumParticleSystems() const
|
||||
{
|
||||
return static_cast<int>(psv_.size());
|
||||
return static_cast<int>(_psv.size());
|
||||
}
|
||||
|
||||
inline ParticleSystem* ParticleSystemUpdater::getParticleSystem(unsigned int i)
|
||||
{
|
||||
return psv_[i].get();
|
||||
return _psv[i].get();
|
||||
}
|
||||
|
||||
inline const ParticleSystem* ParticleSystemUpdater::getParticleSystem(unsigned int i) const
|
||||
{
|
||||
return psv_[i].get();
|
||||
return _psv[i].get();
|
||||
}
|
||||
|
||||
inline bool ParticleSystemUpdater::containsParticleSystem( const ParticleSystem* ps ) const
|
||||
{
|
||||
for( ParticleSystem_Vector::const_iterator itr=psv_.begin();
|
||||
itr!=psv_.end();
|
||||
for( ParticleSystem_Vector::const_iterator itr=_psv.begin();
|
||||
itr!=_psv.end();
|
||||
++itr )
|
||||
{
|
||||
if( itr->get() == ps ) return true;
|
||||
@ -178,11 +178,11 @@ namespace osgParticle
|
||||
|
||||
inline unsigned int ParticleSystemUpdater::getParticleSystemIndex( const ParticleSystem* ps ) const
|
||||
{
|
||||
for( unsigned int particleSystemNum=0; particleSystemNum<psv_.size(); ++particleSystemNum )
|
||||
for( unsigned int particleSystemNum=0; particleSystemNum<_psv.size(); ++particleSystemNum )
|
||||
{
|
||||
if( psv_[particleSystemNum] == ps ) return particleSystemNum;
|
||||
if( _psv[particleSystemNum] == ps ) return particleSystemNum;
|
||||
}
|
||||
return psv_.size(); // node not found.
|
||||
return _psv.size(); // node not found.
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_PLACER_
|
||||
#define OSGPARTICLE_PLACER_ 1
|
||||
#ifndef OSGPARTICLE_PLACER
|
||||
#define OSGPARTICLE_PLACER 1
|
||||
|
||||
#include <osg/CopyOp>
|
||||
#include <osg/Object>
|
||||
@ -30,18 +30,18 @@ namespace osgParticle
|
||||
class Placer: public osg::Object {
|
||||
public:
|
||||
inline Placer();
|
||||
inline Placer(const Placer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline Placer(const Placer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "Placer"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Placer *>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "Placer"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Placer *>(obj) != 0; }
|
||||
|
||||
/// Place a particle. Must be implemented in descendant classes.
|
||||
virtual void place(Particle *P) const = 0;
|
||||
virtual void place(Particle* P) const = 0;
|
||||
|
||||
protected:
|
||||
~Placer() {}
|
||||
Placer &operator=(const Placer &) { return *this; }
|
||||
Placer& operator=(const Placer& ) { return *this; }
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
@ -51,7 +51,7 @@ namespace osgParticle
|
||||
{
|
||||
}
|
||||
|
||||
inline Placer::Placer(const Placer ©, const osg::CopyOp ©op)
|
||||
inline Placer::Placer(const Placer& copy, const osg::CopyOp& copyop)
|
||||
: osg::Object(copy, copyop)
|
||||
{
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_POINTPLACER_
|
||||
#define OSGPARTICLE_POINTPLACER_ 1
|
||||
#ifndef OSGPARTICLE_POINT_PLACER
|
||||
#define OSGPARTICLE_POINT_PLACER 1
|
||||
|
||||
#include <osgParticle/CenteredPlacer>
|
||||
#include <osgParticle/Particle>
|
||||
@ -31,7 +31,7 @@ namespace osgParticle
|
||||
class PointPlacer: public CenteredPlacer {
|
||||
public:
|
||||
inline PointPlacer();
|
||||
inline PointPlacer(const PointPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline PointPlacer(const PointPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, PointPlacer);
|
||||
|
||||
@ -39,11 +39,11 @@ namespace osgParticle
|
||||
This method is called automatically by <CODE>ModularEmitter</CODE> and should not be called
|
||||
manually.
|
||||
*/
|
||||
inline void place(Particle *P) const;
|
||||
inline void place(Particle* P) const;
|
||||
|
||||
protected:
|
||||
virtual ~PointPlacer() {}
|
||||
PointPlacer &operator=(const PointPlacer &) { return *this; }
|
||||
PointPlacer& operator=(const PointPlacer&) { return *this; }
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
@ -53,12 +53,12 @@ namespace osgParticle
|
||||
{
|
||||
}
|
||||
|
||||
inline PointPlacer::PointPlacer(const PointPlacer ©, const osg::CopyOp ©op)
|
||||
inline PointPlacer::PointPlacer(const PointPlacer& copy, const osg::CopyOp& copyop)
|
||||
: CenteredPlacer(copy, copyop)
|
||||
{
|
||||
}
|
||||
|
||||
inline void PointPlacer::place(Particle *P) const
|
||||
inline void PointPlacer::place(Particle* P) const
|
||||
{
|
||||
P->setPosition(getCenter());
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_PROGRAM_
|
||||
#define OSGPARTICLE_PROGRAM_ 1
|
||||
#ifndef OSGPARTICLE_PROGRAM
|
||||
#define OSGPARTICLE_PROGRAM 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
#include <osgParticle/ParticleProcessor>
|
||||
@ -32,19 +32,20 @@ namespace osgParticle
|
||||
through all particles in the linked particle system and modify them somehow
|
||||
(usually updating their velocity vector).
|
||||
*/
|
||||
class OSGPARTICLE_EXPORT Program: public ParticleProcessor {
|
||||
class OSGPARTICLE_EXPORT Program: public ParticleProcessor
|
||||
{
|
||||
public:
|
||||
Program();
|
||||
Program(const Program ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
Program(const Program& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "Program"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Program*>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "Program"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Program*>(obj) != 0; }
|
||||
virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
|
||||
|
||||
protected:
|
||||
virtual ~Program() {}
|
||||
Program &operator=(const Program &) { return *this; }
|
||||
Program& operator=(const Program&) { return *this; }
|
||||
|
||||
/// Implementation of <CODE>ParticleProcessor::process()</CODE>. Do not call this method by yourself.
|
||||
inline void process(double dt);
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_RADIALSHOOTER_
|
||||
#define OSGPARTICLE_RADIALSHOOTER_ 1
|
||||
#ifndef OSGPARTICLE_RADIAL_SHOOTER
|
||||
#define OSGPARTICLE_RADIAL_SHOOTER 1
|
||||
|
||||
#include <osgParticle/Shooter>
|
||||
#include <osgParticle/Particle>
|
||||
@ -36,150 +36,150 @@ namespace osgParticle
|
||||
class RadialShooter: public Shooter {
|
||||
public:
|
||||
inline RadialShooter();
|
||||
inline RadialShooter(const RadialShooter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline RadialShooter(const RadialShooter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, RadialShooter);
|
||||
|
||||
/// Get the range of possible values for <B>theta</B> angle.
|
||||
inline const rangef &getThetaRange() const;
|
||||
inline const rangef& getThetaRange() const;
|
||||
|
||||
/// Set the range of possible values for <B>theta</B> angle.
|
||||
inline void setThetaRange(const rangef &r);
|
||||
inline void setThetaRange(const rangef& r);
|
||||
|
||||
/// Set the range of possible values for <B>theta</B> angle.
|
||||
inline void setThetaRange(float r1, float r2);
|
||||
|
||||
/// Get the range of possible values for <B>phi</B> angle.
|
||||
inline const rangef &getPhiRange() const;
|
||||
inline const rangef& getPhiRange() const;
|
||||
|
||||
/// Set the range of possible values for <B>phi</B> angle.
|
||||
inline void setPhiRange(const rangef &r);
|
||||
inline void setPhiRange(const rangef& r);
|
||||
|
||||
/// Set the range of possible values for <B>phi</B> angle.
|
||||
inline void setPhiRange(float r1, float r2);
|
||||
|
||||
/// Get the range of possible values for initial speed of particles.
|
||||
inline const rangef &getInitialSpeedRange() const;
|
||||
inline const rangef& getInitialSpeedRange() const;
|
||||
|
||||
/// Set the range of possible values for initial speed of particles.
|
||||
inline void setInitialSpeedRange(const rangef &r);
|
||||
inline void setInitialSpeedRange(const rangef& r);
|
||||
|
||||
/// Set the range of possible values for initial speed of particles.
|
||||
inline void setInitialSpeedRange(float r1, float r2);
|
||||
|
||||
/// Get the range of possible values for initial rotational speed of particles.
|
||||
inline const rangev3 &getInitialRotationalSpeedRange() const;
|
||||
inline const rangev3& getInitialRotationalSpeedRange() const;
|
||||
|
||||
/// Set the range of possible values for initial rotational speed of particles.
|
||||
inline void setInitialRotationalSpeedRange(const rangev3 &r);
|
||||
inline void setInitialRotationalSpeedRange(const rangev3& r);
|
||||
|
||||
/// Set the range of possible values for initial rotational speed of particles.
|
||||
inline void setInitialRotationalSpeedRange(const osg::Vec3 &r1, const osg::Vec3 &r2);
|
||||
inline void setInitialRotationalSpeedRange(const osg::Vec3& r1, const osg::Vec3& r2);
|
||||
|
||||
/// Shoot a particle. Do not call this method manually.
|
||||
inline void shoot(Particle *P) const;
|
||||
inline void shoot(Particle* P) const;
|
||||
|
||||
protected:
|
||||
virtual ~RadialShooter() {}
|
||||
RadialShooter &operator=(const RadialShooter &) { return *this; }
|
||||
RadialShooter& operator=(const RadialShooter&) { return *this; }
|
||||
|
||||
private:
|
||||
rangef theta_range_;
|
||||
rangef phi_range_;
|
||||
rangef speed_range_;
|
||||
rangev3 rot_speed_range_;
|
||||
rangef _theta_range;
|
||||
rangef _phi_range;
|
||||
rangef _speed_range;
|
||||
rangev3 _rot_speed_range;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline RadialShooter::RadialShooter()
|
||||
: Shooter(),
|
||||
theta_range_(0, 0.5f*osg::PI_4),
|
||||
phi_range_(0, 2*osg::PI),
|
||||
speed_range_(10, 10),
|
||||
rot_speed_range_(osg::Vec3(0,0,0), osg::Vec3(0,0,0))
|
||||
_theta_range(0, 0.5f*osg::PI_4),
|
||||
_phi_range(0, 2*osg::PI),
|
||||
_speed_range(10, 10),
|
||||
_rot_speed_range(osg::Vec3(0,0,0), osg::Vec3(0,0,0))
|
||||
{
|
||||
}
|
||||
|
||||
inline RadialShooter::RadialShooter(const RadialShooter ©, const osg::CopyOp ©op)
|
||||
inline RadialShooter::RadialShooter(const RadialShooter& copy, const osg::CopyOp& copyop)
|
||||
: Shooter(copy, copyop),
|
||||
theta_range_(copy.theta_range_),
|
||||
phi_range_(copy.phi_range_),
|
||||
speed_range_(copy.speed_range_),
|
||||
rot_speed_range_(copy.rot_speed_range_)
|
||||
_theta_range(copy._theta_range),
|
||||
_phi_range(copy._phi_range),
|
||||
_speed_range(copy._speed_range),
|
||||
_rot_speed_range(copy._rot_speed_range)
|
||||
{
|
||||
}
|
||||
|
||||
inline const rangef &RadialShooter::getThetaRange() const
|
||||
inline const rangef& RadialShooter::getThetaRange() const
|
||||
{
|
||||
return theta_range_;
|
||||
return _theta_range;
|
||||
}
|
||||
|
||||
inline const rangef &RadialShooter::getPhiRange() const
|
||||
inline const rangef& RadialShooter::getPhiRange() const
|
||||
{
|
||||
return phi_range_;
|
||||
return _phi_range;
|
||||
}
|
||||
|
||||
inline const rangef &RadialShooter::getInitialSpeedRange() const
|
||||
inline const rangef& RadialShooter::getInitialSpeedRange() const
|
||||
{
|
||||
return speed_range_;
|
||||
return _speed_range;
|
||||
}
|
||||
|
||||
inline const rangev3 &RadialShooter::getInitialRotationalSpeedRange() const
|
||||
inline const rangev3& RadialShooter::getInitialRotationalSpeedRange() const
|
||||
{
|
||||
return rot_speed_range_;
|
||||
return _rot_speed_range;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setThetaRange(const rangef &r)
|
||||
inline void RadialShooter::setThetaRange(const rangef& r)
|
||||
{
|
||||
theta_range_ = r;
|
||||
_theta_range = r;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setThetaRange(float r1, float r2)
|
||||
{
|
||||
theta_range_.minimum = r1;
|
||||
theta_range_.maximum = r2;
|
||||
_theta_range.minimum = r1;
|
||||
_theta_range.maximum = r2;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setPhiRange(const rangef &r)
|
||||
inline void RadialShooter::setPhiRange(const rangef& r)
|
||||
{
|
||||
phi_range_ = r;
|
||||
_phi_range = r;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setPhiRange(float r1, float r2)
|
||||
{
|
||||
phi_range_.minimum = r1;
|
||||
phi_range_.maximum = r2;
|
||||
_phi_range.minimum = r1;
|
||||
_phi_range.maximum = r2;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setInitialSpeedRange(const rangef &r)
|
||||
inline void RadialShooter::setInitialSpeedRange(const rangef& r)
|
||||
{
|
||||
speed_range_ = r;
|
||||
_speed_range = r;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setInitialSpeedRange(float r1, float r2)
|
||||
{
|
||||
speed_range_.minimum = r1;
|
||||
speed_range_.maximum = r2;
|
||||
_speed_range.minimum = r1;
|
||||
_speed_range.maximum = r2;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setInitialRotationalSpeedRange(const rangev3 &r)
|
||||
inline void RadialShooter::setInitialRotationalSpeedRange(const rangev3& r)
|
||||
{
|
||||
rot_speed_range_ = r;
|
||||
_rot_speed_range = r;
|
||||
}
|
||||
|
||||
inline void RadialShooter::setInitialRotationalSpeedRange(const osg::Vec3 &r1, const osg::Vec3 &r2)
|
||||
inline void RadialShooter::setInitialRotationalSpeedRange(const osg::Vec3& r1, const osg::Vec3& r2)
|
||||
{
|
||||
rot_speed_range_.minimum = r1;
|
||||
rot_speed_range_.maximum = r2;
|
||||
_rot_speed_range.minimum = r1;
|
||||
_rot_speed_range.maximum = r2;
|
||||
}
|
||||
|
||||
inline void RadialShooter::shoot(Particle *P) const
|
||||
inline void RadialShooter::shoot(Particle* P) const
|
||||
{
|
||||
float theta = theta_range_.get_random();
|
||||
float phi = phi_range_.get_random();
|
||||
float speed = speed_range_.get_random();
|
||||
osg::Vec3 rot_speed = rot_speed_range_.get_random();
|
||||
float theta = _theta_range.get_random();
|
||||
float phi = _phi_range.get_random();
|
||||
float speed = _speed_range.get_random();
|
||||
osg::Vec3 rot_speed = _rot_speed_range.get_random();
|
||||
|
||||
P->setVelocity(osg::Vec3(
|
||||
speed * sinf(theta) * cosf(phi),
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_RANDOMRATECOUNTER_
|
||||
#define OSGPARTICLE_RANDOMRATECOUNTER_ 1
|
||||
#ifndef OSGPARTICLE_RANDOMRATE_COUNTER
|
||||
#define OSGPARTICLE_RANDOMRATE_COUNTER 1
|
||||
|
||||
#include <osgParticle/VariableRateCounter>
|
||||
|
||||
@ -26,7 +26,7 @@ namespace osgParticle
|
||||
class RandomRateCounter: public VariableRateCounter {
|
||||
public:
|
||||
inline RandomRateCounter();
|
||||
inline RandomRateCounter(const RandomRateCounter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline RandomRateCounter(const RandomRateCounter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, RandomRateCounter);
|
||||
|
||||
@ -36,26 +36,26 @@ namespace osgParticle
|
||||
protected:
|
||||
virtual ~RandomRateCounter() {}
|
||||
|
||||
mutable float np_;
|
||||
mutable float _np;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline RandomRateCounter::RandomRateCounter()
|
||||
: VariableRateCounter(), np_(0)
|
||||
: VariableRateCounter(), _np(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline RandomRateCounter::RandomRateCounter(const RandomRateCounter ©, const osg::CopyOp ©op)
|
||||
: VariableRateCounter(copy, copyop), np_(copy.np_)
|
||||
inline RandomRateCounter::RandomRateCounter(const RandomRateCounter& copy, const osg::CopyOp& copyop)
|
||||
: VariableRateCounter(copy, copyop), _np(copy._np)
|
||||
{
|
||||
}
|
||||
|
||||
inline int RandomRateCounter::numParticlesToCreate(double dt) const
|
||||
{
|
||||
np_ += dt * getRateRange().get_random();
|
||||
int n = static_cast<int>(np_);
|
||||
np_ -= n;
|
||||
_np += dt * getRateRange().get_random();
|
||||
int n = static_cast<int>(_np);
|
||||
_np -= n;
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_SECTORPLACER_
|
||||
#define OSGPARTICLE_SECTORPLACER_ 1
|
||||
#ifndef OSGPARTICLE_SECTOR_PLACER
|
||||
#define OSGPARTICLE_SECTOR_PLACER 1
|
||||
|
||||
#include <osgParticle/CenteredPlacer>
|
||||
#include <osgParticle/Particle>
|
||||
@ -36,22 +36,22 @@ namespace osgParticle
|
||||
class SectorPlacer: public CenteredPlacer {
|
||||
public:
|
||||
inline SectorPlacer();
|
||||
inline SectorPlacer(const SectorPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline SectorPlacer(const SectorPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
/// Get the range of possible values for radius.
|
||||
inline const rangef &getRadiusRange() const;
|
||||
inline const rangef& getRadiusRange() const;
|
||||
|
||||
/// Set the range of possible values for radius.
|
||||
inline void setRadiusRange(const rangef &r);
|
||||
inline void setRadiusRange(const rangef& r);
|
||||
|
||||
/// Set the range of possible values for radius.
|
||||
inline void setRadiusRange(float r1, float r2);
|
||||
|
||||
/// Get the range of possible values for the central angle.
|
||||
inline const rangef &getPhiRange() const;
|
||||
inline const rangef& getPhiRange() const;
|
||||
|
||||
/// Set the range of possible values for the central angle.
|
||||
inline void setPhiRange(const rangef &r);
|
||||
inline void setPhiRange(const rangef& r);
|
||||
|
||||
/// Set the range of possible values for the central angle.
|
||||
inline void setPhiRange(float r1, float r2);
|
||||
@ -59,65 +59,65 @@ namespace osgParticle
|
||||
META_Object(osgParticle, SectorPlacer);
|
||||
|
||||
/// Place a particle. Do not call it manually.
|
||||
inline void place(Particle *P) const;
|
||||
inline void place(Particle* P) const;
|
||||
|
||||
protected:
|
||||
virtual ~SectorPlacer() {}
|
||||
SectorPlacer &operator=(const SectorPlacer &) { return *this; }
|
||||
SectorPlacer& operator=(const SectorPlacer&) { return *this; }
|
||||
|
||||
private:
|
||||
rangef rad_range_;
|
||||
rangef phi_range_;
|
||||
rangef _rad_range;
|
||||
rangef _phi_range;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline SectorPlacer::SectorPlacer()
|
||||
: CenteredPlacer(), rad_range_(0, 1), phi_range_(0, osg::PI*2)
|
||||
: CenteredPlacer(), _rad_range(0, 1), _phi_range(0, osg::PI*2)
|
||||
{
|
||||
}
|
||||
|
||||
inline SectorPlacer::SectorPlacer(const SectorPlacer ©, const osg::CopyOp ©op)
|
||||
: CenteredPlacer(copy, copyop), rad_range_(copy.rad_range_), phi_range_(copy.phi_range_)
|
||||
inline SectorPlacer::SectorPlacer(const SectorPlacer& copy, const osg::CopyOp& copyop)
|
||||
: CenteredPlacer(copy, copyop), _rad_range(copy._rad_range), _phi_range(copy._phi_range)
|
||||
{
|
||||
}
|
||||
|
||||
inline const rangef &SectorPlacer::getRadiusRange() const
|
||||
inline const rangef& SectorPlacer::getRadiusRange() const
|
||||
{
|
||||
return rad_range_;
|
||||
return _rad_range;
|
||||
}
|
||||
|
||||
inline const rangef &SectorPlacer::getPhiRange() const
|
||||
inline const rangef& SectorPlacer::getPhiRange() const
|
||||
{
|
||||
return phi_range_;
|
||||
return _phi_range;
|
||||
}
|
||||
|
||||
inline void SectorPlacer::setRadiusRange(const rangef &r)
|
||||
inline void SectorPlacer::setRadiusRange(const rangef& r)
|
||||
{
|
||||
rad_range_ = r;
|
||||
_rad_range = r;
|
||||
}
|
||||
|
||||
inline void SectorPlacer::setRadiusRange(float r1, float r2)
|
||||
{
|
||||
rad_range_.minimum = r1;
|
||||
rad_range_.maximum = r2;
|
||||
_rad_range.minimum = r1;
|
||||
_rad_range.maximum = r2;
|
||||
}
|
||||
|
||||
inline void SectorPlacer::setPhiRange(const rangef &r)
|
||||
inline void SectorPlacer::setPhiRange(const rangef& r)
|
||||
{
|
||||
phi_range_ = r;
|
||||
_phi_range = r;
|
||||
}
|
||||
|
||||
inline void SectorPlacer::setPhiRange(float r1, float r2)
|
||||
{
|
||||
phi_range_.minimum = r1;
|
||||
phi_range_.maximum = r2;
|
||||
_phi_range.minimum = r1;
|
||||
_phi_range.maximum = r2;
|
||||
}
|
||||
|
||||
inline void SectorPlacer::place(Particle *P) const
|
||||
inline void SectorPlacer::place(Particle* P) const
|
||||
{
|
||||
float rad = rad_range_.get_random_sqrtf();
|
||||
float phi = phi_range_.get_random();
|
||||
float rad = _rad_range.get_random_sqrtf();
|
||||
float phi = _phi_range.get_random();
|
||||
|
||||
osg::Vec3 pos(
|
||||
getCenter().x() + rad * cosf(phi),
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_SEGMENTPLACER_
|
||||
#define OSGPARTICLE_SEGMENTPLACER_ 1
|
||||
#ifndef OSGPARTICLE_SEGMENT_PLACER
|
||||
#define OSGPARTICLE_SEGMENT_PLACER 1
|
||||
|
||||
#include <osgParticle/Placer>
|
||||
#include <osgParticle/Particle>
|
||||
@ -32,94 +32,94 @@ namespace osgParticle {
|
||||
class SegmentPlacer: public Placer {
|
||||
public:
|
||||
inline SegmentPlacer();
|
||||
inline SegmentPlacer(const SegmentPlacer ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline SegmentPlacer(const SegmentPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osgParticle, SegmentPlacer);
|
||||
|
||||
/// get vertex <B>A</B>.
|
||||
inline const osg::Vec3 &getVertexA() const;
|
||||
inline const osg::Vec3& getVertexA() const;
|
||||
|
||||
/// Set vertex <B>A</B> of the segment as a vector.
|
||||
inline void setVertexA(const osg::Vec3 &v);
|
||||
inline void setVertexA(const osg::Vec3& v);
|
||||
|
||||
/// Set vertex <B>A</B> of the segment as three floats.
|
||||
inline void setVertexA(float x, float y, float z);
|
||||
|
||||
/// get vertex <B>B</B>.
|
||||
inline const osg::Vec3 &getVertexB() const;
|
||||
inline const osg::Vec3& getVertexB() const;
|
||||
|
||||
/// Set vertex <B>B</B> of the segment as a vector.
|
||||
inline void setVertexB(const osg::Vec3 &v);
|
||||
inline void setVertexB(const osg::Vec3& v);
|
||||
|
||||
/// Set vertex <B>B</B> of the segment as three floats.
|
||||
inline void setVertexB(float x, float y, float z);
|
||||
|
||||
/// Set both vertices.
|
||||
inline void setSegment(const osg::Vec3 &A, const osg::Vec3 &B);
|
||||
inline void setSegment(const osg::Vec3& A, const osg::Vec3& B);
|
||||
|
||||
/// Place a particle. This method is called by <CODE>ModularEmitter</CODE>, do not call it manually.
|
||||
inline void place(Particle *P) const;
|
||||
inline void place(Particle* P) const;
|
||||
|
||||
protected:
|
||||
virtual ~SegmentPlacer() {}
|
||||
SegmentPlacer &operator=(const SegmentPlacer &) { return *this; }
|
||||
SegmentPlacer& operator=(const SegmentPlacer&) { return *this; }
|
||||
|
||||
private:
|
||||
osg::Vec3 A_;
|
||||
osg::Vec3 B_;
|
||||
osg::Vec3 _vertexA;
|
||||
osg::Vec3 _vertexB;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline SegmentPlacer::SegmentPlacer()
|
||||
: Placer(), A_(-1, 0, 0), B_(1, 0, 0)
|
||||
: Placer(), _vertexA(-1, 0, 0), _vertexB(1, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
inline SegmentPlacer::SegmentPlacer(const SegmentPlacer ©, const osg::CopyOp ©op)
|
||||
: Placer(copy, copyop), A_(copy.A_), B_(copy.B_)
|
||||
inline SegmentPlacer::SegmentPlacer(const SegmentPlacer& copy, const osg::CopyOp& copyop)
|
||||
: Placer(copy, copyop), _vertexA(copy._vertexA), _vertexB(copy._vertexB)
|
||||
{
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &SegmentPlacer::getVertexA() const
|
||||
inline const osg::Vec3& SegmentPlacer::getVertexA() const
|
||||
{
|
||||
return A_;
|
||||
return _vertexA;
|
||||
}
|
||||
|
||||
inline const osg::Vec3 &SegmentPlacer::getVertexB() const
|
||||
inline const osg::Vec3& SegmentPlacer::getVertexB() const
|
||||
{
|
||||
return B_;
|
||||
return _vertexB;
|
||||
}
|
||||
|
||||
inline void SegmentPlacer::setSegment(const osg::Vec3 &A, const osg::Vec3 &B)
|
||||
inline void SegmentPlacer::setSegment(const osg::Vec3& A, const osg::Vec3& B)
|
||||
{
|
||||
A_ = A;
|
||||
B_ = B;
|
||||
_vertexA = A;
|
||||
_vertexB = B;
|
||||
}
|
||||
|
||||
inline void SegmentPlacer::place(Particle *P) const
|
||||
inline void SegmentPlacer::place(Particle* P) const
|
||||
{
|
||||
P->setPosition(rangev3(A_, B_).get_random());
|
||||
P->setPosition(rangev3(_vertexA, _vertexB).get_random());
|
||||
}
|
||||
|
||||
inline void SegmentPlacer::setVertexA(const osg::Vec3 &v)
|
||||
inline void SegmentPlacer::setVertexA(const osg::Vec3& v)
|
||||
{
|
||||
A_ = v;
|
||||
_vertexA = v;
|
||||
}
|
||||
|
||||
inline void SegmentPlacer::setVertexA(float x, float y, float z)
|
||||
{
|
||||
A_.set(x, y, z);
|
||||
_vertexA.set(x, y, z);
|
||||
}
|
||||
|
||||
inline void SegmentPlacer::setVertexB(const osg::Vec3 &v)
|
||||
inline void SegmentPlacer::setVertexB(const osg::Vec3& v)
|
||||
{
|
||||
B_ = v;
|
||||
_vertexB = v;
|
||||
}
|
||||
|
||||
inline void SegmentPlacer::setVertexB(float x, float y, float z)
|
||||
{
|
||||
B_.set(x, y, z);
|
||||
_vertexB.set(x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_SHOOTER_
|
||||
#define OSGPARTICLE_SHOOTER_ 1
|
||||
#ifndef OSGPARTICLE_SHOOTER
|
||||
#define OSGPARTICLE_SHOOTER 1
|
||||
|
||||
#include <osg/CopyOp>
|
||||
#include <osg/Object>
|
||||
@ -26,20 +26,21 @@ namespace osgParticle
|
||||
/** An abstract base class used by ModularEmitter to "shoot" the particles after they have been placed.
|
||||
Descendants of this class must override the <CODE>shoot()</CODE> method.
|
||||
*/
|
||||
class Shooter: public osg::Object {
|
||||
class Shooter: public osg::Object
|
||||
{
|
||||
public:
|
||||
inline Shooter();
|
||||
inline Shooter(const Shooter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline Shooter(const Shooter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "Shooter"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Shooter *>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "Shooter"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Shooter *>(obj) != 0; }
|
||||
|
||||
/** Shoot a particle. Must be overriden by descendants.
|
||||
This method should only set the velocity vector of particle <CODE>P</CODE>, leaving other
|
||||
attributes unchanged.
|
||||
*/
|
||||
virtual void shoot(Particle *P) const = 0;
|
||||
virtual void shoot(Particle* P) const = 0;
|
||||
|
||||
protected:
|
||||
virtual ~Shooter() {}
|
||||
@ -53,7 +54,7 @@ namespace osgParticle
|
||||
{
|
||||
}
|
||||
|
||||
inline Shooter::Shooter(const Shooter ©, const osg::CopyOp ©op)
|
||||
inline Shooter::Shooter(const Shooter& copy, const osg::CopyOp& copyop)
|
||||
: osg::Object(copy, copyop)
|
||||
{
|
||||
}
|
||||
|
@ -11,8 +11,8 @@
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGPARTICLE_SmokeEffect
|
||||
#define OSGPARTICLE_SmokeEffect
|
||||
#ifndef OSGPARTICLE_SMOKEEFFECT
|
||||
#define OSGPARTICLE_SMOKEEFFECT
|
||||
|
||||
#include <osgParticle/ParticleEffect>
|
||||
#include <osgParticle/ModularEmitter>
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_VARIABLERATECOUNTER_
|
||||
#define OSGPARTICLE_VARIABLERATECOUNTER_ 1
|
||||
#ifndef OSGPARTICLE_VARIABLERATE_COUNTER
|
||||
#define OSGPARTICLE_VARIABLERATE_COUNTER 1
|
||||
|
||||
#include <osgParticle/Counter>
|
||||
#include <osgParticle/range>
|
||||
@ -27,48 +27,48 @@ namespace osgParticle
|
||||
class VariableRateCounter: public Counter {
|
||||
public:
|
||||
inline VariableRateCounter();
|
||||
inline VariableRateCounter(const VariableRateCounter ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
inline VariableRateCounter(const VariableRateCounter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *libraryName() const { return "osgParticle"; }
|
||||
virtual const char *className() const { return "VariableRateCounter"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const VariableRateCounter *>(obj) != 0; }
|
||||
virtual const char* libraryName() const { return "osgParticle"; }
|
||||
virtual const char* className() const { return "VariableRateCounter"; }
|
||||
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const VariableRateCounter *>(obj) != 0; }
|
||||
|
||||
inline const rangef &getRateRange() const;
|
||||
inline void setRateRange(const rangef &r);
|
||||
inline const rangef& getRateRange() const;
|
||||
inline void setRateRange(const rangef& r);
|
||||
inline void setRateRange(float minrange, float maxrange);
|
||||
|
||||
protected:
|
||||
virtual ~VariableRateCounter() {}
|
||||
|
||||
private:
|
||||
rangef rate_range_;
|
||||
rangef _rate_range;
|
||||
};
|
||||
|
||||
// INLINE FUNCTIONS
|
||||
|
||||
inline VariableRateCounter::VariableRateCounter()
|
||||
: Counter(), rate_range_(1, 1)
|
||||
: Counter(), _rate_range(1, 1)
|
||||
{
|
||||
}
|
||||
|
||||
inline VariableRateCounter::VariableRateCounter(const VariableRateCounter ©, const osg::CopyOp ©op)
|
||||
: Counter(copy, copyop), rate_range_(copy.rate_range_)
|
||||
inline VariableRateCounter::VariableRateCounter(const VariableRateCounter& copy, const osg::CopyOp& copyop)
|
||||
: Counter(copy, copyop), _rate_range(copy._rate_range)
|
||||
{
|
||||
}
|
||||
|
||||
inline const rangef &VariableRateCounter::getRateRange() const
|
||||
{
|
||||
return rate_range_;
|
||||
return _rate_range;
|
||||
}
|
||||
|
||||
inline void VariableRateCounter::setRateRange(const rangef &r)
|
||||
inline void VariableRateCounter::setRateRange(const rangef& r)
|
||||
{
|
||||
rate_range_ = r;
|
||||
_rate_range = r;
|
||||
}
|
||||
|
||||
inline void VariableRateCounter::setRateRange(float minrange, float maxrange)
|
||||
{
|
||||
rate_range_.set(minrange, maxrange);
|
||||
_rate_range.set(minrange, maxrange);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_VERSION_
|
||||
#define OSGPARTICLE_VERSION_ 1
|
||||
#ifndef OSGPARTICLE_VERSION
|
||||
#define OSGPARTICLE_VERSION 1
|
||||
|
||||
#include <osgParticle/Export>
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
//osgParticle - Copyright (C) 2002 Marco Jez
|
||||
|
||||
#ifndef OSGPARTICLE_RANGE_
|
||||
#define OSGPARTICLE_RANGE_ 1
|
||||
#ifndef OSGPARTICLE_RANGE
|
||||
#define OSGPARTICLE_RANGE 1
|
||||
|
||||
// include Export simply to disable Visual Studio silly warnings.
|
||||
#include <osgParticle/Export>
|
||||
@ -35,37 +35,38 @@ namespace osgParticle
|
||||
|
||||
/**
|
||||
A simple struct template useful to store ranges of values as min/max pairs.
|
||||
This struct template helps storing min/max ranges for values of any kind; class <CODE>T_</CODE> is
|
||||
the type of values to be stored, and it must support operations <CODE>T_ + T_</CODE>, <CODE>T_ - T_</CODE>,
|
||||
and <CODE>T_ * float</CODE>, otherwise the <CODE>get_random()</CODE> method will not compile.
|
||||
This struct template helps storing min/max ranges for values of any kind; class <CODE>ValueType</CODE> is
|
||||
the type of values to be stored, and it must support operations <CODE>ValueType + ValueType</CODE>, <CODE>ValueType - ValueType</CODE>,
|
||||
and <CODE>ValueType * float</CODE>, otherwise the <CODE>geValueTyperandom()</CODE> method will not compile.
|
||||
This struct could be extended to customize the random number generator (now it uses only
|
||||
<CODE>std::rand()</CODE>).
|
||||
*/
|
||||
template<class T_> struct range {
|
||||
template<class ValueType> struct range
|
||||
{
|
||||
|
||||
/// Lower bound.
|
||||
T_ minimum;
|
||||
ValueType minimum;
|
||||
|
||||
/// Higher bound.
|
||||
T_ maximum;
|
||||
ValueType maximum;
|
||||
|
||||
/// Construct the object by calling default constructors for min and max.
|
||||
range() : minimum(T_()), maximum(T_()) {}
|
||||
range() : minimum(ValueType()), maximum(ValueType()) {}
|
||||
|
||||
/// Construct and initialize min and max directly.
|
||||
range(const T_ &mn, const T_ &mx) : minimum(mn), maximum(mx) {}
|
||||
range(const ValueType& mn, const ValueType& mx) : minimum(mn), maximum(mx) {}
|
||||
|
||||
/// Set min and max.
|
||||
void set(const T_ &mn, const T_ &mx) { minimum = mn; maximum = mx; }
|
||||
void set(const ValueType& mn, const ValueType& mx) { minimum = mn; maximum = mx; }
|
||||
|
||||
/// Get a random value between min and max.
|
||||
T_ get_random() const
|
||||
ValueType get_random() const
|
||||
{
|
||||
return minimum + (maximum - minimum) * rand() / RAND_MAX;
|
||||
}
|
||||
|
||||
/// Get a random square root value between min and max.
|
||||
T_ get_random_sqrtf() const
|
||||
ValueType get_random_sqrtf() const
|
||||
{
|
||||
return minimum + (maximum - minimum) * sqrtf( static_cast<float>(rand()) / static_cast<float>(RAND_MAX) );
|
||||
}
|
||||
|
@ -5,13 +5,13 @@
|
||||
|
||||
osgParticle::Emitter::Emitter()
|
||||
: ParticleProcessor(),
|
||||
usedeftemp_(true)
|
||||
_usedeftemp(true)
|
||||
{
|
||||
}
|
||||
|
||||
osgParticle::Emitter::Emitter(const Emitter ©, const osg::CopyOp ©op)
|
||||
osgParticle::Emitter::Emitter(const Emitter& copy, const osg::CopyOp& copyop)
|
||||
: ParticleProcessor(copy, copyop),
|
||||
usedeftemp_(copy.usedeftemp_),
|
||||
ptemp_(copy.ptemp_)
|
||||
_usedeftemp(copy._usedeftemp),
|
||||
_ptemp(copy._ptemp)
|
||||
{
|
||||
}
|
||||
|
@ -6,39 +6,39 @@
|
||||
|
||||
osgParticle::FluidFrictionOperator::FluidFrictionOperator():
|
||||
Operator(),
|
||||
A_(0),
|
||||
B_(0),
|
||||
density_(0),
|
||||
viscosity_(0),
|
||||
ovr_rad_(0),
|
||||
current_program_(0)
|
||||
_coeff_A(0),
|
||||
_coeff_B(0),
|
||||
_density(0),
|
||||
_viscosity(0),
|
||||
_ovr_rad(0),
|
||||
_current_program(0)
|
||||
{
|
||||
setFluidToAir();
|
||||
}
|
||||
|
||||
osgParticle::FluidFrictionOperator::FluidFrictionOperator(const FluidFrictionOperator ©, const osg::CopyOp ©op)
|
||||
osgParticle::FluidFrictionOperator::FluidFrictionOperator(const FluidFrictionOperator& copy, const osg::CopyOp& copyop)
|
||||
: Operator(copy, copyop),
|
||||
A_(copy.A_),
|
||||
B_(copy.B_),
|
||||
density_(copy.density_),
|
||||
viscosity_(copy.viscosity_),
|
||||
ovr_rad_(copy.ovr_rad_),
|
||||
current_program_(0)
|
||||
_coeff_A(copy._coeff_A),
|
||||
_coeff_B(copy._coeff_B),
|
||||
_density(copy._density),
|
||||
_viscosity(copy._viscosity),
|
||||
_ovr_rad(copy._ovr_rad),
|
||||
_current_program(0)
|
||||
{
|
||||
}
|
||||
|
||||
void osgParticle::FluidFrictionOperator::operate(Particle *P, double dt)
|
||||
void osgParticle::FluidFrictionOperator::operate(Particle* P, double dt)
|
||||
{
|
||||
float r = (ovr_rad_ > 0)? ovr_rad_ : P->getRadius();
|
||||
float r = (_ovr_rad > 0)? _ovr_rad : P->getRadius();
|
||||
osg::Vec3 v = P->getVelocity()-_wind;
|
||||
|
||||
float vm = v.normalize();
|
||||
float R = A_ * r * vm + B_ * r * r * vm * vm;
|
||||
float R = _coeff_A * r * vm + _coeff_B * r * r * vm * vm;
|
||||
|
||||
osg::Vec3 Fr(-R * v.x(), -R * v.y(), -R * v.z());
|
||||
|
||||
if (current_program_->getReferenceFrame() == ModularProgram::RELATIVE_RF) {
|
||||
Fr = current_program_->rotateLocalToWorld(Fr);
|
||||
if (_current_program->getReferenceFrame() == ModularProgram::RELATIVE_RF) {
|
||||
Fr = _current_program->rotateLocalToWorld(Fr);
|
||||
}
|
||||
|
||||
// correct unwanted velocity increments
|
||||
|
@ -20,11 +20,11 @@ osgParticle::FluidProgram::FluidProgram(const FluidProgram& copy, const osg::Cop
|
||||
void osgParticle::FluidProgram::execute(double dt)
|
||||
{
|
||||
const float four_over_three = 4.0f/3.0f;
|
||||
ParticleSystem *ps = getParticleSystem();
|
||||
ParticleSystem* ps = getParticleSystem();
|
||||
int n = ps->numParticles();
|
||||
for (int i=0; i<n; ++i)
|
||||
{
|
||||
Particle *particle = ps->getParticle(i);
|
||||
Particle* particle = ps->getParticle(i);
|
||||
if (particle->isAlive())
|
||||
{
|
||||
float radius = particle->getRadius();
|
||||
|
@ -3,28 +3,28 @@
|
||||
|
||||
osgParticle::ModularEmitter::ModularEmitter()
|
||||
: Emitter(),
|
||||
counter_(new RandomRateCounter),
|
||||
placer_(new PointPlacer),
|
||||
shooter_(new RadialShooter)
|
||||
_counter(new RandomRateCounter),
|
||||
_placer(new PointPlacer),
|
||||
_shooter(new RadialShooter)
|
||||
{
|
||||
}
|
||||
|
||||
osgParticle::ModularEmitter::ModularEmitter(const ModularEmitter ©, const osg::CopyOp ©op)
|
||||
osgParticle::ModularEmitter::ModularEmitter(const ModularEmitter& copy, const osg::CopyOp& copyop)
|
||||
: Emitter(copy, copyop),
|
||||
counter_(static_cast<Counter *>(copyop(copy.counter_.get()))),
|
||||
placer_(static_cast<Placer *>(copyop(copy.placer_.get()))),
|
||||
shooter_(static_cast<Shooter *>(copyop(copy.shooter_.get())))
|
||||
_counter(static_cast<Counter *>(copyop(copy._counter.get()))),
|
||||
_placer(static_cast<Placer *>(copyop(copy._placer.get()))),
|
||||
_shooter(static_cast<Shooter *>(copyop(copy._shooter.get())))
|
||||
{
|
||||
}
|
||||
|
||||
void osgParticle::ModularEmitter::emit(double dt)
|
||||
{
|
||||
int n = counter_->numParticlesToCreate(dt);
|
||||
int n = _counter->numParticlesToCreate(dt);
|
||||
for (int i=0; i<n; ++i) {
|
||||
Particle *P = getParticleSystem()->createParticle(getUseDefaultTemplate()? 0: &getParticleTemplate());
|
||||
Particle* P = getParticleSystem()->createParticle(getUseDefaultTemplate()? 0: &getParticleTemplate());
|
||||
if (P) {
|
||||
placer_->place(P);
|
||||
shooter_->shoot(P);
|
||||
_placer->place(P);
|
||||
_shooter->shoot(P);
|
||||
if (getReferenceFrame() == RELATIVE_RF) {
|
||||
P->transformPositionVelocity(getLocalToWorldMatrix());
|
||||
}
|
||||
|
@ -8,26 +8,26 @@ osgParticle::ModularProgram::ModularProgram()
|
||||
{
|
||||
}
|
||||
|
||||
osgParticle::ModularProgram::ModularProgram(const ModularProgram ©, const osg::CopyOp ©op)
|
||||
osgParticle::ModularProgram::ModularProgram(const ModularProgram& copy, const osg::CopyOp& copyop)
|
||||
: Program(copy, copyop)
|
||||
{
|
||||
Operator_vector::const_iterator ci;
|
||||
for (ci=copy.operators_.begin(); ci!=copy.operators_.end(); ++ci) {
|
||||
operators_.push_back(static_cast<Operator *>(copyop(ci->get())));
|
||||
for (ci=copy._operators.begin(); ci!=copy._operators.end(); ++ci) {
|
||||
_operators.push_back(static_cast<Operator* >(copyop(ci->get())));
|
||||
}
|
||||
}
|
||||
|
||||
void osgParticle::ModularProgram::execute(double dt)
|
||||
{
|
||||
Operator_vector::iterator ci;
|
||||
Operator_vector::iterator ci_end = operators_.end();
|
||||
Operator_vector::iterator ci_end = _operators.end();
|
||||
|
||||
ParticleSystem *ps = getParticleSystem();
|
||||
for (ci=operators_.begin(); ci!=ci_end; ++ci) {
|
||||
ParticleSystem* ps = getParticleSystem();
|
||||
for (ci=_operators.begin(); ci!=ci_end; ++ci) {
|
||||
(*ci)->beginOperate(this);
|
||||
int n = ps->numParticles();
|
||||
for (int i=0; i<n; ++i) {
|
||||
Particle *P = ps->getParticle(i);
|
||||
Particle* P = ps->getParticle(i);
|
||||
if (P->isAlive() && (*ci)->isEnabled()) {
|
||||
(*ci)->operate(P, dt);
|
||||
}
|
||||
|
@ -5,46 +5,51 @@
|
||||
#include <osg/Vec3>
|
||||
|
||||
osgParticle::MultiSegmentPlacer::MultiSegmentPlacer()
|
||||
: Placer(), total_length_(0)
|
||||
: Placer(), _total_length(0)
|
||||
{
|
||||
}
|
||||
|
||||
osgParticle::MultiSegmentPlacer::MultiSegmentPlacer(const MultiSegmentPlacer ©, const osg::CopyOp ©op)
|
||||
: Placer(copy, copyop), vx_(copy.vx_), total_length_(copy.total_length_)
|
||||
osgParticle::MultiSegmentPlacer::MultiSegmentPlacer(const MultiSegmentPlacer& copy, const osg::CopyOp& copyop)
|
||||
: Placer(copy, copyop), _vx(copy._vx), _total_length(copy._total_length)
|
||||
{
|
||||
}
|
||||
|
||||
void osgParticle::MultiSegmentPlacer::recompute_length()
|
||||
{
|
||||
Vertex_vector::iterator i;
|
||||
Vertex_vector::iterator i0 = vx_.begin();
|
||||
Vertex_vector::iterator i0 = _vx.begin();
|
||||
|
||||
total_length_ = 0;
|
||||
for (i=vx_.begin(); i!=vx_.end(); ++i) {
|
||||
total_length_ += (i->first - i0->first).length();
|
||||
i->second = total_length_;
|
||||
_total_length = 0;
|
||||
for (i=_vx.begin(); i!=_vx.end(); ++i)
|
||||
{
|
||||
_total_length += (i->first - i0->first).length();
|
||||
i->second = _total_length;
|
||||
i0 = i;
|
||||
}
|
||||
}
|
||||
|
||||
void osgParticle::MultiSegmentPlacer::place(Particle *P) const
|
||||
void osgParticle::MultiSegmentPlacer::place(Particle* P) const
|
||||
{
|
||||
if (vx_.size() >= 2) {
|
||||
float x = rangef(0, total_length_).get_random();
|
||||
if (_vx.size() >= 2) {
|
||||
float x = rangef(0, _total_length).get_random();
|
||||
|
||||
Vertex_vector::const_iterator i;
|
||||
Vertex_vector::const_iterator i0 = vx_.begin();
|
||||
const Vertex_vector::const_iterator vend = vx_.end();
|
||||
Vertex_vector::const_iterator i0 = _vx.begin();
|
||||
const Vertex_vector::const_iterator vend = _vx.end();
|
||||
|
||||
for (i=vx_.begin(); i!=vend; ++i) {
|
||||
if (x <= i->second) {
|
||||
for (i=_vx.begin(); i!=vend; ++i)
|
||||
{
|
||||
if (x <= i->second)
|
||||
{
|
||||
float t = (x - i0->second) / (i->second - i0->second);
|
||||
P->setPosition(i0->first + (i->first - i0->first) * t);
|
||||
return;
|
||||
}
|
||||
i0 = i;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
osg::notify(osg::WARN) << "this MultiSegmentPlacer has less than 2 vertices\n";
|
||||
}
|
||||
}
|
||||
|
@ -20,34 +20,34 @@ namespace
|
||||
}
|
||||
|
||||
osgParticle::Particle::Particle()
|
||||
: shape_(QUAD),
|
||||
sr_(0.2f, 0.2f),
|
||||
ar_(1, 0),
|
||||
cr_(osg::Vec4(1, 1, 1, 1), osg::Vec4(1, 1, 1, 1)),
|
||||
si_(new LinearInterpolator),
|
||||
ai_(new LinearInterpolator),
|
||||
ci_(new LinearInterpolator),
|
||||
alive_(true),
|
||||
mustdie_(false),
|
||||
lifetime_(2),
|
||||
radius_(0.2f),
|
||||
mass_(0.1f),
|
||||
massinv_(10.0f),
|
||||
prev_pos_(0, 0, 0),
|
||||
position_(0, 0, 0),
|
||||
velocity_(0, 0, 0),
|
||||
prev_angle_(0, 0, 0),
|
||||
angle_(0, 0, 0),
|
||||
angular_vel_(0, 0, 0),
|
||||
t0_(0),
|
||||
current_size_(0),
|
||||
current_alpha_(0),
|
||||
s_tile_(1.0f),
|
||||
t_tile_(1.0f),
|
||||
num_tile_(1),
|
||||
cur_tile_(-1),
|
||||
s_coord_(0.0f),
|
||||
t_coord_(0.0f)
|
||||
: _shape(QUAD),
|
||||
_sr(0.2f, 0.2f),
|
||||
_ar(1, 0),
|
||||
_cr(osg::Vec4(1, 1, 1, 1), osg::Vec4(1, 1, 1, 1)),
|
||||
_si(new LinearInterpolator),
|
||||
_ai(new LinearInterpolator),
|
||||
_ci(new LinearInterpolator),
|
||||
_alive(true),
|
||||
_mustdie(false),
|
||||
_lifeTime(2),
|
||||
_radius(0.2f),
|
||||
_mass(0.1f),
|
||||
_massinv(10.0f),
|
||||
_prev_pos(0, 0, 0),
|
||||
_position(0, 0, 0),
|
||||
_velocity(0, 0, 0),
|
||||
_prev_angle(0, 0, 0),
|
||||
_angle(0, 0, 0),
|
||||
_angul_arvel(0, 0, 0),
|
||||
_t0(0),
|
||||
_current_size(0),
|
||||
_current_alpha(0),
|
||||
_s_tile(1.0f),
|
||||
_t_tile(1.0f),
|
||||
_num_tile(1),
|
||||
_cur_tile(-1),
|
||||
_s_coord(0.0f),
|
||||
_t_coord(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
@ -55,97 +55,97 @@ bool osgParticle::Particle::update(double dt)
|
||||
{
|
||||
// this method should return false when the particle dies;
|
||||
// so, if we were instructed to die, do it now and return.
|
||||
if (mustdie_) {
|
||||
alive_ = false;
|
||||
if (_mustdie) {
|
||||
_alive = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
double x = 0;
|
||||
|
||||
// if we don't live forever, compute our normalized age.
|
||||
if (lifetime_ > 0) {
|
||||
x = t0_ / lifetime_;
|
||||
if (_lifeTime > 0) {
|
||||
x = _t0 / _lifeTime;
|
||||
}
|
||||
|
||||
t0_ += dt;
|
||||
_t0 += dt;
|
||||
|
||||
// if our age is over the lifetime limit, then die and return.
|
||||
if (x > 1) {
|
||||
alive_ = false;
|
||||
_alive = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Compute the current texture tile based on our normalized age
|
||||
int currentTile = static_cast<int>(x * num_tile_);
|
||||
|
||||
//If the current texture tile is different from previous, then compute new texture coords
|
||||
if(currentTile != cur_tile_) {
|
||||
cur_tile_ = currentTile;
|
||||
s_coord_ = s_tile_ * fmod(cur_tile_ , 1.0 / s_tile_);
|
||||
t_coord_ = 1.0 - t_tile_ * (static_cast<int>(cur_tile_ * t_tile_) + 1);
|
||||
}
|
||||
|
||||
//Compute the current texture tile based on our normalized age
|
||||
int currentTile = static_cast<int>(x * _num_tile);
|
||||
|
||||
//If the current texture tile is different from previous, then compute new texture coords
|
||||
if(currentTile != _cur_tile) {
|
||||
_cur_tile = currentTile;
|
||||
_s_coord = _s_tile * fmod(_cur_tile , 1.0 / _s_tile);
|
||||
_t_coord = 1.0 - _t_tile * (static_cast<int>(_cur_tile * _t_tile) + 1);
|
||||
}
|
||||
|
||||
// compute the current values for size, alpha and color.
|
||||
if (lifetime_ <= 0) {
|
||||
if (dt == t0_) {
|
||||
current_size_ = sr_.get_random();
|
||||
current_alpha_ = ar_.get_random();
|
||||
current_color_ = cr_.get_random();
|
||||
if (_lifeTime <= 0) {
|
||||
if (dt == _t0) {
|
||||
_current_size = _sr.get_random();
|
||||
_current_alpha = _ar.get_random();
|
||||
_current_color = _cr.get_random();
|
||||
}
|
||||
} else {
|
||||
current_size_ = si_.get()->interpolate(x, sr_);
|
||||
current_alpha_ = ai_.get()->interpolate(x, ar_);
|
||||
current_color_ = ci_.get()->interpolate(x, cr_);
|
||||
_current_size = _si.get()->interpolate(x, _sr);
|
||||
_current_alpha = _ai.get()->interpolate(x, _ar);
|
||||
_current_color = _ci.get()->interpolate(x, _cr);
|
||||
}
|
||||
|
||||
// update position
|
||||
prev_pos_ = position_;
|
||||
position_ += velocity_ * dt;
|
||||
_prev_pos = _position;
|
||||
_position += _velocity * dt;
|
||||
|
||||
// update angle
|
||||
prev_angle_ = angle_;
|
||||
angle_ += angular_vel_ * dt;
|
||||
_prev_angle = _angle;
|
||||
_angle += _angul_arvel * dt;
|
||||
|
||||
if (angle_.x() > osg::PI*2) angle_.x() -= osg::PI*2;
|
||||
if (angle_.x() < -osg::PI*2) angle_.x() += osg::PI*2;
|
||||
if (angle_.y() > osg::PI*2) angle_.y() -= osg::PI*2;
|
||||
if (angle_.y() < -osg::PI*2) angle_.y() += osg::PI*2;
|
||||
if (angle_.z() > osg::PI*2) angle_.z() -= osg::PI*2;
|
||||
if (angle_.z() < -osg::PI*2) angle_.z() += osg::PI*2;
|
||||
if (_angle.x() > osg::PI*2) _angle.x() -= osg::PI*2;
|
||||
if (_angle.x() < -osg::PI*2) _angle.x() += osg::PI*2;
|
||||
if (_angle.y() > osg::PI*2) _angle.y() -= osg::PI*2;
|
||||
if (_angle.y() < -osg::PI*2) _angle.y() += osg::PI*2;
|
||||
if (_angle.z() > osg::PI*2) _angle.z() -= osg::PI*2;
|
||||
if (_angle.z() < -osg::PI*2) _angle.z() += osg::PI*2;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void osgParticle::Particle::render(const osg::Vec3 &xpos, const osg::Vec3 &px, const osg::Vec3 &py, float scale) const
|
||||
void osgParticle::Particle::render(const osg::Vec3& xpos, const osg::Vec3& px, const osg::Vec3& py, float scale) const
|
||||
{
|
||||
glColor4f( current_color_.x(),
|
||||
current_color_.y(),
|
||||
current_color_.z(),
|
||||
current_color_.w() * current_alpha_);
|
||||
glColor4f( _current_color.x(),
|
||||
_current_color.y(),
|
||||
_current_color.z(),
|
||||
_current_color.w() * _current_alpha);
|
||||
|
||||
osg::Matrix R;
|
||||
R.makeRotate(
|
||||
angle_.x(), osg::Vec3(1, 0, 0),
|
||||
angle_.y(), osg::Vec3(0, 1, 0),
|
||||
angle_.z(), osg::Vec3(0, 0, 1));
|
||||
_angle.x(), osg::Vec3(1, 0, 0),
|
||||
_angle.y(), osg::Vec3(0, 1, 0),
|
||||
_angle.z(), osg::Vec3(0, 0, 1));
|
||||
|
||||
osg::Vec3 p1(px * current_size_ * scale);
|
||||
osg::Vec3 p2(py * current_size_ * scale);
|
||||
osg::Vec3 p1(px * _current_size * scale);
|
||||
osg::Vec3 p2(py * _current_size * scale);
|
||||
|
||||
switch (shape_)
|
||||
switch (_shape)
|
||||
{
|
||||
case POINT:
|
||||
glVertex3f(xpos.x(), xpos.y(), xpos.z());
|
||||
break;
|
||||
|
||||
case QUAD:
|
||||
glTexCoord2f(s_coord_, t_coord_);
|
||||
glTexCoord2f(_s_coord, _t_coord);
|
||||
glVertex3fv((xpos-(p1+p2)*R).ptr());
|
||||
glTexCoord2f(s_coord_+s_tile_, t_coord_);
|
||||
glTexCoord2f(_s_coord+_s_tile, _t_coord);
|
||||
glVertex3fv((xpos+(p1-p2)*R).ptr());
|
||||
glTexCoord2f(s_coord_+s_tile_, t_coord_+t_tile_);
|
||||
glTexCoord2f(_s_coord+_s_tile, _t_coord+_t_tile);
|
||||
glVertex3fv((xpos+(p1+p2)*R).ptr());
|
||||
glTexCoord2f(s_coord_, t_coord_+t_tile_);
|
||||
glTexCoord2f(_s_coord, _t_coord+_t_tile);
|
||||
glVertex3fv((xpos-(p1-p2)*R).ptr());
|
||||
break;
|
||||
|
||||
@ -155,13 +155,13 @@ void osgParticle::Particle::render(const osg::Vec3 &xpos, const osg::Vec3 &px, c
|
||||
glMultMatrix(R.ptr());
|
||||
// we must glBegin() and glEnd() here, because each particle is a single strip
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(s_coord_+s_tile_, t_coord_+t_tile_);
|
||||
glTexCoord2f(_s_coord+_s_tile, _t_coord+_t_tile);
|
||||
glVertex3fv((p1+p2).ptr());
|
||||
glTexCoord2f(s_coord_, t_coord_+t_tile_);
|
||||
glTexCoord2f(_s_coord, _t_coord+_t_tile);
|
||||
glVertex3fv((-p1+p2).ptr());
|
||||
glTexCoord2f(s_coord_+s_tile_, t_coord_);
|
||||
glTexCoord2f(_s_coord+_s_tile, _t_coord);
|
||||
glVertex3fv((p1-p2).ptr());
|
||||
glTexCoord2f(s_coord_, t_coord_);
|
||||
glTexCoord2f(_s_coord, _t_coord);
|
||||
glVertex3fv((-p1-p2).ptr());
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
@ -173,21 +173,21 @@ void osgParticle::Particle::render(const osg::Vec3 &xpos, const osg::Vec3 &px, c
|
||||
glMultMatrix(R.ptr());
|
||||
// we must glBegin() and glEnd() here, because each particle is a single fan
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glTexCoord2f(s_coord_ + s_tile_ * 0.5f, t_coord_ + t_tile_ * 0.5f);
|
||||
glTexCoord2f(_s_coord + _s_tile * 0.5f, _t_coord + _t_tile * 0.5f);
|
||||
glVertex3f(0,0,0);
|
||||
glTexCoord2f(s_coord_ + s_tile_ * hex_texcoord_x1, t_coord_ + t_tile_ * hex_texcoord_y1);
|
||||
glTexCoord2f(_s_coord + _s_tile * hex_texcoord_x1, _t_coord + _t_tile * hex_texcoord_y1);
|
||||
glVertex3fv((p1*cosPI3+p2*sinPI3).ptr());
|
||||
glTexCoord2f(s_coord_ + s_tile_ * hex_texcoord_x2, t_coord_ + t_tile_ * hex_texcoord_y1);
|
||||
glTexCoord2f(_s_coord + _s_tile * hex_texcoord_x2, _t_coord + _t_tile * hex_texcoord_y1);
|
||||
glVertex3fv((-p1*cosPI3+p2*sinPI3).ptr());
|
||||
glTexCoord2f(s_coord_, t_coord_ + t_tile_ * 0.5f);
|
||||
glTexCoord2f(_s_coord, _t_coord + _t_tile * 0.5f);
|
||||
glVertex3fv((-p1).ptr());
|
||||
glTexCoord2f(s_coord_ + s_tile_ * hex_texcoord_x2, t_coord_ + t_tile_ * hex_texcoord_y2);
|
||||
glTexCoord2f(_s_coord + _s_tile * hex_texcoord_x2, _t_coord + _t_tile * hex_texcoord_y2);
|
||||
glVertex3fv((-p1*cosPI3-p2*sinPI3).ptr());
|
||||
glTexCoord2f(s_coord_ + s_tile_ * hex_texcoord_x1, t_coord_ + t_tile_ * hex_texcoord_y2);
|
||||
glTexCoord2f(_s_coord + _s_tile * hex_texcoord_x1, _t_coord + _t_tile * hex_texcoord_y2);
|
||||
glVertex3fv((p1*cosPI3-p2*sinPI3).ptr());
|
||||
glTexCoord2f(s_coord_ + s_tile_, t_coord_ + t_tile_ * 0.5f);
|
||||
glTexCoord2f(_s_coord + _s_tile, _t_coord + _t_tile * 0.5f);
|
||||
glVertex3fv((p1).ptr());
|
||||
glTexCoord2f(s_coord_ + s_tile_ * hex_texcoord_x1, t_coord_ + t_tile_ * hex_texcoord_y1);
|
||||
glTexCoord2f(_s_coord + _s_tile * hex_texcoord_x1, _t_coord + _t_tile * hex_texcoord_y1);
|
||||
glVertex3fv((p1*cosPI3+p2*sinPI3).ptr());
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
@ -197,9 +197,9 @@ void osgParticle::Particle::render(const osg::Vec3 &xpos, const osg::Vec3 &px, c
|
||||
{
|
||||
// Get the normalized direction of the particle, to be used in the
|
||||
// calculation of one of the linesegment endpoints.
|
||||
float vl = velocity_.length();
|
||||
float vl = _velocity.length();
|
||||
if (vl != 0) {
|
||||
osg::Vec3 v = velocity_ * current_size_ * scale / vl;
|
||||
osg::Vec3 v = _velocity * _current_size * scale / vl;
|
||||
|
||||
glTexCoord1f(0);
|
||||
glVertex3f(xpos.x(), xpos.y(), xpos.z());
|
||||
|
@ -13,49 +13,49 @@ using namespace osg;
|
||||
|
||||
osgParticle::ParticleProcessor::ParticleProcessor()
|
||||
: osg::Node(),
|
||||
rf_(RELATIVE_RF),
|
||||
enabled_(true),
|
||||
t0_(-1),
|
||||
ps_(0),
|
||||
need_ltw_matrix_(false),
|
||||
need_wtl_matrix_(false),
|
||||
current_nodevisitor_(0),
|
||||
endless_(true),
|
||||
lifeTime_(0.0),
|
||||
startTime_(0.0),
|
||||
currentTime_(0.0),
|
||||
resetTime_(0.0)
|
||||
_rf(RELATIVE_RF),
|
||||
_enabled(true),
|
||||
_t0(-1),
|
||||
_ps(0),
|
||||
_need_ltw_matrix(false),
|
||||
_need_wtl_matrix(false),
|
||||
_current_nodevisitor(0),
|
||||
_endless(true),
|
||||
_lifeTime(0.0),
|
||||
_startTime(0.0),
|
||||
_currentTime(0.0),
|
||||
_resetTime(0.0)
|
||||
{
|
||||
setCullingActive(false);
|
||||
}
|
||||
|
||||
osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor ©, const osg::CopyOp ©op)
|
||||
osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor& copy, const osg::CopyOp& copyop)
|
||||
: osg::Node(copy, copyop),
|
||||
rf_(copy.rf_),
|
||||
enabled_(copy.enabled_),
|
||||
t0_(copy.t0_),
|
||||
ps_(static_cast<ParticleSystem *>(copyop(copy.ps_.get()))),
|
||||
need_ltw_matrix_(copy.need_ltw_matrix_),
|
||||
need_wtl_matrix_(copy.need_wtl_matrix_),
|
||||
current_nodevisitor_(0),
|
||||
endless_(copy.endless_),
|
||||
lifeTime_(copy.lifeTime_),
|
||||
startTime_(copy.startTime_),
|
||||
currentTime_(copy.currentTime_),
|
||||
resetTime_(copy.resetTime_)
|
||||
_rf(copy._rf),
|
||||
_enabled(copy._enabled),
|
||||
_t0(copy._t0),
|
||||
_ps(static_cast<ParticleSystem* >(copyop(copy._ps.get()))),
|
||||
_need_ltw_matrix(copy._need_ltw_matrix),
|
||||
_need_wtl_matrix(copy._need_wtl_matrix),
|
||||
_current_nodevisitor(0),
|
||||
_endless(copy._endless),
|
||||
_lifeTime(copy._lifeTime),
|
||||
_startTime(copy._startTime),
|
||||
_currentTime(copy._currentTime),
|
||||
_resetTime(copy._resetTime)
|
||||
{
|
||||
}
|
||||
|
||||
void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv)
|
||||
void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
// typecast the NodeVisitor to CullVisitor
|
||||
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
|
||||
// continue only if the visitor actually is a cull visitor
|
||||
if (cv) {
|
||||
|
||||
// continue only if the particle system is valid
|
||||
if (ps_.valid())
|
||||
if (_ps.valid())
|
||||
{
|
||||
|
||||
if (nv.getFrameStamp())
|
||||
@ -65,42 +65,45 @@ void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor &nv)
|
||||
double t = nv.getFrameStamp()->getReferenceTime();
|
||||
|
||||
// reset this processor if we've reached the reset point
|
||||
if ((currentTime_ >= resetTime_) && (resetTime_ > 0)) {
|
||||
currentTime_ = 0;
|
||||
t0_ = -1;
|
||||
if ((_currentTime >= _resetTime) && (_resetTime > 0))
|
||||
{
|
||||
_currentTime = 0;
|
||||
_t0 = -1;
|
||||
}
|
||||
|
||||
// skip if we haven't initialized t0_ yet
|
||||
if (t0_ != -1) {
|
||||
// skip if we haven't initialized _t0 yet
|
||||
if (_t0 != -1)
|
||||
{
|
||||
|
||||
// check whether the processor is alive
|
||||
bool alive = false;
|
||||
if (currentTime_ >= startTime_) {
|
||||
if (endless_ || (currentTime_ < (startTime_ + lifeTime_)))
|
||||
if (_currentTime >= _startTime)
|
||||
{
|
||||
if (_endless || (_currentTime < (_startTime + _lifeTime)))
|
||||
alive = true;
|
||||
}
|
||||
|
||||
// update current time
|
||||
currentTime_ += t - t0_;
|
||||
_currentTime += t - _t0;
|
||||
|
||||
// process only if the particle system is not frozen/culled
|
||||
if (alive &&
|
||||
enabled_ &&
|
||||
!ps_->isFrozen() &&
|
||||
(ps_->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !ps_->getFreezeOnCull())) {
|
||||
|
||||
_enabled &&
|
||||
!_ps->isFrozen() &&
|
||||
(_ps->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !_ps->getFreezeOnCull()))
|
||||
{
|
||||
// initialize matrix flags
|
||||
need_ltw_matrix_ = true;
|
||||
need_wtl_matrix_ = true;
|
||||
current_nodevisitor_ = &nv;
|
||||
_need_ltw_matrix = true;
|
||||
_need_wtl_matrix = true;
|
||||
_current_nodevisitor = &nv;
|
||||
|
||||
// do some process (unimplemented in this base class)
|
||||
process(t - t0_);
|
||||
process(t - _t0);
|
||||
}
|
||||
}
|
||||
|
||||
// update t0_
|
||||
t0_ = t;
|
||||
// update _t0
|
||||
_t0 = t;
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -18,44 +18,44 @@
|
||||
|
||||
osgParticle::ParticleSystem::ParticleSystem()
|
||||
: osg::Drawable(),
|
||||
def_bbox_(osg::Vec3(-10, -10, -10), osg::Vec3(10, 10, 10)),
|
||||
alignment_(BILLBOARD),
|
||||
align_X_axis_(1, 0, 0),
|
||||
align_Y_axis_(0, 1, 0),
|
||||
doublepass_(false),
|
||||
frozen_(false),
|
||||
bmin_(0, 0, 0),
|
||||
bmax_(0, 0, 0),
|
||||
reset_bounds_flag_(false),
|
||||
bounds_computed_(false),
|
||||
def_ptemp_(Particle()),
|
||||
last_frame_(0),
|
||||
freeze_on_cull_(false),
|
||||
detail_(1),
|
||||
draw_count_(0)
|
||||
_def_bbox(osg::Vec3(-10, -10, -10), osg::Vec3(10, 10, 10)),
|
||||
_alignment(BILLBOARD),
|
||||
_align_X_axis(1, 0, 0),
|
||||
_align_Y_axis(0, 1, 0),
|
||||
_doublepass(false),
|
||||
_frozen(false),
|
||||
_bmin(0, 0, 0),
|
||||
_bmax(0, 0, 0),
|
||||
_reset_bounds_flag(false),
|
||||
_bounds_computed(false),
|
||||
_def_ptemp(Particle()),
|
||||
_last_frame(0),
|
||||
_freeze_on_cull(false),
|
||||
_detail(1),
|
||||
_draw_count(0)
|
||||
{
|
||||
// we don't support display lists because particle systems
|
||||
// are dynamic, and they always changes between frames
|
||||
setSupportsDisplayList(false);
|
||||
}
|
||||
|
||||
osgParticle::ParticleSystem::ParticleSystem(const ParticleSystem ©, const osg::CopyOp ©op)
|
||||
osgParticle::ParticleSystem::ParticleSystem(const ParticleSystem& copy, const osg::CopyOp& copyop)
|
||||
: osg::Drawable(copy, copyop),
|
||||
def_bbox_(copy.def_bbox_),
|
||||
alignment_(copy.alignment_),
|
||||
align_X_axis_(copy.align_X_axis_),
|
||||
align_Y_axis_(copy.align_Y_axis_),
|
||||
doublepass_(copy.doublepass_),
|
||||
frozen_(copy.frozen_),
|
||||
bmin_(copy.bmin_),
|
||||
bmax_(copy.bmax_),
|
||||
reset_bounds_flag_(copy.reset_bounds_flag_),
|
||||
bounds_computed_(copy.bounds_computed_),
|
||||
def_ptemp_(copy.def_ptemp_),
|
||||
last_frame_(copy.last_frame_),
|
||||
freeze_on_cull_(copy.freeze_on_cull_),
|
||||
detail_(copy.detail_),
|
||||
draw_count_(0)
|
||||
_def_bbox(copy._def_bbox),
|
||||
_alignment(copy._alignment),
|
||||
_align_X_axis(copy._align_X_axis),
|
||||
_align_Y_axis(copy._align_Y_axis),
|
||||
_doublepass(copy._doublepass),
|
||||
_frozen(copy._frozen),
|
||||
_bmin(copy._bmin),
|
||||
_bmax(copy._bmax),
|
||||
_reset_bounds_flag(copy._reset_bounds_flag),
|
||||
_bounds_computed(copy._bounds_computed),
|
||||
_def_ptemp(copy._def_ptemp),
|
||||
_last_frame(copy._last_frame),
|
||||
_freeze_on_cull(copy._freeze_on_cull),
|
||||
_detail(copy._detail),
|
||||
_draw_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -66,19 +66,19 @@ osgParticle::ParticleSystem::~ParticleSystem()
|
||||
void osgParticle::ParticleSystem::update(double dt)
|
||||
{
|
||||
// reset bounds
|
||||
reset_bounds_flag_ = true;
|
||||
_reset_bounds_flag = true;
|
||||
|
||||
// set up iterators for particles
|
||||
Particle_vector::iterator i;
|
||||
Particle_vector::iterator end = particles_.end();
|
||||
Particle_vector::iterator end = _particles.end();
|
||||
|
||||
// update particles
|
||||
for (i=particles_.begin(); i!=end; ++i) {
|
||||
for (i=_particles.begin(); i!=end; ++i) {
|
||||
if (i->isAlive()) {
|
||||
if (i->update(dt)) {
|
||||
update_bounds(i->getPosition(), i->getCurrentSize());
|
||||
} else {
|
||||
deadparts_.push(&(*i));
|
||||
_deadparts.push(&(*i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,16 +87,16 @@ void osgParticle::ParticleSystem::update(double dt)
|
||||
dirtyBound();
|
||||
}
|
||||
|
||||
void osgParticle::ParticleSystem::drawImplementation(osg::State &state) const
|
||||
void osgParticle::ParticleSystem::drawImplementation(osg::State& state) const
|
||||
{
|
||||
// update the frame count, so other objects can detect when
|
||||
// this particle system is culled
|
||||
last_frame_ = state.getFrameStamp()->getFrameNumber();
|
||||
_last_frame = state.getFrameStamp()->getFrameNumber();
|
||||
|
||||
// get the current modelview matrix
|
||||
osg::Matrix modelview = state.getModelViewMatrix();
|
||||
|
||||
if (alignment_ == BILLBOARD)
|
||||
if (_alignment == BILLBOARD)
|
||||
state.applyModelViewMatrix(0);
|
||||
|
||||
// set up depth mask for first rendering pass
|
||||
@ -110,7 +110,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::State &state) const
|
||||
glPopAttrib();
|
||||
|
||||
// render, second pass
|
||||
if (doublepass_) {
|
||||
if (_doublepass) {
|
||||
// set up color mask for second rendering pass
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
@ -123,7 +123,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::State &state) const
|
||||
}
|
||||
}
|
||||
|
||||
void osgParticle::ParticleSystem::setDefaultAttributes(const std::string &texturefile, bool emissive_particles, bool lighting, int texture_unit)
|
||||
void osgParticle::ParticleSystem::setDefaultAttributes(const std::string& texturefile, bool emissive_particles, bool lighting, int texture_unit)
|
||||
{
|
||||
osg::StateSet *stateset = new osg::StateSet;
|
||||
|
||||
@ -160,33 +160,33 @@ void osgParticle::ParticleSystem::setDefaultAttributes(const std::string &textur
|
||||
}
|
||||
|
||||
|
||||
void osgParticle::ParticleSystem::single_pass_render(osg::State & /*state*/, const osg::Matrix &modelview) const
|
||||
void osgParticle::ParticleSystem::single_pass_render(osg::State& /*state*/, const osg::Matrix& modelview) const
|
||||
{
|
||||
draw_count_ = 0;
|
||||
if (particles_.size() <= 0) return;
|
||||
_draw_count = 0;
|
||||
if (_particles.size() <= 0) return;
|
||||
|
||||
Particle_vector::const_iterator i;
|
||||
Particle_vector::const_iterator i0 = particles_.begin();
|
||||
Particle_vector::const_iterator end = particles_.end();
|
||||
Particle_vector::const_iterator i0 = _particles.begin();
|
||||
Particle_vector::const_iterator end = _particles.end();
|
||||
|
||||
i0->beginRender();
|
||||
|
||||
float scale = sqrtf(static_cast<float>(detail_));
|
||||
for (i=i0; i<end; i+=detail_) {
|
||||
float scale = sqrtf(static_cast<float>(_detail));
|
||||
for (i=i0; i<end; i+=_detail) {
|
||||
if (i->isAlive()) {
|
||||
if (i->getShape() != i0->getShape()) {
|
||||
i0->endRender();
|
||||
i->beginRender();
|
||||
i0 = i;
|
||||
}
|
||||
++draw_count_;
|
||||
++_draw_count;
|
||||
|
||||
switch (alignment_) {
|
||||
switch (_alignment) {
|
||||
case BILLBOARD:
|
||||
i->render(modelview.preMult(i->getPosition()), osg::Vec3(1, 0, 0), osg::Vec3(0, 1, 0), scale);
|
||||
break;
|
||||
case FIXED:
|
||||
i->render(i->getPosition(), align_X_axis_, align_Y_axis_, scale);
|
||||
i->render(i->getPosition(), _align_X_axis, _align_Y_axis, scale);
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
|
@ -6,39 +6,39 @@
|
||||
using namespace osg;
|
||||
|
||||
osgParticle::ParticleSystemUpdater::ParticleSystemUpdater()
|
||||
: osg::Node(), t0_(-1)
|
||||
: osg::Node(), _t0(-1)
|
||||
{
|
||||
setCullingActive(false);
|
||||
}
|
||||
|
||||
osgParticle::ParticleSystemUpdater::ParticleSystemUpdater(const ParticleSystemUpdater ©, const osg::CopyOp ©op)
|
||||
: osg::Node(copy, copyop), t0_(copy.t0_)
|
||||
osgParticle::ParticleSystemUpdater::ParticleSystemUpdater(const ParticleSystemUpdater& copy, const osg::CopyOp& copyop)
|
||||
: osg::Node(copy, copyop), _t0(copy._t0)
|
||||
{
|
||||
ParticleSystem_Vector::const_iterator i;
|
||||
for (i=copy.psv_.begin(); i!=copy.psv_.end(); ++i) {
|
||||
psv_.push_back(static_cast<ParticleSystem *>(copyop(i->get())));
|
||||
for (i=copy._psv.begin(); i!=copy._psv.end(); ++i) {
|
||||
_psv.push_back(static_cast<ParticleSystem* >(copyop(i->get())));
|
||||
}
|
||||
}
|
||||
|
||||
void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor &nv)
|
||||
void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
|
||||
if (cv) {
|
||||
if (nv.getFrameStamp())
|
||||
{
|
||||
double t = nv.getFrameStamp()->getReferenceTime();
|
||||
if (t0_ != -1)
|
||||
if (_t0 != -1)
|
||||
{
|
||||
ParticleSystem_Vector::iterator i;
|
||||
for (i=psv_.begin(); i!=psv_.end(); ++i)
|
||||
for (i=_psv.begin(); i!=_psv.end(); ++i)
|
||||
{
|
||||
if (!i->get()->isFrozen() && (i->get()->getLastFrameNumber() >= (nv.getFrameStamp()->getFrameNumber() - 1) || !i->get()->getFreezeOnCull()))
|
||||
{
|
||||
i->get()->update(t - t0_);
|
||||
i->get()->update(t - _t0);
|
||||
}
|
||||
}
|
||||
}
|
||||
t0_ = t;
|
||||
_t0 = t;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ osgParticle::Program::Program()
|
||||
{
|
||||
}
|
||||
|
||||
osgParticle::Program::Program(const Program ©, const osg::CopyOp ©op)
|
||||
osgParticle::Program::Program(const Program& copy, const osg::CopyOp& copyop)
|
||||
: ParticleProcessor(copy, copyop)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user