Moved osgParticle across to standard OSG coding style.

This commit is contained in:
Robert Osfield
2005-04-29 09:47:57 +00:00
parent 6211eb7b48
commit 6b5238c294
44 changed files with 1035 additions and 1027 deletions

View File

@@ -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 &copy, const osg::CopyOp &copyop = 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);
}
}