Added 'int index' member to be used for sprite rendering.

This commit is contained in:
Josh Wilson 2005-07-14 18:16:40 +00:00
parent 2219a758e4
commit 8c4ba1acd2
3 changed files with 21 additions and 7 deletions

View File

@ -28,6 +28,10 @@ INLINE void BaseParticle::set_alive(bool alive) {
_alive = alive;
}
INLINE void BaseParticle::set_index(int index) {
_index = index;
}
INLINE float BaseParticle::get_age() const {
return _age;
}
@ -40,6 +44,10 @@ INLINE bool BaseParticle::get_alive() const {
return _alive;
}
INLINE int BaseParticle::get_index() const {
return _index;
}
INLINE float BaseParticle::get_parameterized_age() const {
if (_lifespan <= 0) return 1.0;
return _age / _lifespan;

View File

@ -24,8 +24,8 @@
// Description : Default Constructor
////////////////////////////////////////////////////////////////////
BaseParticle::
BaseParticle(int lifespan, bool alive) :
_age(0.0f), _lifespan(lifespan), _alive(alive) {
BaseParticle(float lifespan, bool alive) :
_age(0.0f), _lifespan(lifespan), _alive(alive), _index(0){
}
////////////////////////////////////////////////////////////////////
@ -34,10 +34,11 @@ BaseParticle(int lifespan, bool alive) :
// Description : Copy Constructor
////////////////////////////////////////////////////////////////////
BaseParticle::
BaseParticle(const BaseParticle &copy) {
_age = copy._age;
_lifespan = copy._lifespan;
_alive = copy._alive;
BaseParticle(const BaseParticle &copy) :
_age(copy._age),
_lifespan(copy._lifespan),
_alive(copy._alive),
_index(copy._index) {
}
////////////////////////////////////////////////////////////////////
@ -85,6 +86,7 @@ write(ostream &out, int indent) const {
out.width(indent+2); out<<""; out<<"_age "<<_age<<"\n";
out.width(indent+2); out<<""; out<<"_lifespan "<<_lifespan<<"\n";
out.width(indent+2); out<<""; out<<"_alive "<<_alive<<"\n";
out.width(indent+2); out<<""; out<<"_index "<<_index<<"\n";
out.width(indent+2); out<<""; out<<"_last_position "<<_last_position<<"\n";
PhysicsObject::write(out, indent+2);
#endif //] NDEBUG

View File

@ -33,10 +33,13 @@ public:
INLINE void set_age(float age);
INLINE void set_lifespan(float lifespan);
INLINE void set_alive(bool alive);
INLINE void set_index(int index);
INLINE float get_age() const;
INLINE float get_lifespan() const;
INLINE bool get_alive() const;
INLINE int get_index() const;
INLINE float get_parameterized_age() const;
INLINE float get_parameterized_vel() const;
@ -56,7 +59,7 @@ public:
virtual void write(ostream &out, int indent=0) const;
protected:
BaseParticle(int lifespan = 1, bool alive = false);
BaseParticle(float lifespan = 1.0f, bool alive = false);
BaseParticle(const BaseParticle &copy);
virtual ~BaseParticle();
@ -65,6 +68,7 @@ private:
float _age;
float _lifespan;
bool _alive;
int _index;
LPoint3f _last_position;
};