00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef BASEPARTICLERENDERER_H
00016 #define BASEPARTICLERENDERER_H
00017
00018 #include "pandabase.h"
00019 #include "referenceCount.h"
00020 #include "physicsObject.h"
00021 #include "renderState.h"
00022 #include "geomNode.h"
00023 #include "colorBlendAttrib.h"
00024 #include "nodePath.h"
00025 #include "particleCommonFuncs.h"
00026 #include "baseParticle.h"
00027
00028 #include "pvector.h"
00029
00030
00031
00032
00033
00034 class EXPCL_PANDAPHYSICS BaseParticleRenderer : public ReferenceCount {
00035 PUBLISHED:
00036 enum ParticleRendererAlphaMode {
00037 PR_ALPHA_NONE,
00038 PR_ALPHA_OUT,
00039 PR_ALPHA_IN,
00040 PR_ALPHA_IN_OUT,
00041 PR_ALPHA_USER,
00042 PR_NOT_INITIALIZED_YET
00043 };
00044
00045 enum ParticleRendererBlendMethod {
00046 PP_NO_BLEND,
00047 PP_BLEND_LINEAR,
00048 PP_BLEND_CUBIC
00049 };
00050
00051 virtual ~BaseParticleRenderer();
00052
00053 INLINE GeomNode *get_render_node() const;
00054 INLINE NodePath get_render_node_path() const;
00055
00056 INLINE void set_alpha_mode(ParticleRendererAlphaMode am);
00057 INLINE ParticleRendererAlphaMode get_alpha_mode() const;
00058
00059 INLINE void set_user_alpha(PN_stdfloat ua);
00060 INLINE PN_stdfloat get_user_alpha() const;
00061
00062 INLINE void set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa = ColorBlendAttrib::O_zero, ColorBlendAttrib::Operand ob = ColorBlendAttrib::O_zero);
00063
00064 void set_ignore_scale(bool ignore_scale);
00065 INLINE bool get_ignore_scale() const;
00066
00067 virtual void output(ostream &out) const;
00068 virtual void write(ostream &out, int indent=0) const;
00069
00070 public:
00071 virtual BaseParticleRenderer *make_copy() = 0;
00072
00073 protected:
00074 ParticleRendererAlphaMode _alpha_mode;
00075
00076 BaseParticleRenderer(ParticleRendererAlphaMode alpha_decay = PR_ALPHA_NONE);
00077 BaseParticleRenderer(const BaseParticleRenderer& copy);
00078
00079 void update_alpha_mode(ParticleRendererAlphaMode am);
00080
00081 void enable_alpha();
00082 void disable_alpha();
00083
00084 INLINE PN_stdfloat get_cur_alpha(BaseParticle* bp);
00085
00086 virtual void resize_pool(int new_size) = 0;
00087
00088 CPT(RenderState) _render_state;
00089
00090 private:
00091 PT(GeomNode) _render_node;
00092 NodePath _render_node_path;
00093
00094 PN_stdfloat _user_alpha;
00095 bool _ignore_scale;
00096
00097
00098
00099
00100
00101
00102
00103
00104 virtual void birth_particle(int index) = 0;
00105 virtual void kill_particle(int index) = 0;
00106
00107
00108 virtual void init_geoms() = 0;
00109 virtual void render(pvector< PT(PhysicsObject) >& po_vector,
00110 int ttl_particles) = 0;
00111
00112 friend class ParticleSystem;
00113 };
00114
00115 #include "baseParticleRenderer.I"
00116
00117 #endif // BASEPARTICLERENDERER_H
00118