Panda3D
 All Classes Functions Variables Enumerations
baseParticle.h
1 // Filename: baseParticle.h
2 // Created by: charles (14Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BASEPARTICLE_H
16 #define BASEPARTICLE_H
17 
18 #include "pandabase.h"
19 #include "physicsObject.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : BaseParticle
23 // Description : An individual, physically-modelable particle
24 // abstract base class.
25 ////////////////////////////////////////////////////////////////////
26 class EXPCL_PANDAPHYSICS BaseParticle : public PhysicsObject {
27 public:
28  // local methods
29  INLINE void set_age(PN_stdfloat age);
30  INLINE void set_lifespan(PN_stdfloat lifespan);
31  INLINE void set_alive(bool alive);
32  INLINE void set_index(int index);
33 
34 
35  INLINE PN_stdfloat get_age() const;
36  INLINE PN_stdfloat get_lifespan() const;
37  INLINE bool get_alive() const;
38  INLINE int get_index() const;
39 
40  INLINE PN_stdfloat get_parameterized_age() const;
41  INLINE PN_stdfloat get_parameterized_vel() const;
42 
43  // child methods
44  virtual void init() = 0;
45  virtual void die() = 0;
46  virtual void update() = 0;
47 
48  // for spriteParticleRenderer
49  virtual PN_stdfloat get_theta() const;
50 
51  // from PhysicsObject
52  virtual PhysicsObject *make_copy() const = 0;
53 
54  virtual void output(ostream &out) const;
55  virtual void write(ostream &out, int indent=0) const;
56 
57 protected:
58  BaseParticle(PN_stdfloat lifespan = 1.0f, bool alive = false);
59  BaseParticle(const BaseParticle &copy);
60  virtual ~BaseParticle();
61 
62 private:
63  // NOTE: age and lifespan are in seconds.
64  PN_stdfloat _age;
65  PN_stdfloat _lifespan;
66  bool _alive;
67  int _index;
68 
69  LPoint3 _last_position;
70 };
71 
72 #include "baseParticle.I"
73 
74 #endif // BASEPARTICLE_H
A body on which physics will be applied.
Definition: physicsObject.h:29
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
virtual PhysicsObject * make_copy() const
dynamic copy.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:26
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.