00001 // Filename: eggAttributes.I 00002 // Created by: drose (16Jan99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: EggAttributes::has_normal 00018 // Access: Published 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE bool EggAttributes:: 00022 has_normal() const { 00023 return (_flags & F_has_normal) != 0; 00024 } 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: EggAttributes::get_normal 00028 // Access: Published 00029 // Description: 00030 //////////////////////////////////////////////////////////////////// 00031 INLINE const LNormald &EggAttributes:: 00032 get_normal() const { 00033 nassertr(has_normal(), _normal); 00034 return _normal; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: EggAttributes::set_normal 00039 // Access: Published 00040 // Description: 00041 //////////////////////////////////////////////////////////////////// 00042 INLINE void EggAttributes:: 00043 set_normal(const LNormald &normal) { 00044 _normal = normal; 00045 _flags |= F_has_normal; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: EggAttributes::clear_normal 00050 // Access: Published 00051 // Description: 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE void EggAttributes:: 00054 clear_normal() { 00055 _flags &= ~F_has_normal; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: EggAttributes::matches_normal 00060 // Access: Published 00061 // Description: Returns true if this normal matches that of the other 00062 // EggAttributes object, include the morph list. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE bool EggAttributes:: 00065 matches_normal(const EggAttributes &other) const { 00066 if (((_flags ^ other._flags) & F_has_normal) != 0) { 00067 return false; 00068 } 00069 if (!has_normal()) { 00070 return true; 00071 } 00072 return (get_normal() == other.get_normal() && 00073 _dnormals.compare_to(other._dnormals, egg_parameters->_normal_threshold) == 0); 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: EggAttributes::copy_normal 00078 // Access: Published 00079 // Description: Sets this normal to be the same as the other's, 00080 // include morphs. If the other has no normal, this 00081 // clears the normal. 00082 //////////////////////////////////////////////////////////////////// 00083 INLINE void EggAttributes:: 00084 copy_normal(const EggAttributes &other) { 00085 if (!other.has_normal()) { 00086 clear_normal(); 00087 } else { 00088 set_normal(other.get_normal()); 00089 _dnormals = other._dnormals; 00090 } 00091 } 00092 00093 //////////////////////////////////////////////////////////////////// 00094 // Function: EggAttributes::has_color 00095 // Access: Published 00096 // Description: 00097 //////////////////////////////////////////////////////////////////// 00098 INLINE bool EggAttributes:: 00099 has_color() const { 00100 return (_flags & F_has_color) != 0; 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: EggAttributes::get_color 00105 // Access: Published 00106 // Description: Returns the color set on this particular attribute. 00107 // If there is no color set, returns white. 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE LColor EggAttributes:: 00110 get_color() const { 00111 if (has_color()) { 00112 return _color; 00113 } else { 00114 return LColor(1.0, 1.0, 1.0, 1.0); 00115 } 00116 } 00117 00118 //////////////////////////////////////////////////////////////////// 00119 // Function: EggAttributes:: 00120 // Access: Published 00121 // Description: 00122 //////////////////////////////////////////////////////////////////// 00123 INLINE void EggAttributes:: 00124 set_color(const LColor &color) { 00125 _color = color; 00126 _flags |= F_has_color; 00127 } 00128 00129 //////////////////////////////////////////////////////////////////// 00130 // Function: EggAttributes:: 00131 // Access: Published 00132 // Description: 00133 //////////////////////////////////////////////////////////////////// 00134 INLINE void EggAttributes:: 00135 clear_color() { 00136 _flags &= ~F_has_color; 00137 } 00138 00139 //////////////////////////////////////////////////////////////////// 00140 // Function: EggAttributes::matches_color 00141 // Access: Published 00142 // Description: Returns true if this color matches that of the other 00143 // EggAttributes object, include the morph list. 00144 //////////////////////////////////////////////////////////////////// 00145 INLINE bool EggAttributes:: 00146 matches_color(const EggAttributes &other) const { 00147 if (((_flags ^ other._flags) & F_has_color) != 0) { 00148 return false; 00149 } 00150 if (!has_color()) { 00151 return true; 00152 } 00153 return (get_color() == other.get_color() && 00154 _drgbas.compare_to(other._drgbas, egg_parameters->_color_threshold) == 0); 00155 } 00156 00157 //////////////////////////////////////////////////////////////////// 00158 // Function: EggAttributes::copy_color 00159 // Access: Published 00160 // Description: Sets this color to be the same as the other's, 00161 // include morphs. If the other has no color, this 00162 // clears the color. 00163 //////////////////////////////////////////////////////////////////// 00164 INLINE void EggAttributes:: 00165 copy_color(const EggAttributes &other) { 00166 if (!other.has_color()) { 00167 clear_color(); 00168 } else { 00169 set_color(other.get_color()); 00170 _drgbas = other._drgbas; 00171 } 00172 } 00173 00174 //////////////////////////////////////////////////////////////////// 00175 // Function: EggAttributes::sorts_less_than 00176 // Access: Published 00177 // Description: An ordering operator to compare two vertices for 00178 // sorting order. This imposes an arbitrary ordering 00179 // useful to identify unique vertices. 00180 //////////////////////////////////////////////////////////////////// 00181 INLINE bool EggAttributes:: 00182 sorts_less_than(const EggAttributes &other) const { 00183 return compare_to(other) < 0; 00184 }