Panda3D
|
00001 // Filename: eggMaterial.h 00002 // Created by: drose (29Jan99) 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 EGGMATERIAL_H 00016 #define EGGMATERIAL_H 00017 00018 #include "pandabase.h" 00019 00020 #include "eggNode.h" 00021 00022 #include "luse.h" 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : EggMaterial 00026 // Description : 00027 //////////////////////////////////////////////////////////////////// 00028 class EXPCL_PANDAEGG EggMaterial : public EggNode { 00029 PUBLISHED: 00030 EggMaterial(const string &mref_name); 00031 EggMaterial(const EggMaterial ©); 00032 00033 virtual void write(ostream &out, int indent_level) const; 00034 00035 enum Equivalence { 00036 E_attributes = 0x001, 00037 E_mref_name = 0x002, 00038 }; 00039 00040 bool is_equivalent_to(const EggMaterial &other, int eq) const; 00041 bool sorts_less_than(const EggMaterial &other, int eq) const; 00042 00043 INLINE void set_diff(const LColor &diff); 00044 INLINE void clear_diff(); 00045 INLINE bool has_diff() const; 00046 INLINE LColor get_diff() const; 00047 00048 INLINE void set_amb(const LColor &amb); 00049 INLINE void clear_amb(); 00050 INLINE bool has_amb() const; 00051 INLINE LColor get_amb() const; 00052 00053 INLINE void set_emit(const LColor &emit); 00054 INLINE void clear_emit(); 00055 INLINE bool has_emit() const; 00056 INLINE LColor get_emit() const; 00057 00058 INLINE void set_spec(const LColor &spec); 00059 INLINE void clear_spec(); 00060 INLINE bool has_spec() const; 00061 INLINE LColor get_spec() const; 00062 00063 INLINE void set_shininess(double shininess); 00064 INLINE void clear_shininess(); 00065 INLINE bool has_shininess() const; 00066 INLINE double get_shininess() const; 00067 00068 INLINE void set_local(bool local); 00069 INLINE void clear_local(); 00070 INLINE bool has_local() const; 00071 INLINE bool get_local() const; 00072 00073 private: 00074 enum Flags { 00075 F_diff = 0x001, 00076 F_amb = 0x002, 00077 F_emit = 0x004, 00078 F_spec = 0x008, 00079 F_shininess = 0x010, 00080 F_local = 0x020 00081 }; 00082 00083 LColor _diff; 00084 LColor _amb; 00085 LColor _emit; 00086 LColor _spec; 00087 double _shininess; 00088 bool _local; 00089 int _flags; 00090 00091 00092 public: 00093 static TypeHandle get_class_type() { 00094 return _type_handle; 00095 } 00096 static void init_type() { 00097 EggNode::init_type(); 00098 register_type(_type_handle, "EggMaterial", 00099 EggNode::get_class_type()); 00100 } 00101 virtual TypeHandle get_type() const { 00102 return get_class_type(); 00103 } 00104 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00105 00106 private: 00107 static TypeHandle _type_handle; 00108 }; 00109 00110 //////////////////////////////////////////////////////////////////// 00111 // Class : UniqueEggMaterials 00112 // Description : An STL function object for sorting materials into 00113 // order by properties. Returns true if the two 00114 // referenced EggMaterial pointers are in sorted order, 00115 // false otherwise. 00116 //////////////////////////////////////////////////////////////////// 00117 class EXPCL_PANDAEGG UniqueEggMaterials { 00118 public: 00119 INLINE UniqueEggMaterials(int eq = ~0); 00120 INLINE bool operator ()(const EggMaterial *t1, const EggMaterial *t2) const; 00121 00122 int _eq; 00123 }; 00124 00125 #include "eggMaterial.I" 00126 00127 #endif