Panda3D
sparkleParticleRenderer.h
1 // Filename: sparkleParticleRenderer.h
2 // Created by: charles (27Jun00)
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 SPARKLEPARTICLERENDERER_H
16 #define SPARKLEPARTICLERENDERER_H
17 
18 #include "baseParticle.h"
19 #include "baseParticleRenderer.h"
20 #include "pointerTo.h"
21 #include "pointerToArray.h"
22 #include "geom.h"
23 #include "geomVertexData.h"
24 #include "geomLines.h"
25 #include "pStatCollector.h"
26 
27 enum SparkleParticleLifeScale {
28  SP_NO_SCALE,
29  SP_SCALE
30 };
31 
32 ////////////////////////////////////////////////////////////////////
33 // Class : SparkleParticleRenderer
34 // Description : pretty sparkly things.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDAPHYSICS SparkleParticleRenderer : public BaseParticleRenderer {
37 PUBLISHED:
38  enum SparkleParticleLifeScale {
39  SP_NO_SCALE,
40  SP_SCALE
41  };
42 
45  SparkleParticleRenderer(const LColor& center,
46  const LColor& edge,
47  PN_stdfloat birth_radius,
48  PN_stdfloat death_radius,
49  SparkleParticleLifeScale life_scale,
50  ParticleRendererAlphaMode alpha_mode);
51 
52  virtual ~SparkleParticleRenderer();
53 
54 public:
55  virtual BaseParticleRenderer *make_copy();
56 
57 PUBLISHED:
58  INLINE void set_center_color(const LColor& c);
59  INLINE void set_edge_color(const LColor& c);
60  INLINE void set_birth_radius(PN_stdfloat radius);
61  INLINE void set_death_radius(PN_stdfloat radius);
62  INLINE void set_life_scale(SparkleParticleLifeScale);
63 
64  INLINE const LColor& get_center_color() const;
65  INLINE const LColor& get_edge_color() const;
66  INLINE PN_stdfloat get_birth_radius() const;
67  INLINE PN_stdfloat get_death_radius() const;
68  INLINE SparkleParticleLifeScale get_life_scale() const;
69 
70  virtual void output(ostream &out) const;
71  virtual void write(ostream &out, int indent_level = 0) const;
72 
73 private:
74  LColor _center_color;
75  LColor _edge_color;
76 
77  PN_stdfloat _birth_radius;
78  PN_stdfloat _death_radius;
79 
80  PT(Geom) _line_primitive;
81  PT(GeomLines) _lines;
82  PT(GeomVertexData) _vdata;
83 
84  int _max_pool_size;
85 
86  SparkleParticleLifeScale _life_scale;
87  LPoint3 _aabb_min;
88  LPoint3 _aabb_max;
89 
90  INLINE PN_stdfloat get_radius(BaseParticle *bp);
91 
92  virtual void birth_particle(int index);
93  virtual void kill_particle(int index);
94  virtual void init_geoms();
95  virtual void render(pvector< PT(PhysicsObject) >& po_vector,
96  int ttl_particles);
97  virtual void resize_pool(int new_size);
98 
99  static PStatCollector _render_collector;
100 };
101 
102 #include "sparkleParticleRenderer.I"
103 
104 #endif // SPARKLEPARTICLERENDERER_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
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
A lightweight class that represents a single element that may be timed and/or counted via stats...
Pure virtual particle renderer base class.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Definition: geom.h:58
Defines a series of disconnected line segments.
Definition: geomLines.h:25
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
pretty sparkly things.
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:26
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
virtual void write(ostream &out, int indent=0) const
Write a string representation of this instance to <out>.