00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MATERIAL_H
00016 #define MATERIAL_H
00017
00018 #include "pandabase.h"
00019
00020 #include "typedWritableReferenceCount.h"
00021 #include "namable.h"
00022 #include "luse.h"
00023 #include "numeric_types.h"
00024 #include "config_gobj.h"
00025
00026 class FactoryParams;
00027
00028
00029
00030
00031
00032
00033
00034 class EXPCL_PANDA_GOBJ Material : public TypedWritableReferenceCount, public Namable {
00035 PUBLISHED:
00036 INLINE Material(const string &name = "");
00037 INLINE Material(const Material ©);
00038 void operator = (const Material ©);
00039 INLINE ~Material();
00040
00041 INLINE static Material *get_default();
00042
00043 INLINE bool has_ambient() const;
00044 INLINE const LColor &get_ambient() const;
00045 void set_ambient(const LColor &color);
00046 INLINE void clear_ambient();
00047
00048 INLINE bool has_diffuse() const;
00049 INLINE const LColor &get_diffuse() const;
00050 void set_diffuse(const LColor &color);
00051 INLINE void clear_diffuse();
00052
00053 INLINE bool has_specular() const;
00054 INLINE const LColor &get_specular() const;
00055 void set_specular(const LColor &color);
00056 INLINE void clear_specular();
00057
00058 INLINE bool has_emission() const;
00059 INLINE const LColor &get_emission() const;
00060 void set_emission(const LColor &color);
00061 INLINE void clear_emission();
00062
00063 INLINE PN_stdfloat get_shininess() const;
00064 INLINE void set_shininess(PN_stdfloat shininess);
00065
00066 INLINE bool get_local() const;
00067 INLINE void set_local(bool local);
00068 INLINE bool get_twoside() const;
00069 INLINE void set_twoside(bool twoside);
00070
00071 INLINE bool operator == (const Material &other) const;
00072 INLINE bool operator != (const Material &other) const;
00073 INLINE bool operator < (const Material &other) const;
00074
00075 int compare_to(const Material &other) const;
00076
00077 void output(ostream &out) const;
00078 void write(ostream &out, int indent) const;
00079
00080 INLINE bool is_attrib_locked() const;
00081 INLINE void set_attrib_lock();
00082
00083 private:
00084 LColor _ambient;
00085 LColor _diffuse;
00086 LColor _specular;
00087 LColor _emission;
00088 PN_stdfloat _shininess;
00089
00090 static PT(Material) _default;
00091
00092 enum Flags {
00093 F_ambient = 0x001,
00094 F_diffuse = 0x002,
00095 F_specular = 0x004,
00096 F_emission = 0x008,
00097 F_local = 0x010,
00098 F_twoside = 0x020,
00099 F_attrib_lock = 0x040
00100 };
00101 int _flags;
00102
00103 public:
00104 static void register_with_read_factory();
00105 virtual void write_datagram(BamWriter *manager, Datagram &me);
00106
00107 protected:
00108 static TypedWritable *make_Material(const FactoryParams ¶ms);
00109 void fillin(DatagramIterator &scan, BamReader *manager);
00110
00111 public:
00112 static TypeHandle get_class_type() {
00113 return _type_handle;
00114 }
00115 static void init_type() {
00116 TypedWritableReferenceCount::init_type();
00117 register_type(_type_handle, "Material",
00118 TypedWritableReferenceCount::get_class_type());
00119 }
00120 virtual TypeHandle get_type() const {
00121 return get_class_type();
00122 }
00123 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00124
00125 private:
00126
00127 static TypeHandle _type_handle;
00128 };
00129
00130 INLINE ostream &operator << (ostream &out, const Material &m) {
00131 m.output(out);
00132 return out;
00133 }
00134
00135 #include "material.I"
00136
00137 #endif