Panda3D

somethingToEggConverter.I

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