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