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