Panda3D
eggMaterial.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file eggMaterial.h
10  * @author drose
11  * @date 1999-01-29
12  */
13 
14 #ifndef EGGMATERIAL_H
15 #define EGGMATERIAL_H
16 
17 #include "pandabase.h"
18 
19 #include "eggNode.h"
20 
21 #include "luse.h"
22 
23 /**
24  *
25  */
26 class EXPCL_PANDA_EGG EggMaterial : public EggNode {
27 PUBLISHED:
28  explicit EggMaterial(const std::string &mref_name);
29  EggMaterial(const EggMaterial &copy);
30 
31  virtual void write(std::ostream &out, int indent_level) const;
32 
33  enum Equivalence {
34  E_attributes = 0x001,
35  E_mref_name = 0x002,
36  };
37 
38  bool is_equivalent_to(const EggMaterial &other, int eq) const;
39  bool sorts_less_than(const EggMaterial &other, int eq) const;
40 
41  INLINE void set_base(const LColor &base);
42  INLINE void clear_base();
43  INLINE bool has_base() const;
44  INLINE LColor get_base() const;
45 
46  INLINE void set_diff(const LColor &diff);
47  INLINE void clear_diff();
48  INLINE bool has_diff() const;
49  INLINE LColor get_diff() const;
50 
51  INLINE void set_amb(const LColor &amb);
52  INLINE void clear_amb();
53  INLINE bool has_amb() const;
54  INLINE LColor get_amb() const;
55 
56  INLINE void set_emit(const LColor &emit);
57  INLINE void clear_emit();
58  INLINE bool has_emit() const;
59  INLINE LColor get_emit() const;
60 
61  INLINE void set_spec(const LColor &spec);
62  INLINE void clear_spec();
63  INLINE bool has_spec() const;
64  INLINE LColor get_spec() const;
65 
66  INLINE void set_shininess(double shininess);
67  INLINE void clear_shininess();
68  INLINE bool has_shininess() const;
69  INLINE double get_shininess() const;
70 
71  INLINE void set_roughness(double roughness);
72  INLINE void clear_roughness();
73  INLINE bool has_roughness() const;
74  INLINE double get_roughness() const;
75 
76  INLINE void set_metallic(double metallic);
77  INLINE void clear_metallic();
78  INLINE bool has_metallic() const;
79  INLINE double get_metallic() const;
80 
81  INLINE void set_ior(double ior);
82  INLINE void clear_ior();
83  INLINE bool has_ior() const;
84  INLINE double get_ior() const;
85 
86  INLINE void set_local(bool local);
87  INLINE void clear_local();
88  INLINE bool has_local() const;
89  INLINE bool get_local() const;
90 
91 PUBLISHED:
92  MAKE_PROPERTY2(base, has_base, get_base, set_base, clear_base);
93  MAKE_PROPERTY2(diff, has_diff, get_diff, set_diff, clear_diff);
94  MAKE_PROPERTY2(amb, has_amb, get_amb, set_amb, clear_amb);
95  MAKE_PROPERTY2(emit, has_emit, get_emit, set_emit, clear_emit);
96  MAKE_PROPERTY2(spec, has_spec, get_spec, set_spec, clear_spec);
97  MAKE_PROPERTY2(shininess, has_shininess, get_shininess, set_shininess, clear_shininess);
98  MAKE_PROPERTY2(roughness, has_roughness, get_roughness, set_roughness, clear_roughness);
99  MAKE_PROPERTY2(metallic, has_metallic, get_metallic, set_metallic, clear_metallic);
100  MAKE_PROPERTY2(ior, has_ior, get_ior, set_ior, clear_ior);
101 
102  MAKE_PROPERTY2(local, has_local, get_local, set_local, clear_local);
103 
104 private:
105  enum Flags {
106  F_base = 0x001,
107  F_diff = 0x002,
108  F_amb = 0x004,
109  F_emit = 0x008,
110  F_spec = 0x010,
111  F_shininess = 0x020,
112  F_roughness = 0x040,
113  F_metallic = 0x080,
114  F_ior = 0x100,
115  F_local = 0x200
116  };
117 
118  LColor _base;
119  LColor _diff;
120  LColor _amb;
121  LColor _emit;
122  LColor _spec;
123  double _shininess;
124  double _roughness;
125  double _metallic;
126  double _ior;
127  bool _local;
128  int _flags;
129 
130 
131 public:
132  static TypeHandle get_class_type() {
133  return _type_handle;
134  }
135  static void init_type() {
136  EggNode::init_type();
137  register_type(_type_handle, "EggMaterial",
138  EggNode::get_class_type());
139  }
140  virtual TypeHandle get_type() const {
141  return get_class_type();
142  }
143  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
144 
145 private:
146  static TypeHandle _type_handle;
147 };
148 
149 /**
150  * An STL function object for sorting materials into order by properties.
151  * Returns true if the two referenced EggMaterial pointers are in sorted
152  * order, false otherwise.
153  */
154 class EXPCL_PANDA_EGG UniqueEggMaterials {
155 public:
156  INLINE UniqueEggMaterials(int eq = ~0);
157  INLINE bool operator ()(const EggMaterial *t1, const EggMaterial *t2) const;
158 
159  int _eq;
160 };
161 
162 #include "eggMaterial.I"
163 
164 #endif
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:36
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An STL function object for sorting materials into order by properties.
Definition: eggMaterial.h:154
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22