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