Panda3D
|
00001 // Filename: colorAttrib.h 00002 // Created by: drose (22Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef COLORATTRIB_H 00016 #define COLORATTRIB_H 00017 00018 #include "pandabase.h" 00019 00020 #include "renderAttrib.h" 00021 #include "luse.h" 00022 00023 class FactoryParams; 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : ColorAttrib 00027 // Description : Indicates what color should be applied to renderable 00028 // geometry. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDA_PGRAPH ColorAttrib : public RenderAttrib { 00031 PUBLISHED: 00032 enum Type { 00033 T_vertex, T_flat, T_off 00034 }; 00035 00036 private: 00037 INLINE ColorAttrib(Type type, const LColor &color); 00038 00039 PUBLISHED: 00040 static CPT(RenderAttrib) make_vertex(); 00041 static CPT(RenderAttrib) make_flat(const LColor &color); 00042 static CPT(RenderAttrib) make_off(); 00043 static CPT(RenderAttrib) make_default(); 00044 00045 INLINE Type get_color_type() const; 00046 INLINE const LColor &get_color() const; 00047 00048 public: 00049 virtual void output(ostream &out) const; 00050 00051 protected: 00052 virtual int compare_to_impl(const RenderAttrib *other) const; 00053 virtual size_t get_hash_impl() const; 00054 virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const; 00055 00056 private: 00057 void quantize_color(); 00058 00059 private: 00060 Type _type; 00061 LColor _color; 00062 static CPT(RenderAttrib) _off; 00063 static CPT(RenderAttrib) _vertex; 00064 00065 PUBLISHED: 00066 static int get_class_slot() { 00067 return _attrib_slot; 00068 } 00069 virtual int get_slot() const { 00070 return get_class_slot(); 00071 } 00072 00073 public: 00074 static void register_with_read_factory(); 00075 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00076 00077 protected: 00078 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00079 void fillin(DatagramIterator &scan, BamReader *manager); 00080 00081 public: 00082 static TypeHandle get_class_type() { 00083 return _type_handle; 00084 } 00085 static void init_type() { 00086 RenderAttrib::init_type(); 00087 register_type(_type_handle, "ColorAttrib", 00088 RenderAttrib::get_class_type()); 00089 _attrib_slot = register_slot(_type_handle, 100, make_default); 00090 } 00091 virtual TypeHandle get_type() const { 00092 return get_class_type(); 00093 } 00094 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00095 00096 private: 00097 static TypeHandle _type_handle; 00098 static int _attrib_slot; 00099 }; 00100 00101 #include "colorAttrib.I" 00102 00103 #endif 00104