Panda3D
|
00001 // Filename: materialAttrib.h 00002 // Created by: drose (04Mar02) 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 MATERIALATTRIB_H 00016 #define MATERIALATTRIB_H 00017 00018 #include "pandabase.h" 00019 00020 #include "renderAttrib.h" 00021 #include "material.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : MaterialAttrib 00025 // Description : Indicates which, if any, material should be applied 00026 // to geometry. The material is used primarily to 00027 // control lighting effects, and isn't necessary (or 00028 // useful) in the absence of lighting. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDA_PGRAPH MaterialAttrib : public RenderAttrib { 00031 private: 00032 INLINE MaterialAttrib(); 00033 00034 PUBLISHED: 00035 static CPT(RenderAttrib) make(Material *material); 00036 static CPT(RenderAttrib) make_off(); 00037 static CPT(RenderAttrib) make_default(); 00038 00039 INLINE bool is_off() const; 00040 INLINE Material *get_material() const; 00041 00042 public: 00043 virtual void output(ostream &out) const; 00044 00045 protected: 00046 virtual int compare_to_impl(const RenderAttrib *other) const; 00047 00048 private: 00049 PT(Material) _material; 00050 00051 PUBLISHED: 00052 static int get_class_slot() { 00053 return _attrib_slot; 00054 } 00055 virtual int get_slot() const { 00056 return get_class_slot(); 00057 } 00058 00059 public: 00060 static void register_with_read_factory(); 00061 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00062 virtual int complete_pointers(TypedWritable **plist, BamReader *manager); 00063 00064 protected: 00065 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00066 void fillin(DatagramIterator &scan, BamReader *manager); 00067 00068 public: 00069 static TypeHandle get_class_type() { 00070 return _type_handle; 00071 } 00072 static void init_type() { 00073 RenderAttrib::init_type(); 00074 register_type(_type_handle, "MaterialAttrib", 00075 RenderAttrib::get_class_type()); 00076 _attrib_slot = register_slot(_type_handle, 100, make_default); 00077 } 00078 virtual TypeHandle get_type() const { 00079 return get_class_type(); 00080 } 00081 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00082 00083 private: 00084 static TypeHandle _type_handle; 00085 static int _attrib_slot; 00086 }; 00087 00088 #include "materialAttrib.I" 00089 00090 #endif 00091