00001 // Filename: somethingToEggConverter.I 00002 // Created by: drose (26Apr01) 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: SomethingToEggConverter::set_path_replace 00022 // Access: Public 00023 // Description: Replaces the PathReplace object (which specifies how 00024 // to mangle paths from the source to the destination 00025 // egg file) with a new one. 00026 //////////////////////////////////////////////////////////////////// 00027 INLINE void SomethingToEggConverter:: 00028 set_path_replace(PathReplace *path_replace) { 00029 _path_replace = path_replace; 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: SomethingToEggConverter::get_path_replace 00034 // Access: Public 00035 // Description: Returns a pointer to the PathReplace object 00036 // associated with this converter. If the converter is 00037 // non-const, this returns a non-const pointer, which 00038 // can be adjusted. 00039 //////////////////////////////////////////////////////////////////// 00040 INLINE PathReplace *SomethingToEggConverter:: 00041 get_path_replace() { 00042 return _path_replace; 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: SomethingToEggConverter::get_path_replace 00047 // Access: Public 00048 // Description: Returns a pointer to the PathReplace object 00049 // associated with this converter. If the converter is 00050 // non-const, this returns a non-const pointer, which 00051 // can be adjusted. 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE const PathReplace *SomethingToEggConverter:: 00054 get_path_replace() const { 00055 return _path_replace; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: SomethingToEggConverter::set_animation_convert 00060 // Access: Public 00061 // Description: Specifies how source animation will be converted into 00062 // egg structures. The default is AC_none, which means 00063 // animation tables will be ignored. This is only 00064 // meaningful for converters that understand animation. 00065 //////////////////////////////////////////////////////////////////// 00066 INLINE void SomethingToEggConverter:: 00067 set_animation_convert(AnimationConvert animation_convert) { 00068 _animation_convert = animation_convert; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: SomethingToEggConverter::get_animation_convert 00073 // Access: Public 00074 // Description: Returns how source animation will be converted into 00075 // egg structures. 00076 //////////////////////////////////////////////////////////////////// 00077 INLINE AnimationConvert SomethingToEggConverter:: 00078 get_animation_convert() const { 00079 return _animation_convert; 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: SomethingToEggConverter::set_character_name 00084 // Access: Public 00085 // Description: Specifies the name of the character generated. This 00086 // name should match between all the model and channel 00087 // egg files for a particular character and its 00088 // associated animations. 00089 //////////////////////////////////////////////////////////////////// 00090 INLINE void SomethingToEggConverter:: 00091 set_character_name(const string &character_name) { 00092 _character_name = character_name; 00093 } 00094 00095 //////////////////////////////////////////////////////////////////// 00096 // Function: SomethingToEggConverter::get_character_name 00097 // Access: Public 00098 // Description: Returns the name of the character generated. See 00099 // set_character_name(). 00100 //////////////////////////////////////////////////////////////////// 00101 INLINE const string &SomethingToEggConverter:: 00102 get_character_name() const { 00103 return _character_name; 00104 } 00105 00106 //////////////////////////////////////////////////////////////////// 00107 // Function: SomethingToEggConverter::set_start_frame 00108 // Access: Public 00109 // Description: Specifies the starting frame of the animation to 00110 // convert, in the units specified by 00111 // set_input_frame_rate(). If this is unspecified, the 00112 // starting frame is taken from the source, for instance 00113 // from the first frame of the animation slider. 00114 //////////////////////////////////////////////////////////////////// 00115 INLINE void SomethingToEggConverter:: 00116 set_start_frame(double start_frame) { 00117 _start_frame = start_frame; 00118 _control_flags |= CF_start_frame; 00119 } 00120 00121 //////////////////////////////////////////////////////////////////// 00122 // Function: SomethingToEggConverter::has_start_frame 00123 // Access: Public 00124 // Description: Returns true if the starting frame has been 00125 // explicitly specified via set_start_frame(), or false 00126 // if the starting frame should be implicit based on the 00127 // source. 00128 //////////////////////////////////////////////////////////////////// 00129 INLINE bool SomethingToEggConverter:: 00130 has_start_frame() const { 00131 return (_control_flags & CF_start_frame) != 0; 00132 } 00133 00134 //////////////////////////////////////////////////////////////////// 00135 // Function: SomethingToEggConverter::get_start_frame 00136 // Access: Public 00137 // Description: Returns the value set by a previous call to 00138 // set_start_frame(). It is an error to call this if 00139 // has_start_frame() returns false. 00140 //////////////////////////////////////////////////////////////////// 00141 INLINE double SomethingToEggConverter:: 00142 get_start_frame() const { 00143 nassertr(has_start_frame(), 0.0); 00144 return _start_frame; 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: SomethingToEggConverter::clear_start_frame 00149 // Access: Public 00150 // Description: Removes the value previously set by 00151 // set_start_frame(). 00152 //////////////////////////////////////////////////////////////////// 00153 INLINE void SomethingToEggConverter:: 00154 clear_start_frame() { 00155 _start_frame = 0.0; 00156 _control_flags &= ~CF_start_frame; 00157 } 00158 00159 //////////////////////////////////////////////////////////////////// 00160 // Function: SomethingToEggConverter::set_end_frame 00161 // Access: Public 00162 // Description: Specifies the ending frame of the animation to 00163 // convert, in the units specified by 00164 // set_input_frame_rate(). If this is unspecified, the 00165 // ending frame is taken from the source, for instance 00166 // from the last frame of the animation slider. 00167 //////////////////////////////////////////////////////////////////// 00168 INLINE void SomethingToEggConverter:: 00169 set_end_frame(double end_frame) { 00170 _end_frame = end_frame; 00171 _control_flags |= CF_end_frame; 00172 } 00173 00174 //////////////////////////////////////////////////////////////////// 00175 // Function: SomethingToEggConverter::has_end_frame 00176 // Access: Public 00177 // Description: Returns true if the ending frame has been 00178 // explicitly specified via set_end_frame(), or false 00179 // if the ending frame should be implicit based on the 00180 // source. 00181 //////////////////////////////////////////////////////////////////// 00182 INLINE bool SomethingToEggConverter:: 00183 has_end_frame() const { 00184 return (_control_flags & CF_end_frame) != 0; 00185 } 00186 00187 //////////////////////////////////////////////////////////////////// 00188 // Function: SomethingToEggConverter::get_end_frame 00189 // Access: Public 00190 // Description: Returns the value set by a previous call to 00191 // set_end_frame(). It is an error to call this if 00192 // has_end_frame() returns false. 00193 //////////////////////////////////////////////////////////////////// 00194 INLINE double SomethingToEggConverter:: 00195 get_end_frame() const { 00196 nassertr(has_end_frame(), 0.0); 00197 return _end_frame; 00198 } 00199 00200 //////////////////////////////////////////////////////////////////// 00201 // Function: SomethingToEggConverter::clear_end_frame 00202 // Access: Public 00203 // Description: Removes the value previously set by 00204 // set_end_frame(). 00205 //////////////////////////////////////////////////////////////////// 00206 INLINE void SomethingToEggConverter:: 00207 clear_end_frame() { 00208 _end_frame = 0.0; 00209 _control_flags &= ~CF_end_frame; 00210 } 00211 00212 //////////////////////////////////////////////////////////////////// 00213 // Function: SomethingToEggConverter::set_frame_inc 00214 // Access: Public 00215 // Description: Specifies the increment between frames to extract. 00216 // This is the amount to increment the time slider (in 00217 // units of internal_frame_rate) between extracting each 00218 // frame. If this is not specified, the default is 00219 // taken from the animation package, or 1.0 if the 00220 // animation package does not specified a frame 00221 // increment. 00222 //////////////////////////////////////////////////////////////////// 00223 INLINE void SomethingToEggConverter:: 00224 set_frame_inc(double frame_inc) { 00225 _frame_inc = frame_inc; 00226 _control_flags |= CF_frame_inc; 00227 } 00228 00229 //////////////////////////////////////////////////////////////////// 00230 // Function: SomethingToEggConverter::has_frame_inc 00231 // Access: Public 00232 // Description: Returns true if the frame increment has been 00233 // explicitly specified via set_frame_inc(), or false 00234 // if the ending frame should be implicit based on the 00235 // source. 00236 //////////////////////////////////////////////////////////////////// 00237 INLINE bool SomethingToEggConverter:: 00238 has_frame_inc() const { 00239 return (_control_flags & CF_frame_inc) != 0; 00240 } 00241 00242 //////////////////////////////////////////////////////////////////// 00243 // Function: SomethingToEggConverter::get_frame_inc 00244 // Access: Public 00245 // Description: Returns the value set by a previous call to 00246 // set_frame_inc(). It is an error to call this if 00247 // has_frame_inc() returns false. 00248 //////////////////////////////////////////////////////////////////// 00249 INLINE double SomethingToEggConverter:: 00250 get_frame_inc() const { 00251 nassertr(has_frame_inc(), 0.0); 00252 return _frame_inc; 00253 } 00254 00255 //////////////////////////////////////////////////////////////////// 00256 // Function: SomethingToEggConverter::clear_frame_inc 00257 // Access: Public 00258 // Description: Removes the value previously set by 00259 // set_frame_inc(). 00260 //////////////////////////////////////////////////////////////////// 00261 INLINE void SomethingToEggConverter:: 00262 clear_frame_inc() { 00263 _frame_inc = 0.0; 00264 _control_flags &= ~CF_frame_inc; 00265 } 00266 00267 //////////////////////////////////////////////////////////////////// 00268 // Function: SomethingToEggConverter::set_neutral_frame 00269 // Access: Public 00270 // Description: Specifies the frame of animation to represent the 00271 // neutral pose of the model. 00272 //////////////////////////////////////////////////////////////////// 00273 INLINE void SomethingToEggConverter:: 00274 set_neutral_frame(double neutral_frame) { 00275 _neutral_frame = neutral_frame; 00276 _control_flags |= CF_neutral_frame; 00277 } 00278 00279 //////////////////////////////////////////////////////////////////// 00280 // Function: SomethingToEggConverter::has_neutral_frame 00281 // Access: Public 00282 // Description: Returns true if the neutral frame has been 00283 // explicitly specified via set_neutral_frame(), or 00284 // false otherwise. 00285 //////////////////////////////////////////////////////////////////// 00286 INLINE bool SomethingToEggConverter:: 00287 has_neutral_frame() const { 00288 return (_control_flags & CF_neutral_frame) != 0; 00289 } 00290 00291 //////////////////////////////////////////////////////////////////// 00292 // Function: SomethingToEggConverter::get_neutral_frame 00293 // Access: Public 00294 // Description: Returns the value set by a previous call to 00295 // set_neutral_frame(). It is an error to call this if 00296 // has_neutral_frame() returns false. 00297 //////////////////////////////////////////////////////////////////// 00298 INLINE double SomethingToEggConverter:: 00299 get_neutral_frame() const { 00300 nassertr(has_neutral_frame(), 0.0); 00301 return _neutral_frame; 00302 } 00303 00304 //////////////////////////////////////////////////////////////////// 00305 // Function: SomethingToEggConverter::clear_neutral_frame 00306 // Access: Public 00307 // Description: Removes the value previously set by 00308 // set_neutral_frame(). 00309 //////////////////////////////////////////////////////////////////// 00310 INLINE void SomethingToEggConverter:: 00311 clear_neutral_frame() { 00312 _neutral_frame = 0.0; 00313 _control_flags &= ~CF_neutral_frame; 00314 } 00315 00316 //////////////////////////////////////////////////////////////////// 00317 // Function: SomethingToEggConverter::set_input_frame_rate 00318 // Access: Public 00319 // Description: Specifies the number of frames per second that is 00320 // represented by the "frame" unit in the animation 00321 // package. If this is omitted, it is taken from 00322 // whatever the file header indicates. Some animation 00323 // packages do not encode a frame rate, in which case 00324 // the default if this is omitted is the same as the 00325 // output frame rate. 00326 //////////////////////////////////////////////////////////////////// 00327 INLINE void SomethingToEggConverter:: 00328 set_input_frame_rate(double input_frame_rate) { 00329 _input_frame_rate = input_frame_rate; 00330 _control_flags |= CF_input_frame_rate; 00331 } 00332 00333 //////////////////////////////////////////////////////////////////// 00334 // Function: SomethingToEggConverter::has_input_frame_rate 00335 // Access: Public 00336 // Description: Returns true if the frame rate has been 00337 // explicitly specified via set_input_frame_rate(), or 00338 // false otherwise. 00339 //////////////////////////////////////////////////////////////////// 00340 INLINE bool SomethingToEggConverter:: 00341 has_input_frame_rate() const { 00342 return (_control_flags & CF_input_frame_rate) != 0; 00343 } 00344 00345 //////////////////////////////////////////////////////////////////// 00346 // Function: SomethingToEggConverter::get_input_frame_rate 00347 // Access: Public 00348 // Description: Returns the value set by a previous call to 00349 // set_input_frame_rate(). It is an error to call this 00350 // if has_input_frame_rate() returns false. 00351 //////////////////////////////////////////////////////////////////// 00352 INLINE double SomethingToEggConverter:: 00353 get_input_frame_rate() const { 00354 nassertr(has_input_frame_rate(), 0.0); 00355 return _input_frame_rate; 00356 } 00357 00358 //////////////////////////////////////////////////////////////////// 00359 // Function: SomethingToEggConverter::clear_input_frame_rate 00360 // Access: Public 00361 // Description: Removes the value previously set by 00362 // set_input_frame_rate(). 00363 //////////////////////////////////////////////////////////////////// 00364 INLINE void SomethingToEggConverter:: 00365 clear_input_frame_rate() { 00366 _input_frame_rate = 0.0; 00367 _control_flags &= ~CF_input_frame_rate; 00368 } 00369 00370 //////////////////////////////////////////////////////////////////// 00371 // Function: SomethingToEggConverter::set_output_frame_rate 00372 // Access: Public 00373 // Description: Specifies the number of frames per second that the 00374 // resulting animation should be played at. If this is 00375 // omitted, it is taken to be the same as the input 00376 // frame rate. 00377 //////////////////////////////////////////////////////////////////// 00378 INLINE void SomethingToEggConverter:: 00379 set_output_frame_rate(double output_frame_rate) { 00380 _output_frame_rate = output_frame_rate; 00381 _control_flags |= CF_output_frame_rate; 00382 } 00383 00384 //////////////////////////////////////////////////////////////////// 00385 // Function: SomethingToEggConverter::has_output_frame_rate 00386 // Access: Public 00387 // Description: Returns true if the frame rate has been 00388 // explicitly specified via set_output_frame_rate(), or 00389 // false otherwise. 00390 //////////////////////////////////////////////////////////////////// 00391 INLINE bool SomethingToEggConverter:: 00392 has_output_frame_rate() const { 00393 return (_control_flags & CF_output_frame_rate) != 0; 00394 } 00395 00396 //////////////////////////////////////////////////////////////////// 00397 // Function: SomethingToEggConverter::get_output_frame_rate 00398 // Access: Public 00399 // Description: Returns the value set by a previous call to 00400 // set_output_frame_rate(). It is an error to call this 00401 // if has_output_frame_rate() returns false. 00402 //////////////////////////////////////////////////////////////////// 00403 INLINE double SomethingToEggConverter:: 00404 get_output_frame_rate() const { 00405 nassertr(has_output_frame_rate(), 0.0); 00406 return _output_frame_rate; 00407 } 00408 00409 //////////////////////////////////////////////////////////////////// 00410 // Function: SomethingToEggConverter::clear_output_frame_rate 00411 // Access: Public 00412 // Description: Removes the value previously set by 00413 // set_output_frame_rate(). 00414 //////////////////////////////////////////////////////////////////// 00415 INLINE void SomethingToEggConverter:: 00416 clear_output_frame_rate() { 00417 _output_frame_rate = 0.0; 00418 _control_flags &= ~CF_output_frame_rate; 00419 } 00420 00421 //////////////////////////////////////////////////////////////////// 00422 // Function: SomethingToEggConverter::get_default_frame_rate 00423 // Access: Public, Static 00424 // Description: Returns the default frame rate if nothing is 00425 // specified for input_frame_rate or output_frame_rate, 00426 // and the animation package does not have an implicit 00427 // frame rate. 00428 //////////////////////////////////////////////////////////////////// 00429 INLINE double SomethingToEggConverter:: 00430 get_default_frame_rate() { 00431 return 24.0; 00432 } 00433 00434 //////////////////////////////////////////////////////////////////// 00435 // Function: SomethingToEggConverter::set_merge_externals 00436 // Access: Public 00437 // Description: Sets the merge_externals flag. When this is true, 00438 // external references within the source file are read 00439 // in and merged directly; otherwise, only a reference 00440 // to a similarly-named egg file is inserted. 00441 //////////////////////////////////////////////////////////////////// 00442 INLINE void SomethingToEggConverter:: 00443 set_merge_externals(bool merge_externals) { 00444 _merge_externals = merge_externals; 00445 } 00446 00447 //////////////////////////////////////////////////////////////////// 00448 // Function: SomethingToEggConverter::get_merge_externals 00449 // Access: Public 00450 // Description: Returns the current state of the merge_externals 00451 // flag. See set_merge_externals(). 00452 //////////////////////////////////////////////////////////////////// 00453 INLINE bool SomethingToEggConverter:: 00454 get_merge_externals() const { 00455 return _merge_externals; 00456 } 00457 00458 //////////////////////////////////////////////////////////////////// 00459 // Function: SomethingToEggConverter::clear_egg_data 00460 // Access: Public 00461 // Description: Sets the EggData to NULL and makes the converter 00462 // invalid. 00463 //////////////////////////////////////////////////////////////////// 00464 INLINE void SomethingToEggConverter:: 00465 clear_egg_data() { 00466 set_egg_data((EggData *)NULL, false); 00467 } 00468 00469 //////////////////////////////////////////////////////////////////// 00470 // Function: SomethingToEggConverter::get_egg_data 00471 // Access: Public 00472 // Description: Returns the EggData structure. 00473 //////////////////////////////////////////////////////////////////// 00474 INLINE EggData &SomethingToEggConverter:: 00475 get_egg_data() { 00476 return *_egg_data; 00477 } 00478 00479 //////////////////////////////////////////////////////////////////// 00480 // Function: SomethingToEggConverter::convert_texture_path 00481 // Access: Public 00482 // Description: Converts the indicated texture filename to a relative 00483 // or absolute or whatever filename, according to 00484 // _path_replace. 00485 //////////////////////////////////////////////////////////////////// 00486 INLINE Filename SomethingToEggConverter:: 00487 convert_texture_path(const Filename &orig_filename) { 00488 return _path_replace->convert_path(orig_filename, get_texture_path()); 00489 } 00490 00491 //////////////////////////////////////////////////////////////////// 00492 // Function: SomethingToEggConverter::convert_model_path 00493 // Access: Public 00494 // Description: Converts the indicated model filename to a relative 00495 // or absolute or whatever filename, according to 00496 // _path_replace. 00497 //////////////////////////////////////////////////////////////////// 00498 INLINE Filename SomethingToEggConverter:: 00499 convert_model_path(const Filename &orig_filename) { 00500 return _path_replace->convert_path(orig_filename); 00501 }