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 Colorf &color); 00038 00039 PUBLISHED: 00040 static CPT(RenderAttrib) make_vertex(); 00041 static CPT(RenderAttrib) make_flat(const Colorf &color); 00042 static CPT(RenderAttrib) make_off(); 00043 static CPT(RenderAttrib) make_default(); 00044 00045 INLINE Type get_color_type() const; 00046 INLINE const Colorf &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 00054 private: 00055 void quantize_color(); 00056 00057 private: 00058 Type _type; 00059 Colorf _color; 00060 static CPT(RenderAttrib) _off; 00061 static CPT(RenderAttrib) _vertex; 00062 00063 PUBLISHED: 00064 static int get_class_slot() { 00065 return _attrib_slot; 00066 } 00067 virtual int get_slot() const { 00068 return get_class_slot(); 00069 } 00070 00071 public: 00072 static void register_with_read_factory(); 00073 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00074 00075 protected: 00076 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00077 void fillin(DatagramIterator &scan, BamReader *manager); 00078 00079 public: 00080 static TypeHandle get_class_type() { 00081 return _type_handle; 00082 } 00083 static void init_type() { 00084 RenderAttrib::init_type(); 00085 register_type(_type_handle, "ColorAttrib", 00086 RenderAttrib::get_class_type()); 00087 _attrib_slot = register_slot(_type_handle, 100, make_default); 00088 } 00089 virtual TypeHandle get_type() const { 00090 return get_class_type(); 00091 } 00092 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00093 00094 private: 00095 static TypeHandle _type_handle; 00096 static int _attrib_slot; 00097 }; 00098 00099 #include "colorAttrib.I" 00100 00101 #endif 00102