00001 // Filename: materialAttrib.h 00002 // Created by: drose (04Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef MATERIALATTRIB_H 00020 #define MATERIALATTRIB_H 00021 00022 #include "pandabase.h" 00023 00024 #include "renderAttrib.h" 00025 #include "material.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : MaterialAttrib 00029 // Description : Indicates which, if any, material should be applied 00030 // to geometry. The material is used primarily to 00031 // control lighting effects, and isn't necessarily (or 00032 // useful) in the absence of lighting. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDA MaterialAttrib : public RenderAttrib { 00035 private: 00036 INLINE MaterialAttrib(); 00037 00038 PUBLISHED: 00039 static CPT(RenderAttrib) make(const Material *material); 00040 static CPT(RenderAttrib) make_off(); 00041 00042 INLINE bool is_off() const; 00043 INLINE const Material *get_material() const; 00044 00045 public: 00046 virtual void issue(GraphicsStateGuardianBase *gsg) const; 00047 virtual void output(ostream &out) const; 00048 00049 protected: 00050 virtual int compare_to_impl(const RenderAttrib *other) const; 00051 virtual RenderAttrib *make_default_impl() const; 00052 00053 private: 00054 CPT(Material) _material; 00055 00056 public: 00057 static void register_with_read_factory(); 00058 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00059 virtual int complete_pointers(TypedWritable **plist, BamReader *manager); 00060 00061 protected: 00062 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00063 void fillin(DatagramIterator &scan, BamReader *manager); 00064 00065 public: 00066 static TypeHandle get_class_type() { 00067 return _type_handle; 00068 } 00069 static void init_type() { 00070 RenderAttrib::init_type(); 00071 register_type(_type_handle, "MaterialAttrib", 00072 RenderAttrib::get_class_type()); 00073 } 00074 virtual TypeHandle get_type() const { 00075 return get_class_type(); 00076 } 00077 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00078 00079 private: 00080 static TypeHandle _type_handle; 00081 }; 00082 00083 #include "materialAttrib.I" 00084 00085 #endif 00086