00001 // Filename: eggMaterial.I 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 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: EggMaterial::set_diff 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE void EggMaterial:: 00026 set_diff(const Colorf &diff) { 00027 _diff = diff; 00028 _flags |= F_diff; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: EggMaterial::clear_diff 00033 // Access: Public 00034 // Description: 00035 //////////////////////////////////////////////////////////////////// 00036 INLINE void EggMaterial:: 00037 clear_diff() { 00038 _flags &= ~F_diff; 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: EggMaterial::has_diff 00043 // Access: Public 00044 // Description: 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE bool EggMaterial:: 00047 has_diff() const { 00048 return (_flags & F_diff) != 0; 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: EggMaterial::get_diff 00053 // Access: Public 00054 // Description: It is legal to call this even if has_diff() returns 00055 // false. If so, it simply returns the default diff 00056 // color. 00057 //////////////////////////////////////////////////////////////////// 00058 INLINE Colorf EggMaterial:: 00059 get_diff() const { 00060 if (has_diff()) { 00061 return _diff; 00062 } else { 00063 return Colorf(1.0, 1.0, 1.0, 1.0); 00064 } 00065 } 00066 00067 //////////////////////////////////////////////////////////////////// 00068 // Function: EggMaterial::set_amb 00069 // Access: Public 00070 // Description: 00071 //////////////////////////////////////////////////////////////////// 00072 INLINE void EggMaterial:: 00073 set_amb(const Colorf &amb) { 00074 _amb = amb; 00075 _flags |= F_amb; 00076 } 00077 00078 //////////////////////////////////////////////////////////////////// 00079 // Function: EggMaterial::clear_amb 00080 // Access: Public 00081 // Description: 00082 //////////////////////////////////////////////////////////////////// 00083 INLINE void EggMaterial:: 00084 clear_amb() { 00085 _flags &= ~F_amb; 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: EggMaterial::has_amb 00090 // Access: Public 00091 // Description: 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE bool EggMaterial:: 00094 has_amb() const { 00095 return (_flags & F_amb) != 0; 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: EggMaterial::get_amb 00100 // Access: Public 00101 // Description: It is legal to call this even if has_amb() returns 00102 // false. If so, it simply returns the default amb 00103 // color. 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE Colorf EggMaterial:: 00106 get_amb() const { 00107 if (has_amb()) { 00108 return _amb; 00109 } else { 00110 return Colorf(1.0, 1.0, 1.0, 1.0); 00111 } 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: EggMaterial::set_emit 00116 // Access: Public 00117 // Description: 00118 //////////////////////////////////////////////////////////////////// 00119 INLINE void EggMaterial:: 00120 set_emit(const Colorf &emit) { 00121 _emit = emit; 00122 _flags |= F_emit; 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: EggMaterial::clear_emit 00127 // Access: Public 00128 // Description: 00129 //////////////////////////////////////////////////////////////////// 00130 INLINE void EggMaterial:: 00131 clear_emit() { 00132 _flags &= ~F_emit; 00133 } 00134 00135 //////////////////////////////////////////////////////////////////// 00136 // Function: EggMaterial::has_emit 00137 // Access: Public 00138 // Description: 00139 //////////////////////////////////////////////////////////////////// 00140 INLINE bool EggMaterial:: 00141 has_emit() const { 00142 return (_flags & F_emit) != 0; 00143 } 00144 00145 //////////////////////////////////////////////////////////////////// 00146 // Function: EggMaterial::get_emit 00147 // Access: Public 00148 // Description: It is legal to call this even if has_emit() returns 00149 // false. If so, it simply returns the default emit 00150 // color. 00151 //////////////////////////////////////////////////////////////////// 00152 INLINE Colorf EggMaterial:: 00153 get_emit() const { 00154 if (has_emit()) { 00155 return _emit; 00156 } else { 00157 return Colorf(0.0, 0.0, 0.0, 1.0); 00158 } 00159 } 00160 00161 //////////////////////////////////////////////////////////////////// 00162 // Function: EggMaterial::set_spec 00163 // Access: Public 00164 // Description: 00165 //////////////////////////////////////////////////////////////////// 00166 INLINE void EggMaterial:: 00167 set_spec(const Colorf &spec) { 00168 _spec = spec; 00169 _flags |= F_spec; 00170 } 00171 00172 //////////////////////////////////////////////////////////////////// 00173 // Function: EggMaterial::clear_spec 00174 // Access: Public 00175 // Description: 00176 //////////////////////////////////////////////////////////////////// 00177 INLINE void EggMaterial:: 00178 clear_spec() { 00179 _flags &= ~F_spec; 00180 } 00181 00182 //////////////////////////////////////////////////////////////////// 00183 // Function: EggMaterial::has_spec 00184 // Access: Public 00185 // Description: 00186 //////////////////////////////////////////////////////////////////// 00187 INLINE bool EggMaterial:: 00188 has_spec() const { 00189 return (_flags & F_spec) != 0; 00190 } 00191 00192 //////////////////////////////////////////////////////////////////// 00193 // Function: EggMaterial::get_spec 00194 // Access: Public 00195 // Description: It is legal to call this even if has_spec() returns 00196 // false. If so, it simply returns the default spec 00197 // color. 00198 //////////////////////////////////////////////////////////////////// 00199 INLINE Colorf EggMaterial:: 00200 get_spec() const { 00201 if (has_spec()) { 00202 return _spec; 00203 } else { 00204 return Colorf(0.0, 0.0, 0.0, 1.0); 00205 } 00206 } 00207 00208 //////////////////////////////////////////////////////////////////// 00209 // Function: EggMaterial::set_shininess 00210 // Access: Public 00211 // Description: 00212 //////////////////////////////////////////////////////////////////// 00213 INLINE void EggMaterial:: 00214 set_shininess(double shininess) { 00215 _shininess = shininess; 00216 _flags |= F_shininess; 00217 } 00218 00219 //////////////////////////////////////////////////////////////////// 00220 // Function: EggMaterial::clear_shininess 00221 // Access: Public 00222 // Description: 00223 //////////////////////////////////////////////////////////////////// 00224 INLINE void EggMaterial:: 00225 clear_shininess() { 00226 _flags &= ~F_shininess; 00227 } 00228 00229 //////////////////////////////////////////////////////////////////// 00230 // Function: EggMaterial::has_shininess 00231 // Access: Public 00232 // Description: 00233 //////////////////////////////////////////////////////////////////// 00234 INLINE bool EggMaterial:: 00235 has_shininess() const { 00236 return (_flags & F_shininess) != 0; 00237 } 00238 00239 //////////////////////////////////////////////////////////////////// 00240 // Function: EggMaterial::get_shininess 00241 // Access: Public 00242 // Description: 00243 //////////////////////////////////////////////////////////////////// 00244 INLINE double EggMaterial:: 00245 get_shininess() const { 00246 if (has_shininess()) { 00247 return _shininess; 00248 } else { 00249 return 0.0; 00250 } 00251 } 00252 00253 //////////////////////////////////////////////////////////////////// 00254 // Function: EggMaterial::set_local 00255 // Access: Public 00256 // Description: 00257 //////////////////////////////////////////////////////////////////// 00258 INLINE void EggMaterial:: 00259 set_local(bool local) { 00260 _local = local; 00261 _flags |= F_local; 00262 } 00263 00264 //////////////////////////////////////////////////////////////////// 00265 // Function: EggMaterial::clear_local 00266 // Access: Public 00267 // Description: 00268 //////////////////////////////////////////////////////////////////// 00269 INLINE void EggMaterial:: 00270 clear_local() { 00271 _flags &= ~F_local; 00272 } 00273 00274 //////////////////////////////////////////////////////////////////// 00275 // Function: EggMaterial::has_local 00276 // Access: Public 00277 // Description: 00278 //////////////////////////////////////////////////////////////////// 00279 INLINE bool EggMaterial:: 00280 has_local() const { 00281 return (_flags & F_local) != 0; 00282 } 00283 00284 //////////////////////////////////////////////////////////////////// 00285 // Function: EggMaterial::get_local 00286 // Access: Public 00287 // Description: 00288 //////////////////////////////////////////////////////////////////// 00289 INLINE bool EggMaterial:: 00290 get_local() const { 00291 if (has_local()) { 00292 return _local; 00293 } else { 00294 return 0.0; 00295 } 00296 } 00297 00298 //////////////////////////////////////////////////////////////////// 00299 // Function: UniqueEggMaterials::Constructor 00300 // Access: Public 00301 // Description: 00302 //////////////////////////////////////////////////////////////////// 00303 INLINE UniqueEggMaterials:: 00304 UniqueEggMaterials(int eq) : _eq(eq) { 00305 } 00306 00307 //////////////////////////////////////////////////////////////////// 00308 // Function: UniqueEggMaterials::Function operator 00309 // Access: Public 00310 // Description: 00311 //////////////////////////////////////////////////////////////////// 00312 INLINE bool UniqueEggMaterials:: 00313 operator ()(const EggMaterial *t1, const EggMaterial *t2) const { 00314 return t1->sorts_less_than(*t2, _eq); 00315 } 00316