00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef TEXGENATTRIB_H
00016 #define TEXGENATTRIB_H
00017
00018 #include "pandabase.h"
00019
00020 #include "geom.h"
00021 #include "renderAttrib.h"
00022 #include "textureStage.h"
00023 #include "texture.h"
00024 #include "pointerTo.h"
00025 #include "nodePath.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class EXPCL_PANDA_PGRAPH TexGenAttrib : public RenderAttrib {
00037 PUBLISHED:
00038
00039
00040
00041
00042 typedef RenderAttrib::TexGenMode Mode;
00043
00044 protected:
00045 INLINE TexGenAttrib();
00046 INLINE TexGenAttrib(const TexGenAttrib ©);
00047
00048 public:
00049 virtual ~TexGenAttrib();
00050
00051 PUBLISHED:
00052 static CPT(RenderAttrib) make();
00053 static CPT(RenderAttrib) make(TextureStage *stage, Mode mode);
00054 static CPT(RenderAttrib) make_default();
00055
00056 CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode) const;
00057 CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode, const string &source_name, const NodePath &light) const;
00058 CPT(RenderAttrib) add_stage(TextureStage *stage, Mode mode, const LTexCoord3 &constant_value) const;
00059 CPT(RenderAttrib) remove_stage(TextureStage *stage) const;
00060
00061 bool is_empty() const;
00062 bool has_stage(TextureStage *stage) const;
00063 Mode get_mode(TextureStage *stage) const;
00064 bool has_gen_texcoord_stage(TextureStage *stage) const;
00065 string get_source_name(TextureStage *stage) const;
00066 NodePath get_light(TextureStage *stage) const;
00067 const LTexCoord3 &get_constant_value(TextureStage *stage) const;
00068
00069 INLINE int get_geom_rendering(int geom_rendering) const;
00070
00071 public:
00072 typedef pset<TextureStage *> LightVectors;
00073 INLINE const LightVectors &get_light_vectors() const;
00074
00075 virtual void output(ostream &out) const;
00076
00077 protected:
00078 virtual int compare_to_impl(const RenderAttrib *other) const;
00079 virtual size_t get_hash_impl() const;
00080 virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00081 virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00082 virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
00083
00084 private:
00085 class ModeDef;
00086 void filled_stages();
00087 void record_stage(TextureStage *stage, ModeDef &mode_def);
00088
00089 class ModeDef {
00090 public:
00091 INLINE ModeDef();
00092 INLINE int compare_to(const ModeDef &other) const;
00093 Mode _mode;
00094 string _source_name;
00095 NodePath _light;
00096 LTexCoord3 _constant_value;
00097 };
00098 typedef pmap<PT(TextureStage), ModeDef> Stages;
00099 Stages _stages;
00100
00101
00102
00103
00104
00105 typedef pset<TextureStage *> NoTexCoordStages;
00106 NoTexCoordStages _no_texcoords;
00107
00108
00109
00110 LightVectors _light_vectors;
00111
00112
00113
00114 pvector<Mode> _read_modes;
00115
00116 int _num_point_sprites;
00117 int _num_light_vectors;
00118
00119
00120
00121
00122
00123 int _point_geom_rendering;
00124 int _geom_rendering;
00125
00126 static CPT(RenderAttrib) _empty_attrib;
00127
00128 PUBLISHED:
00129 static int get_class_slot() {
00130 return _attrib_slot;
00131 }
00132 virtual int get_slot() const {
00133 return get_class_slot();
00134 }
00135
00136 public:
00137 static void register_with_read_factory();
00138 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00139 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00140
00141 protected:
00142 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00143 void fillin(DatagramIterator &scan, BamReader *manager);
00144
00145 public:
00146 static TypeHandle get_class_type() {
00147 return _type_handle;
00148 }
00149 static void init_type() {
00150 RenderAttrib::init_type();
00151 register_type(_type_handle, "TexGenAttrib",
00152 RenderAttrib::get_class_type());
00153 _attrib_slot = register_slot(_type_handle, 100, make_default);
00154 }
00155 virtual TypeHandle get_type() const {
00156 return get_class_type();
00157 }
00158 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00159
00160 private:
00161 static TypeHandle _type_handle;
00162 static int _attrib_slot;
00163 };
00164
00165 #include "texGenAttrib.I"
00166
00167 #endif
00168