00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef RENDEREFFECTS_H
00020 #define RENDEREFFECTS_H
00021
00022 #include "pandabase.h"
00023
00024 #include "renderEffect.h"
00025 #include "typedWritableReferenceCount.h"
00026 #include "pointerTo.h"
00027 #include "indirectLess.h"
00028 #include "ordered_vector.h"
00029
00030 class BillboardEffect;
00031 class CompassEffect;
00032 class FactoryParams;
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 class EXPCL_PANDA RenderEffects : public TypedWritableReferenceCount {
00047 protected:
00048 RenderEffects();
00049
00050 private:
00051 RenderEffects(const RenderEffects ©);
00052 void operator = (const RenderEffects ©);
00053
00054 public:
00055 virtual ~RenderEffects();
00056
00057 bool operator < (const RenderEffects &other) const;
00058
00059 bool safe_to_transform() const;
00060 bool safe_to_combine() const;
00061 CPT(RenderEffects) xform(const LMatrix4f &mat) const;
00062
00063 PUBLISHED:
00064 INLINE bool is_empty() const;
00065 INLINE int get_num_effects() const;
00066 INLINE const RenderEffect *get_effect(int n) const;
00067
00068 int find_effect(TypeHandle type) const;
00069
00070 static CPT(RenderEffects) make_empty();
00071 static CPT(RenderEffects) make(const RenderEffect *effect);
00072 static CPT(RenderEffects) make(const RenderEffect *effect1,
00073 const RenderEffect *effect2);
00074 static CPT(RenderEffects) make(const RenderEffect *effect1,
00075 const RenderEffect *effect2,
00076 const RenderEffect *effect3);
00077 static CPT(RenderEffects) make(const RenderEffect *effect1,
00078 const RenderEffect *effect2,
00079 const RenderEffect *effect3,
00080 const RenderEffect *effect4);
00081
00082 CPT(RenderEffects) add_effect(const RenderEffect *effect) const;
00083 CPT(RenderEffects) remove_effect(TypeHandle type) const;
00084
00085 const RenderEffect *get_effect(TypeHandle type) const;
00086
00087 void output(ostream &out) const;
00088 void write(ostream &out, int indent_level) const;
00089
00090 public:
00091 INLINE const BillboardEffect *get_billboard() const;
00092 INLINE bool has_decal() const;
00093 INLINE const CompassEffect *get_compass() const;
00094 INLINE bool has_show_bounds() const;
00095
00096 private:
00097 static CPT(RenderEffects) return_new(RenderEffects *state);
00098 void determine_billboard();
00099 void determine_decal();
00100 void determine_compass();
00101 void determine_show_bounds();
00102
00103 private:
00104 typedef pset<const RenderEffects *, IndirectLess<RenderEffects> > States;
00105 static States _states;
00106 static CPT(RenderEffects) _empty_state;
00107
00108
00109
00110
00111 States::iterator _saved_entry;
00112
00113 private:
00114
00115
00116 class Effect {
00117 public:
00118 INLINE Effect(const RenderEffect *effect);
00119 INLINE Effect();
00120 INLINE Effect(TypeHandle type);
00121 INLINE Effect(const Effect ©);
00122 INLINE void operator = (const Effect ©);
00123 INLINE bool operator < (const Effect &other) const;
00124 INLINE int compare_to(const Effect &other) const;
00125
00126 TypeHandle _type;
00127 CPT(RenderEffect) _effect;
00128 };
00129 typedef ov_set<Effect> Effects;
00130 Effects _effects;
00131
00132
00133
00134 const BillboardEffect *_billboard;
00135 const CompassEffect *_compass;
00136
00137 enum Flags {
00138 F_checked_billboard = 0x0001,
00139 F_checked_decal = 0x0002,
00140 F_has_decal = 0x0004,
00141 F_checked_show_bounds = 0x0008,
00142 F_has_show_bounds = 0x0010,
00143 F_checked_compass = 0x0020,
00144 };
00145 short _flags;
00146
00147 public:
00148 static void register_with_read_factory();
00149 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00150 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00151 static TypedWritable *change_this(TypedWritable *old_ptr, BamReader *manager);
00152 virtual void finalize();
00153
00154 protected:
00155 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00156 void fillin(DatagramIterator &scan, BamReader *manager);
00157
00158 public:
00159 static TypeHandle get_class_type() {
00160 return _type_handle;
00161 }
00162 static void init_type() {
00163 TypedWritableReferenceCount::init_type();
00164 register_type(_type_handle, "RenderEffects",
00165 TypedWritableReferenceCount::get_class_type());
00166 }
00167 virtual TypeHandle get_type() const {
00168 return get_class_type();
00169 }
00170 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00171
00172 private:
00173 static TypeHandle _type_handle;
00174 };
00175
00176 INLINE ostream &operator << (ostream &out, const RenderEffects &state) {
00177 state.output(out);
00178 return out;
00179 }
00180
00181 #include "renderEffects.I"
00182
00183 #endif
00184