Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/egg/eggMaterial.h

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

Generated on Fri May 2 00:37:41 2003 for Panda by doxygen1.3