00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef COLORSCALEATTRIB_H
00016 #define COLORSCALEATTRIB_H
00017
00018 #include "pandabase.h"
00019
00020 #include "renderAttrib.h"
00021 #include "luse.h"
00022
00023 class FactoryParams;
00024
00025
00026
00027
00028
00029
00030 class EXPCL_PANDA_PGRAPH ColorScaleAttrib : public RenderAttrib {
00031 protected:
00032 ColorScaleAttrib(bool off, const LVecBase4 &scale);
00033 INLINE ColorScaleAttrib(const ColorScaleAttrib ©);
00034
00035 PUBLISHED:
00036 static CPT(RenderAttrib) make_identity();
00037 static CPT(RenderAttrib) make(const LVecBase4 &scale);
00038 static CPT(RenderAttrib) make_off();
00039 static CPT(RenderAttrib) make_default();
00040
00041 INLINE bool is_off() const;
00042 INLINE bool is_identity() const;
00043 INLINE bool has_scale() const;
00044 INLINE bool has_rgb_scale() const;
00045 INLINE bool has_alpha_scale() const;
00046 INLINE const LVecBase4 &get_scale() const;
00047 CPT(RenderAttrib) set_scale(const LVecBase4 &scale) const;
00048
00049 public:
00050 virtual bool lower_attrib_can_override() const;
00051 virtual void output(ostream &out) const;
00052
00053 protected:
00054 virtual int compare_to_impl(const RenderAttrib *other) const;
00055 virtual size_t get_hash_impl() const;
00056 virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
00057 virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
00058 virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
00059
00060 private:
00061 void quantize_scale();
00062
00063 private:
00064 bool _off;
00065 bool _has_scale;
00066 bool _has_rgb_scale;
00067 bool _has_alpha_scale;
00068 LVecBase4 _scale;
00069 static CPT(RenderAttrib) _identity_attrib;
00070
00071 PUBLISHED:
00072 static int get_class_slot() {
00073 return _attrib_slot;
00074 }
00075 virtual int get_slot() const {
00076 return get_class_slot();
00077 }
00078
00079 public:
00080 static void register_with_read_factory();
00081 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00082
00083 protected:
00084 static TypedWritable *make_from_bam(const FactoryParams ¶ms);
00085 void fillin(DatagramIterator &scan, BamReader *manager);
00086
00087 public:
00088 static TypeHandle get_class_type() {
00089 return _type_handle;
00090 }
00091 static void init_type() {
00092 RenderAttrib::init_type();
00093 register_type(_type_handle, "ColorScaleAttrib",
00094 RenderAttrib::get_class_type());
00095 _attrib_slot = register_slot(_type_handle, 100, make_default);
00096 }
00097 virtual TypeHandle get_type() const {
00098 return get_class_type();
00099 }
00100 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00101
00102 private:
00103 static TypeHandle _type_handle;
00104 static int _attrib_slot;
00105 };
00106
00107 #include "colorScaleAttrib.I"
00108
00109 #endif
00110