Panda3D
somethingToEggConverter.I
1 // Filename: somethingToEggConverter.I
2 // Created by: drose (26Apr01)
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: SomethingToEggConverter::clear_error
18 // Access: Public
19 // Description: Resets the error flag to the no-error state.
20 // had_error() will return false until a new error is
21 // generated.
22 ////////////////////////////////////////////////////////////////////
23 INLINE void SomethingToEggConverter::
25  _error = false;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: SomethingToEggConverter::had_error
30 // Access: Public
31 // Description: Returns true if an error was detected during the
32 // conversion process (unless _allow_errors is true),
33 // false otherwise.
34 ////////////////////////////////////////////////////////////////////
35 INLINE bool SomethingToEggConverter::
36 had_error() const {
37  return !_allow_errors && (_error || _path_replace->had_error());
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: SomethingToEggConverter::set_path_replace
42 // Access: Public
43 // Description: Replaces the PathReplace object (which specifies how
44 // to mangle paths from the source to the destination
45 // egg file) with a new one.
46 ////////////////////////////////////////////////////////////////////
47 INLINE void SomethingToEggConverter::
48 set_path_replace(PathReplace *path_replace) {
49  _path_replace = path_replace;
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: SomethingToEggConverter::get_path_replace
54 // Access: Public
55 // Description: Returns a pointer to the PathReplace object
56 // associated with this converter. If the converter is
57 // non-const, this returns a non-const pointer, which
58 // can be adjusted.
59 ////////////////////////////////////////////////////////////////////
62  return _path_replace;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: SomethingToEggConverter::get_path_replace
67 // Access: Public
68 // Description: Returns a pointer to the PathReplace object
69 // associated with this converter. If the converter is
70 // non-const, this returns a non-const pointer, which
71 // can be adjusted.
72 ////////////////////////////////////////////////////////////////////
75  return _path_replace;
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: SomethingToEggConverter::set_animation_convert
80 // Access: Public
81 // Description: Specifies how source animation will be converted into
82 // egg structures. The default is AC_none, which means
83 // animation tables will be ignored. This is only
84 // meaningful for converters that understand animation.
85 ////////////////////////////////////////////////////////////////////
86 INLINE void SomethingToEggConverter::
87 set_animation_convert(AnimationConvert animation_convert) {
88  _animation_convert = animation_convert;
89 }
90 
91 ////////////////////////////////////////////////////////////////////
92 // Function: SomethingToEggConverter::get_animation_convert
93 // Access: Public
94 // Description: Returns how source animation will be converted into
95 // egg structures.
96 ////////////////////////////////////////////////////////////////////
97 INLINE AnimationConvert SomethingToEggConverter::
99  return _animation_convert;
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: SomethingToEggConverter::set_character_name
104 // Access: Public
105 // Description: Specifies the name of the character generated. This
106 // name should match between all the model and channel
107 // egg files for a particular character and its
108 // associated animations.
109 ////////////////////////////////////////////////////////////////////
110 INLINE void SomethingToEggConverter::
111 set_character_name(const string &character_name) {
112  _character_name = character_name;
113 }
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: SomethingToEggConverter::get_character_name
117 // Access: Public
118 // Description: Returns the name of the character generated. See
119 // set_character_name().
120 ////////////////////////////////////////////////////////////////////
121 INLINE const string &SomethingToEggConverter::
123  return _character_name;
124 }
125 
126 ////////////////////////////////////////////////////////////////////
127 // Function: SomethingToEggConverter::set_start_frame
128 // Access: Public
129 // Description: Specifies the starting frame of the animation to
130 // convert, in the units specified by
131 // set_input_frame_rate(). If this is unspecified, the
132 // starting frame is taken from the source, for instance
133 // from the first frame of the animation slider.
134 ////////////////////////////////////////////////////////////////////
135 INLINE void SomethingToEggConverter::
136 set_start_frame(double start_frame) {
137  _start_frame = start_frame;
138  _control_flags |= CF_start_frame;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: SomethingToEggConverter::has_start_frame
143 // Access: Public
144 // Description: Returns true if the starting frame has been
145 // explicitly specified via set_start_frame(), or false
146 // if the starting frame should be implicit based on the
147 // source.
148 ////////////////////////////////////////////////////////////////////
149 INLINE bool SomethingToEggConverter::
151  return (_control_flags & CF_start_frame) != 0;
152 }
153 
154 ////////////////////////////////////////////////////////////////////
155 // Function: SomethingToEggConverter::get_start_frame
156 // Access: Public
157 // Description: Returns the value set by a previous call to
158 // set_start_frame(). It is an error to call this if
159 // has_start_frame() returns false.
160 ////////////////////////////////////////////////////////////////////
161 INLINE double SomethingToEggConverter::
163  nassertr(has_start_frame(), 0.0);
164  return _start_frame;
165 }
166 
167 ////////////////////////////////////////////////////////////////////
168 // Function: SomethingToEggConverter::clear_start_frame
169 // Access: Public
170 // Description: Removes the value previously set by
171 // set_start_frame().
172 ////////////////////////////////////////////////////////////////////
173 INLINE void SomethingToEggConverter::
175  _start_frame = 0.0;
176  _control_flags &= ~CF_start_frame;
177 }
178 
179 ////////////////////////////////////////////////////////////////////
180 // Function: SomethingToEggConverter::set_end_frame
181 // Access: Public
182 // Description: Specifies the ending frame of the animation to
183 // convert, in the units specified by
184 // set_input_frame_rate(). If this is unspecified, the
185 // ending frame is taken from the source, for instance
186 // from the last frame of the animation slider.
187 ////////////////////////////////////////////////////////////////////
188 INLINE void SomethingToEggConverter::
189 set_end_frame(double end_frame) {
190  _end_frame = end_frame;
191  _control_flags |= CF_end_frame;
192 }
193 
194 ////////////////////////////////////////////////////////////////////
195 // Function: SomethingToEggConverter::has_end_frame
196 // Access: Public
197 // Description: Returns true if the ending frame has been
198 // explicitly specified via set_end_frame(), or false
199 // if the ending frame should be implicit based on the
200 // source.
201 ////////////////////////////////////////////////////////////////////
202 INLINE bool SomethingToEggConverter::
203 has_end_frame() const {
204  return (_control_flags & CF_end_frame) != 0;
205 }
206 
207 ////////////////////////////////////////////////////////////////////
208 // Function: SomethingToEggConverter::get_end_frame
209 // Access: Public
210 // Description: Returns the value set by a previous call to
211 // set_end_frame(). It is an error to call this if
212 // has_end_frame() returns false.
213 ////////////////////////////////////////////////////////////////////
214 INLINE double SomethingToEggConverter::
215 get_end_frame() const {
216  nassertr(has_end_frame(), 0.0);
217  return _end_frame;
218 }
219 
220 ////////////////////////////////////////////////////////////////////
221 // Function: SomethingToEggConverter::clear_end_frame
222 // Access: Public
223 // Description: Removes the value previously set by
224 // set_end_frame().
225 ////////////////////////////////////////////////////////////////////
226 INLINE void SomethingToEggConverter::
228  _end_frame = 0.0;
229  _control_flags &= ~CF_end_frame;
230 }
231 
232 ////////////////////////////////////////////////////////////////////
233 // Function: SomethingToEggConverter::set_frame_inc
234 // Access: Public
235 // Description: Specifies the increment between frames to extract.
236 // This is the amount to increment the time slider (in
237 // units of internal_frame_rate) between extracting each
238 // frame. If this is not specified, the default is
239 // taken from the animation package, or 1.0 if the
240 // animation package does not specified a frame
241 // increment.
242 ////////////////////////////////////////////////////////////////////
243 INLINE void SomethingToEggConverter::
244 set_frame_inc(double frame_inc) {
245  _frame_inc = frame_inc;
246  _control_flags |= CF_frame_inc;
247 }
248 
249 ////////////////////////////////////////////////////////////////////
250 // Function: SomethingToEggConverter::has_frame_inc
251 // Access: Public
252 // Description: Returns true if the frame increment has been
253 // explicitly specified via set_frame_inc(), or false
254 // if the ending frame should be implicit based on the
255 // source.
256 ////////////////////////////////////////////////////////////////////
257 INLINE bool SomethingToEggConverter::
258 has_frame_inc() const {
259  return (_control_flags & CF_frame_inc) != 0;
260 }
261 
262 ////////////////////////////////////////////////////////////////////
263 // Function: SomethingToEggConverter::get_frame_inc
264 // Access: Public
265 // Description: Returns the value set by a previous call to
266 // set_frame_inc(). It is an error to call this if
267 // has_frame_inc() returns false.
268 ////////////////////////////////////////////////////////////////////
269 INLINE double SomethingToEggConverter::
270 get_frame_inc() const {
271  nassertr(has_frame_inc(), 0.0);
272  return _frame_inc;
273 }
274 
275 ////////////////////////////////////////////////////////////////////
276 // Function: SomethingToEggConverter::clear_frame_inc
277 // Access: Public
278 // Description: Removes the value previously set by
279 // set_frame_inc().
280 ////////////////////////////////////////////////////////////////////
281 INLINE void SomethingToEggConverter::
283  _frame_inc = 0.0;
284  _control_flags &= ~CF_frame_inc;
285 }
286 
287 ////////////////////////////////////////////////////////////////////
288 // Function: SomethingToEggConverter::set_neutral_frame
289 // Access: Public
290 // Description: Specifies the frame of animation to represent the
291 // neutral pose of the model.
292 ////////////////////////////////////////////////////////////////////
293 INLINE void SomethingToEggConverter::
294 set_neutral_frame(double neutral_frame) {
295  _neutral_frame = neutral_frame;
296  _control_flags |= CF_neutral_frame;
297 }
298 
299 ////////////////////////////////////////////////////////////////////
300 // Function: SomethingToEggConverter::has_neutral_frame
301 // Access: Public
302 // Description: Returns true if the neutral frame has been
303 // explicitly specified via set_neutral_frame(), or
304 // false otherwise.
305 ////////////////////////////////////////////////////////////////////
306 INLINE bool SomethingToEggConverter::
308  return (_control_flags & CF_neutral_frame) != 0;
309 }
310 
311 ////////////////////////////////////////////////////////////////////
312 // Function: SomethingToEggConverter::get_neutral_frame
313 // Access: Public
314 // Description: Returns the value set by a previous call to
315 // set_neutral_frame(). It is an error to call this if
316 // has_neutral_frame() returns false.
317 ////////////////////////////////////////////////////////////////////
318 INLINE double SomethingToEggConverter::
320  nassertr(has_neutral_frame(), 0.0);
321  return _neutral_frame;
322 }
323 
324 ////////////////////////////////////////////////////////////////////
325 // Function: SomethingToEggConverter::clear_neutral_frame
326 // Access: Public
327 // Description: Removes the value previously set by
328 // set_neutral_frame().
329 ////////////////////////////////////////////////////////////////////
330 INLINE void SomethingToEggConverter::
332  _neutral_frame = 0.0;
333  _control_flags &= ~CF_neutral_frame;
334 }
335 
336 ////////////////////////////////////////////////////////////////////
337 // Function: SomethingToEggConverter::set_input_frame_rate
338 // Access: Public
339 // Description: Specifies the number of frames per second that is
340 // represented by the "frame" unit in the animation
341 // package. If this is omitted, it is taken from
342 // whatever the file header indicates. Some animation
343 // packages do not encode a frame rate, in which case
344 // the default if this is omitted is the same as the
345 // output frame rate.
346 ////////////////////////////////////////////////////////////////////
347 INLINE void SomethingToEggConverter::
348 set_input_frame_rate(double input_frame_rate) {
349  _input_frame_rate = input_frame_rate;
350  _control_flags |= CF_input_frame_rate;
351 }
352 
353 ////////////////////////////////////////////////////////////////////
354 // Function: SomethingToEggConverter::has_input_frame_rate
355 // Access: Public
356 // Description: Returns true if the frame rate has been
357 // explicitly specified via set_input_frame_rate(), or
358 // false otherwise.
359 ////////////////////////////////////////////////////////////////////
360 INLINE bool SomethingToEggConverter::
362  return (_control_flags & CF_input_frame_rate) != 0;
363 }
364 
365 ////////////////////////////////////////////////////////////////////
366 // Function: SomethingToEggConverter::get_input_frame_rate
367 // Access: Public
368 // Description: Returns the value set by a previous call to
369 // set_input_frame_rate(). It is an error to call this
370 // if has_input_frame_rate() returns false.
371 ////////////////////////////////////////////////////////////////////
372 INLINE double SomethingToEggConverter::
374  nassertr(has_input_frame_rate(), 0.0);
375  return _input_frame_rate;
376 }
377 
378 ////////////////////////////////////////////////////////////////////
379 // Function: SomethingToEggConverter::clear_input_frame_rate
380 // Access: Public
381 // Description: Removes the value previously set by
382 // set_input_frame_rate().
383 ////////////////////////////////////////////////////////////////////
384 INLINE void SomethingToEggConverter::
386  _input_frame_rate = 0.0;
387  _control_flags &= ~CF_input_frame_rate;
388 }
389 
390 ////////////////////////////////////////////////////////////////////
391 // Function: SomethingToEggConverter::set_output_frame_rate
392 // Access: Public
393 // Description: Specifies the number of frames per second that the
394 // resulting animation should be played at. If this is
395 // omitted, it is taken to be the same as the input
396 // frame rate.
397 ////////////////////////////////////////////////////////////////////
398 INLINE void SomethingToEggConverter::
399 set_output_frame_rate(double output_frame_rate) {
400  _output_frame_rate = output_frame_rate;
401  _control_flags |= CF_output_frame_rate;
402 }
403 
404 ////////////////////////////////////////////////////////////////////
405 // Function: SomethingToEggConverter::has_output_frame_rate
406 // Access: Public
407 // Description: Returns true if the frame rate has been
408 // explicitly specified via set_output_frame_rate(), or
409 // false otherwise.
410 ////////////////////////////////////////////////////////////////////
411 INLINE bool SomethingToEggConverter::
413  return (_control_flags & CF_output_frame_rate) != 0;
414 }
415 
416 ////////////////////////////////////////////////////////////////////
417 // Function: SomethingToEggConverter::get_output_frame_rate
418 // Access: Public
419 // Description: Returns the value set by a previous call to
420 // set_output_frame_rate(). It is an error to call this
421 // if has_output_frame_rate() returns false.
422 ////////////////////////////////////////////////////////////////////
423 INLINE double SomethingToEggConverter::
425  nassertr(has_output_frame_rate(), 0.0);
426  return _output_frame_rate;
427 }
428 
429 ////////////////////////////////////////////////////////////////////
430 // Function: SomethingToEggConverter::clear_output_frame_rate
431 // Access: Public
432 // Description: Removes the value previously set by
433 // set_output_frame_rate().
434 ////////////////////////////////////////////////////////////////////
435 INLINE void SomethingToEggConverter::
437  _output_frame_rate = 0.0;
438  _control_flags &= ~CF_output_frame_rate;
439 }
440 
441 ////////////////////////////////////////////////////////////////////
442 // Function: SomethingToEggConverter::get_default_frame_rate
443 // Access: Public, Static
444 // Description: Returns the default frame rate if nothing is
445 // specified for input_frame_rate or output_frame_rate,
446 // and the animation package does not have an implicit
447 // frame rate.
448 ////////////////////////////////////////////////////////////////////
449 INLINE double SomethingToEggConverter::
451  return 24.0;
452 }
453 
454 ////////////////////////////////////////////////////////////////////
455 // Function: SomethingToEggConverter::set_merge_externals
456 // Access: Public
457 // Description: Sets the merge_externals flag. When this is true,
458 // external references within the source file are read
459 // in and merged directly; otherwise, only a reference
460 // to a similarly-named egg file is inserted.
461 ////////////////////////////////////////////////////////////////////
462 INLINE void SomethingToEggConverter::
463 set_merge_externals(bool merge_externals) {
464  _merge_externals = merge_externals;
465 }
466 
467 ////////////////////////////////////////////////////////////////////
468 // Function: SomethingToEggConverter::get_merge_externals
469 // Access: Public
470 // Description: Returns the current state of the merge_externals
471 // flag. See set_merge_externals().
472 ////////////////////////////////////////////////////////////////////
473 INLINE bool SomethingToEggConverter::
475  return _merge_externals;
476 }
477 
478 ////////////////////////////////////////////////////////////////////
479 // Function: SomethingToEggConverter::clear_egg_data
480 // Access: Public
481 // Description: Sets the EggData to NULL and makes the converter
482 // invalid.
483 ////////////////////////////////////////////////////////////////////
484 INLINE void SomethingToEggConverter::
486  set_egg_data((EggData *)NULL);
487 }
488 
489 ////////////////////////////////////////////////////////////////////
490 // Function: SomethingToEggConverter::get_egg_data
491 // Access: Public
492 // Description: Returns the EggData structure.
493 ////////////////////////////////////////////////////////////////////
496  return _egg_data;
497 }
498 
499 ////////////////////////////////////////////////////////////////////
500 // Function: SomethingToEggConverter::convert_model_path
501 // Access: Public
502 // Description: Converts the indicated model filename to a relative
503 // or absolute or whatever filename, according to
504 // _path_replace.
505 ////////////////////////////////////////////////////////////////////
507 convert_model_path(const Filename &orig_filename) {
508  return _path_replace->convert_path(orig_filename);
509 }
void clear_input_frame_rate()
Removes the value previously set by set_input_frame_rate().
void set_frame_inc(double frame_inc)
Specifies the increment between frames to extract.
void clear_frame_inc()
Removes the value previously set by set_frame_inc().
bool had_error() const
Returns true if an error was detected during the conversion process (unless _allow_errors is true)...
void clear_start_frame()
Removes the value previously set by set_start_frame().
void clear_output_frame_rate()
Removes the value previously set by set_output_frame_rate().
bool has_frame_inc() const
Returns true if the frame increment has been explicitly specified via set_frame_inc(), or false if the ending frame should be implicit based on the source.
bool has_start_frame() const
Returns true if the starting frame has been explicitly specified via set_start_frame(), or false if the starting frame should be implicit based on the source.
bool has_neutral_frame() const
Returns true if the neutral frame has been explicitly specified via set_neutral_frame(), or false otherwise.
EggData * get_egg_data()
Returns the EggData structure.
double get_neutral_frame() const
Returns the value set by a previous call to set_neutral_frame().
void set_neutral_frame(double neutral_frame)
Specifies the frame of animation to represent the neutral pose of the model.
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
const string & get_character_name() const
Returns the name of the character generated.
bool has_input_frame_rate() const
Returns true if the frame rate has been explicitly specified via set_input_frame_rate(), or false otherwise.
void set_character_name(const string &character_name)
Specifies the name of the character generated.
void set_start_frame(double start_frame)
Specifies the starting frame of the animation to convert, in the units specified by set_input_frame_r...
void clear_egg_data()
Sets the EggData to NULL and makes the converter invalid.
void set_end_frame(double end_frame)
Specifies the ending frame of the animation to convert, in the units specified by set_input_frame_rat...
void clear_error()
Resets the error flag to the no-error state.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
double get_input_frame_rate() const
Returns the value set by a previous call to set_input_frame_rate().
AnimationConvert get_animation_convert() const
Returns how source animation will be converted into egg structures.
void set_path_replace(PathReplace *path_replace)
Replaces the PathReplace object (which specifies how to mangle paths from the source to the destinati...
void clear_neutral_frame()
Removes the value previously set by set_neutral_frame().
void set_animation_convert(AnimationConvert animation_convert)
Specifies how source animation will be converted into egg structures.
void set_egg_data(EggData *egg_data)
Sets the egg data that will be filled in when convert_file() is called.
double get_frame_inc() const
Returns the value set by a previous call to set_frame_inc().
double get_start_frame() const
Returns the value set by a previous call to set_start_frame().
PathReplace * get_path_replace()
Returns a pointer to the PathReplace object associated with this converter.
This encapsulates the user's command-line request to replace existing, incorrect pathnames to models ...
Definition: pathReplace.h:40
bool has_end_frame() const
Returns true if the ending frame has been explicitly specified via set_end_frame(), or false if the ending frame should be implicit based on the source.
void set_merge_externals(bool merge_externals)
Sets the merge_externals flag.
double get_output_frame_rate() const
Returns the value set by a previous call to set_output_frame_rate().
void set_output_frame_rate(double output_frame_rate)
Specifies the number of frames per second that the resulting animation should be played at...
bool get_merge_externals() const
Returns the current state of the merge_externals flag.
void clear_end_frame()
Removes the value previously set by set_end_frame().
static double get_default_frame_rate()
Returns the default frame rate if nothing is specified for input_frame_rate or output_frame_rate, and the animation package does not have an implicit frame rate.
void set_input_frame_rate(double input_frame_rate)
Specifies the number of frames per second that is represented by the "frame" unit in the animation pa...
bool has_output_frame_rate() const
Returns true if the frame rate has been explicitly specified via set_output_frame_rate(), or false otherwise.
Filename convert_model_path(const Filename &orig_filename)
Converts the indicated model filename to a relative or absolute or whatever filename, according to _path_replace.
double get_end_frame() const
Returns the value set by a previous call to set_end_frame().