Panda3D
 All Classes Functions Variables Enumerations
eggMaterial.h
1 // Filename: eggMaterial.h
2 // Created by: drose (29Jan99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGMATERIAL_H
16 #define EGGMATERIAL_H
17 
18 #include "pandabase.h"
19 
20 #include "eggNode.h"
21 
22 #include "luse.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : EggMaterial
26 // Description :
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDAEGG EggMaterial : public EggNode {
29 PUBLISHED:
30  EggMaterial(const string &mref_name);
31  EggMaterial(const EggMaterial &copy);
32 
33  virtual void write(ostream &out, int indent_level) const;
34 
35  enum Equivalence {
36  E_attributes = 0x001,
37  E_mref_name = 0x002,
38  };
39 
40  bool is_equivalent_to(const EggMaterial &other, int eq) const;
41  bool sorts_less_than(const EggMaterial &other, int eq) const;
42 
43  INLINE void set_diff(const LColor &diff);
44  INLINE void clear_diff();
45  INLINE bool has_diff() const;
46  INLINE LColor get_diff() const;
47 
48  INLINE void set_amb(const LColor &amb);
49  INLINE void clear_amb();
50  INLINE bool has_amb() const;
51  INLINE LColor get_amb() const;
52 
53  INLINE void set_emit(const LColor &emit);
54  INLINE void clear_emit();
55  INLINE bool has_emit() const;
56  INLINE LColor get_emit() const;
57 
58  INLINE void set_spec(const LColor &spec);
59  INLINE void clear_spec();
60  INLINE bool has_spec() const;
61  INLINE LColor get_spec() const;
62 
63  INLINE void set_shininess(double shininess);
64  INLINE void clear_shininess();
65  INLINE bool has_shininess() const;
66  INLINE double get_shininess() const;
67 
68  INLINE void set_local(bool local);
69  INLINE void clear_local();
70  INLINE bool has_local() const;
71  INLINE bool get_local() const;
72 
73 private:
74  enum Flags {
75  F_diff = 0x001,
76  F_amb = 0x002,
77  F_emit = 0x004,
78  F_spec = 0x008,
79  F_shininess = 0x010,
80  F_local = 0x020
81  };
82 
83  LColor _diff;
84  LColor _amb;
85  LColor _emit;
86  LColor _spec;
87  double _shininess;
88  bool _local;
89  int _flags;
90 
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  EggNode::init_type();
98  register_type(_type_handle, "EggMaterial",
99  EggNode::get_class_type());
100  }
101  virtual TypeHandle get_type() const {
102  return get_class_type();
103  }
104  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
105 
106 private:
107  static TypeHandle _type_handle;
108 };
109 
110 ////////////////////////////////////////////////////////////////////
111 // Class : UniqueEggMaterials
112 // Description : An STL function object for sorting materials into
113 // order by properties. Returns true if the two
114 // referenced EggMaterial pointers are in sorted order,
115 // false otherwise.
116 ////////////////////////////////////////////////////////////////////
117 class EXPCL_PANDAEGG UniqueEggMaterials {
118 public:
119  INLINE UniqueEggMaterials(int eq = ~0);
120  INLINE bool operator ()(const EggMaterial *t1, const EggMaterial *t2) const;
121 
122  int _eq;
123 };
124 
125 #include "eggMaterial.I"
126 
127 #endif
An STL function object for sorting materials into order by properties.
Definition: eggMaterial.h:117
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:38
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85