Panda3D
 All Classes Functions Variables Enumerations
eggAttributes.I
1 // Filename: eggAttributes.I
2 // Created by: drose (16Jan99)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: EggAttributes::has_normal
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE bool EggAttributes::
22 has_normal() const {
23  return (_flags & F_has_normal) != 0;
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: EggAttributes::get_normal
28 // Access: Published
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE const LNormald &EggAttributes::
32 get_normal() const {
33  nassertr(has_normal(), _normal);
34  return _normal;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: EggAttributes::set_normal
39 // Access: Published
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 INLINE void EggAttributes::
43 set_normal(const LNormald &normal) {
44  _normal = normal;
45  _flags |= F_has_normal;
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: EggAttributes::clear_normal
50 // Access: Published
51 // Description:
52 ////////////////////////////////////////////////////////////////////
53 INLINE void EggAttributes::
54 clear_normal() {
55  _flags &= ~F_has_normal;
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: EggAttributes::matches_normal
60 // Access: Published
61 // Description: Returns true if this normal matches that of the other
62 // EggAttributes object, include the morph list.
63 ////////////////////////////////////////////////////////////////////
64 INLINE bool EggAttributes::
65 matches_normal(const EggAttributes &other) const {
66  if (((_flags ^ other._flags) & F_has_normal) != 0) {
67  return false;
68  }
69  if (!has_normal()) {
70  return true;
71  }
72  return (get_normal() == other.get_normal() &&
73  _dnormals.compare_to(other._dnormals, egg_parameters->_normal_threshold) == 0);
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: EggAttributes::copy_normal
78 // Access: Published
79 // Description: Sets this normal to be the same as the other's,
80 // include morphs. If the other has no normal, this
81 // clears the normal.
82 ////////////////////////////////////////////////////////////////////
83 INLINE void EggAttributes::
84 copy_normal(const EggAttributes &other) {
85  if (!other.has_normal()) {
86  clear_normal();
87  } else {
88  set_normal(other.get_normal());
89  _dnormals = other._dnormals;
90  }
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: EggAttributes::has_color
95 // Access: Published
96 // Description:
97 ////////////////////////////////////////////////////////////////////
98 INLINE bool EggAttributes::
99 has_color() const {
100  return (_flags & F_has_color) != 0;
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: EggAttributes::get_color
105 // Access: Published
106 // Description: Returns the color set on this particular attribute.
107 // If there is no color set, returns white.
108 ////////////////////////////////////////////////////////////////////
109 INLINE LColor EggAttributes::
110 get_color() const {
111  if (has_color()) {
112  return _color;
113  } else {
114  return LColor(1.0, 1.0, 1.0, 1.0);
115  }
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: EggAttributes::
120 // Access: Published
121 // Description:
122 ////////////////////////////////////////////////////////////////////
123 INLINE void EggAttributes::
124 set_color(const LColor &color) {
125  _color = color;
126  _flags |= F_has_color;
127 }
128 
129 ////////////////////////////////////////////////////////////////////
130 // Function: EggAttributes::
131 // Access: Published
132 // Description:
133 ////////////////////////////////////////////////////////////////////
134 INLINE void EggAttributes::
135 clear_color() {
136  _flags &= ~F_has_color;
137 }
138 
139 ////////////////////////////////////////////////////////////////////
140 // Function: EggAttributes::matches_color
141 // Access: Published
142 // Description: Returns true if this color matches that of the other
143 // EggAttributes object, include the morph list.
144 ////////////////////////////////////////////////////////////////////
145 INLINE bool EggAttributes::
146 matches_color(const EggAttributes &other) const {
147  if (((_flags ^ other._flags) & F_has_color) != 0) {
148  return false;
149  }
150  if (!has_color()) {
151  return true;
152  }
153  return (get_color() == other.get_color() &&
154  _drgbas.compare_to(other._drgbas, egg_parameters->_color_threshold) == 0);
155 }
156 
157 ////////////////////////////////////////////////////////////////////
158 // Function: EggAttributes::copy_color
159 // Access: Published
160 // Description: Sets this color to be the same as the other's,
161 // include morphs. If the other has no color, this
162 // clears the color.
163 ////////////////////////////////////////////////////////////////////
164 INLINE void EggAttributes::
165 copy_color(const EggAttributes &other) {
166  if (!other.has_color()) {
167  clear_color();
168  } else {
169  set_color(other.get_color());
170  _drgbas = other._drgbas;
171  }
172 }
173 
174 ////////////////////////////////////////////////////////////////////
175 // Function: EggAttributes::sorts_less_than
176 // Access: Published
177 // Description: An ordering operator to compare two vertices for
178 // sorting order. This imposes an arbitrary ordering
179 // useful to identify unique vertices.
180 ////////////////////////////////////////////////////////////////////
181 INLINE bool EggAttributes::
182 sorts_less_than(const EggAttributes &other) const {
183  return compare_to(other) < 0;
184 }
bool matches_color(const EggAttributes &other) const
Returns true if this color matches that of the other EggAttributes object, include the morph list...
LColor get_color() const
Returns the color set on this particular attribute.
void copy_normal(const EggAttributes &other)
Sets this normal to be the same as the other&#39;s, include morphs.
Definition: eggAttributes.I:84
int compare_to(const EggAttributes &other) const
An ordering operator to compare two vertices for sorting order.
bool matches_normal(const EggAttributes &other) const
Returns true if this normal matches that of the other EggAttributes object, include the morph list...
Definition: eggAttributes.I:65
int compare_to(const EggMorphList< MorphType > &other, double threshold) const
compare_to() compares a different space than the operator methods, which only check the morph&#39;s name...
Definition: eggMorphList.I:101
The set of attributes that may be applied to vertices as well as polygons, such as surface normal and...
Definition: eggAttributes.h:37
void copy_color(const EggAttributes &other)
Sets this color to be the same as the other&#39;s, include morphs.
bool sorts_less_than(const EggAttributes &other) const
An ordering operator to compare two vertices for sorting order.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:746