Panda3D
 All Classes Functions Variables Enumerations
baseParticleRenderer.h
1 // Filename: baseParticleRenderer.h
2 // Created by: charles (20Jun00)
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 BASEPARTICLERENDERER_H
16 #define BASEPARTICLERENDERER_H
17 
18 #include "pandabase.h"
19 #include "referenceCount.h"
20 #include "physicsObject.h"
21 #include "renderState.h"
22 #include "geomNode.h"
23 #include "colorBlendAttrib.h"
24 #include "nodePath.h"
25 #include "particleCommonFuncs.h"
26 #include "baseParticle.h"
27 
28 #include "pvector.h"
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : BaseParticleRenderer
32 // Description : Pure virtual particle renderer base class
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDAPHYSICS BaseParticleRenderer : public ReferenceCount {
35 PUBLISHED:
36  enum ParticleRendererAlphaMode {
37  PR_ALPHA_NONE,
38  PR_ALPHA_OUT,
39  PR_ALPHA_IN,
40  PR_ALPHA_IN_OUT,
41  PR_ALPHA_USER,
42  PR_NOT_INITIALIZED_YET
43  };
44 
45  enum ParticleRendererBlendMethod {
46  PP_NO_BLEND,
47  PP_BLEND_LINEAR,
48  PP_BLEND_CUBIC
49  };
50 
51  virtual ~BaseParticleRenderer();
52 
53  INLINE GeomNode *get_render_node() const;
54  INLINE NodePath get_render_node_path() const;
55 
56  INLINE void set_alpha_mode(ParticleRendererAlphaMode am);
57  INLINE ParticleRendererAlphaMode get_alpha_mode() const;
58 
59  INLINE void set_user_alpha(PN_stdfloat ua);
60  INLINE PN_stdfloat get_user_alpha() const;
61 
62  INLINE void set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa = ColorBlendAttrib::O_zero, ColorBlendAttrib::Operand ob = ColorBlendAttrib::O_zero);
63 
64  void set_ignore_scale(bool ignore_scale);
65  INLINE bool get_ignore_scale() const;
66 
67  virtual void output(ostream &out) const;
68  virtual void write(ostream &out, int indent=0) const;
69 
70 public:
71  virtual BaseParticleRenderer *make_copy() = 0;
72 
73 protected:
74  ParticleRendererAlphaMode _alpha_mode;
75 
76  BaseParticleRenderer(ParticleRendererAlphaMode alpha_decay = PR_ALPHA_NONE);
78 
79  void update_alpha_mode(ParticleRendererAlphaMode am);
80 
81  void enable_alpha();
82  void disable_alpha();
83 
84  INLINE PN_stdfloat get_cur_alpha(BaseParticle* bp);
85 
86  virtual void resize_pool(int new_size) = 0;
87 
88  CPT(RenderState) _render_state;
89 
90 private:
91  PT(GeomNode) _render_node;
92  NodePath _render_node_path;
93 
94  PN_stdfloat _user_alpha;
95  bool _ignore_scale;
96 
97  // birth and kill particle are for renderers that might do maintenance
98  // faster if it was notified on a per-event basis. An example:
99  // geomParticleRenderer maintains an arc for every particle. Instead
100  // of visiting EVERY entry in the arc array, individual arcs are
101  // changed on birth and death. Brings it down a little from O(N) every
102  // update.
103 
104  virtual void birth_particle(int index) = 0;
105  virtual void kill_particle(int index) = 0;
106 
107 
108  virtual void init_geoms() = 0;
109  virtual void render(pvector< PT(PhysicsObject) >& po_vector,
110  int ttl_particles) = 0;
111 
112  friend class ParticleSystem;
113 };
114 
115 #include "baseParticleRenderer.I"
116 
117 #endif // BASEPARTICLERENDERER_H
118 
A body on which physics will be applied.
Definition: physicsObject.h:29
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
Contains and manages a particle system.
Pure virtual particle renderer base class.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
A base class for all things that want to be reference-counted.
An individual, physically-modelable particle abstract base class.
Definition: baseParticle.h:26
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37