Panda3D
somethingToEggConverter.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file somethingToEggConverter.I
10  * @author drose
11  * @date 2001-04-26
12  */
13 
14 /**
15  * Resets the error flag to the no-error state. had_error() will return false
16  * until a new error is generated.
17  */
18 INLINE void SomethingToEggConverter::
20  _error = false;
21 }
22 
23 /**
24  * Returns true if an error was detected during the conversion process (unless
25  * _allow_errors is true), false otherwise.
26  */
27 INLINE bool SomethingToEggConverter::
28 had_error() const {
29  return !_allow_errors && (_error || _path_replace->had_error());
30 }
31 
32 /**
33  * Replaces the PathReplace object (which specifies how to mangle paths from
34  * the source to the destination egg file) with a new one.
35  */
36 INLINE void SomethingToEggConverter::
37 set_path_replace(PathReplace *path_replace) {
38  _path_replace = path_replace;
39 }
40 
41 /**
42  * Returns a pointer to the PathReplace object associated with this converter.
43  * If the converter is non-const, this returns a non-const pointer, which can
44  * be adjusted.
45  */
48  return _path_replace;
49 }
50 
51 /**
52  * Returns a pointer to the PathReplace object associated with this converter.
53  * If the converter is non-const, this returns a non-const pointer, which can
54  * be adjusted.
55  */
57 get_path_replace() const {
58  return _path_replace;
59 }
60 
61 /**
62  * Specifies how source animation will be converted into egg structures. The
63  * default is AC_none, which means animation tables will be ignored. This is
64  * only meaningful for converters that understand animation.
65  */
66 INLINE void SomethingToEggConverter::
68  _animation_convert = animation_convert;
69 }
70 
71 /**
72  * Returns how source animation will be converted into egg structures.
73  */
76  return _animation_convert;
77 }
78 
79 /**
80  * Specifies the name of the character generated. This name should match
81  * between all the model and channel egg files for a particular character and
82  * its associated animations.
83  */
84 INLINE void SomethingToEggConverter::
85 set_character_name(const std::string &character_name) {
86  _character_name = character_name;
87 }
88 
89 /**
90  * Returns the name of the character generated. See set_character_name().
91  */
92 INLINE const std::string &SomethingToEggConverter::
94  return _character_name;
95 }
96 
97 /**
98  * Specifies the starting frame of the animation to convert, in the units
99  * specified by set_input_frame_rate(). If this is unspecified, the starting
100  * frame is taken from the source, for instance from the first frame of the
101  * animation slider.
102  */
103 INLINE void SomethingToEggConverter::
104 set_start_frame(double start_frame) {
105  _start_frame = start_frame;
106  _control_flags |= CF_start_frame;
107 }
108 
109 /**
110  * Returns true if the starting frame has been explicitly specified via
111  * set_start_frame(), or false if the starting frame should be implicit based
112  * on the source.
113  */
114 INLINE bool SomethingToEggConverter::
116  return (_control_flags & CF_start_frame) != 0;
117 }
118 
119 /**
120  * Returns the value set by a previous call to set_start_frame(). It is an
121  * error to call this if has_start_frame() returns false.
122  */
123 INLINE double SomethingToEggConverter::
125  nassertr(has_start_frame(), 0.0);
126  return _start_frame;
127 }
128 
129 /**
130  * Removes the value previously set by set_start_frame().
131  */
132 INLINE void SomethingToEggConverter::
134  _start_frame = 0.0;
135  _control_flags &= ~CF_start_frame;
136 }
137 
138 /**
139  * Specifies the ending frame of the animation to convert, in the units
140  * specified by set_input_frame_rate(). If this is unspecified, the ending
141  * frame is taken from the source, for instance from the last frame of the
142  * animation slider.
143  */
144 INLINE void SomethingToEggConverter::
145 set_end_frame(double end_frame) {
146  _end_frame = end_frame;
147  _control_flags |= CF_end_frame;
148 }
149 
150 /**
151  * Returns true if the ending frame has been explicitly specified via
152  * set_end_frame(), or false if the ending frame should be implicit based on
153  * the source.
154  */
155 INLINE bool SomethingToEggConverter::
156 has_end_frame() const {
157  return (_control_flags & CF_end_frame) != 0;
158 }
159 
160 /**
161  * Returns the value set by a previous call to set_end_frame(). It is an
162  * error to call this if has_end_frame() returns false.
163  */
164 INLINE double SomethingToEggConverter::
165 get_end_frame() const {
166  nassertr(has_end_frame(), 0.0);
167  return _end_frame;
168 }
169 
170 /**
171  * Removes the value previously set by set_end_frame().
172  */
173 INLINE void SomethingToEggConverter::
175  _end_frame = 0.0;
176  _control_flags &= ~CF_end_frame;
177 }
178 
179 /**
180  * Specifies the increment between frames to extract. This is the amount to
181  * increment the time slider (in units of internal_frame_rate) between
182  * extracting each frame. If this is not specified, the default is taken from
183  * the animation package, or 1.0 if the animation package does not specified a
184  * frame increment.
185  */
186 INLINE void SomethingToEggConverter::
187 set_frame_inc(double frame_inc) {
188  _frame_inc = frame_inc;
189  _control_flags |= CF_frame_inc;
190 }
191 
192 /**
193  * Returns true if the frame increment has been explicitly specified via
194  * set_frame_inc(), or false if the ending frame should be implicit based on
195  * the source.
196  */
197 INLINE bool SomethingToEggConverter::
198 has_frame_inc() const {
199  return (_control_flags & CF_frame_inc) != 0;
200 }
201 
202 /**
203  * Returns the value set by a previous call to set_frame_inc(). It is an
204  * error to call this if has_frame_inc() returns false.
205  */
206 INLINE double SomethingToEggConverter::
207 get_frame_inc() const {
208  nassertr(has_frame_inc(), 0.0);
209  return _frame_inc;
210 }
211 
212 /**
213  * Removes the value previously set by set_frame_inc().
214  */
215 INLINE void SomethingToEggConverter::
217  _frame_inc = 0.0;
218  _control_flags &= ~CF_frame_inc;
219 }
220 
221 /**
222  * Specifies the frame of animation to represent the neutral pose of the
223  * model.
224  */
225 INLINE void SomethingToEggConverter::
226 set_neutral_frame(double neutral_frame) {
227  _neutral_frame = neutral_frame;
228  _control_flags |= CF_neutral_frame;
229 }
230 
231 /**
232  * Returns true if the neutral frame has been explicitly specified via
233  * set_neutral_frame(), or false otherwise.
234  */
235 INLINE bool SomethingToEggConverter::
237  return (_control_flags & CF_neutral_frame) != 0;
238 }
239 
240 /**
241  * Returns the value set by a previous call to set_neutral_frame(). It is an
242  * error to call this if has_neutral_frame() returns false.
243  */
244 INLINE double SomethingToEggConverter::
246  nassertr(has_neutral_frame(), 0.0);
247  return _neutral_frame;
248 }
249 
250 /**
251  * Removes the value previously set by set_neutral_frame().
252  */
253 INLINE void SomethingToEggConverter::
255  _neutral_frame = 0.0;
256  _control_flags &= ~CF_neutral_frame;
257 }
258 
259 /**
260  * Specifies the number of frames per second that is represented by the
261  * "frame" unit in the animation package. If this is omitted, it is taken
262  * from whatever the file header indicates. Some animation packages do not
263  * encode a frame rate, in which case the default if this is omitted is the
264  * same as the output frame rate.
265  */
266 INLINE void SomethingToEggConverter::
267 set_input_frame_rate(double input_frame_rate) {
268  _input_frame_rate = input_frame_rate;
269  _control_flags |= CF_input_frame_rate;
270 }
271 
272 /**
273  * Returns true if the frame rate has been explicitly specified via
274  * set_input_frame_rate(), or false otherwise.
275  */
276 INLINE bool SomethingToEggConverter::
278  return (_control_flags & CF_input_frame_rate) != 0;
279 }
280 
281 /**
282  * Returns the value set by a previous call to set_input_frame_rate(). It is
283  * an error to call this if has_input_frame_rate() returns false.
284  */
285 INLINE double SomethingToEggConverter::
287  nassertr(has_input_frame_rate(), 0.0);
288  return _input_frame_rate;
289 }
290 
291 /**
292  * Removes the value previously set by set_input_frame_rate().
293  */
294 INLINE void SomethingToEggConverter::
296  _input_frame_rate = 0.0;
297  _control_flags &= ~CF_input_frame_rate;
298 }
299 
300 /**
301  * Specifies the number of frames per second that the resulting animation
302  * should be played at. If this is omitted, it is taken to be the same as the
303  * input frame rate.
304  */
305 INLINE void SomethingToEggConverter::
306 set_output_frame_rate(double output_frame_rate) {
307  _output_frame_rate = output_frame_rate;
308  _control_flags |= CF_output_frame_rate;
309 }
310 
311 /**
312  * Returns true if the frame rate has been explicitly specified via
313  * set_output_frame_rate(), or false otherwise.
314  */
315 INLINE bool SomethingToEggConverter::
317  return (_control_flags & CF_output_frame_rate) != 0;
318 }
319 
320 /**
321  * Returns the value set by a previous call to set_output_frame_rate(). It is
322  * an error to call this if has_output_frame_rate() returns false.
323  */
324 INLINE double SomethingToEggConverter::
326  nassertr(has_output_frame_rate(), 0.0);
327  return _output_frame_rate;
328 }
329 
330 /**
331  * Removes the value previously set by set_output_frame_rate().
332  */
333 INLINE void SomethingToEggConverter::
335  _output_frame_rate = 0.0;
336  _control_flags &= ~CF_output_frame_rate;
337 }
338 
339 /**
340  * Returns the default frame rate if nothing is specified for input_frame_rate
341  * or output_frame_rate, and the animation package does not have an implicit
342  * frame rate.
343  */
344 INLINE double SomethingToEggConverter::
346  return 24.0;
347 }
348 
349 /**
350  * Sets the merge_externals flag. When this is true, external references
351  * within the source file are read in and merged directly; otherwise, only a
352  * reference to a similarly-named egg file is inserted.
353  */
354 INLINE void SomethingToEggConverter::
355 set_merge_externals(bool merge_externals) {
356  _merge_externals = merge_externals;
357 }
358 
359 /**
360  * Returns the current state of the merge_externals flag. See
361  * set_merge_externals().
362  */
363 INLINE bool SomethingToEggConverter::
365  return _merge_externals;
366 }
367 
368 /**
369  * Sets the EggData to NULL and makes the converter invalid.
370  */
371 INLINE void SomethingToEggConverter::
373  set_egg_data(nullptr);
374 }
375 
376 /**
377  * Returns the EggData structure.
378  */
381  return _egg_data;
382 }
383 
384 /**
385  * Converts the indicated model filename to a relative or absolute or whatever
386  * filename, according to _path_replace.
387  */
389 convert_model_path(const Filename &orig_filename) {
390  return _path_replace->convert_path(orig_filename);
391 }
SomethingToEggConverter::has_output_frame_rate
bool has_output_frame_rate() const
Returns true if the frame rate has been explicitly specified via set_output_frame_rate(),...
Definition: somethingToEggConverter.I:316
SomethingToEggConverter::get_default_frame_rate
static double get_default_frame_rate()
Returns the default frame rate if nothing is specified for input_frame_rate or output_frame_rate,...
Definition: somethingToEggConverter.I:345
SomethingToEggConverter::clear_start_frame
void clear_start_frame()
Removes the value previously set by set_start_frame().
Definition: somethingToEggConverter.I:133
SomethingToEggConverter::had_error
bool had_error() const
Returns true if an error was detected during the conversion process (unless _allow_errors is true),...
Definition: somethingToEggConverter.I:28
SomethingToEggConverter::clear_frame_inc
void clear_frame_inc()
Removes the value previously set by set_frame_inc().
Definition: somethingToEggConverter.I:216
SomethingToEggConverter::get_end_frame
double get_end_frame() const
Returns the value set by a previous call to set_end_frame().
Definition: somethingToEggConverter.I:165
SomethingToEggConverter::set_frame_inc
void set_frame_inc(double frame_inc)
Specifies the increment between frames to extract.
Definition: somethingToEggConverter.I:187
SomethingToEggConverter::clear_output_frame_rate
void clear_output_frame_rate()
Removes the value previously set by set_output_frame_rate().
Definition: somethingToEggConverter.I:334
SomethingToEggConverter::has_frame_inc
bool has_frame_inc() const
Returns true if the frame increment has been explicitly specified via set_frame_inc(),...
Definition: somethingToEggConverter.I:198
SomethingToEggConverter::clear_input_frame_rate
void clear_input_frame_rate()
Removes the value previously set by set_input_frame_rate().
Definition: somethingToEggConverter.I:295
SomethingToEggConverter::has_neutral_frame
bool has_neutral_frame() const
Returns true if the neutral frame has been explicitly specified via set_neutral_frame(),...
Definition: somethingToEggConverter.I:236
AnimationConvert
AnimationConvert
This enumerated type lists the methods by which animation from an animation package might be represen...
Definition: animationConvert.h:23
SomethingToEggConverter::get_path_replace
PathReplace * get_path_replace()
Returns a pointer to the PathReplace object associated with this converter.
Definition: somethingToEggConverter.I:47
SomethingToEggConverter::set_character_name
void set_character_name(const std::string &character_name)
Specifies the name of the character generated.
Definition: somethingToEggConverter.I:85
SomethingToEggConverter::set_neutral_frame
void set_neutral_frame(double neutral_frame)
Specifies the frame of animation to represent the neutral pose of the model.
Definition: somethingToEggConverter.I:226
SomethingToEggConverter::get_egg_data
EggData * get_egg_data()
Returns the EggData structure.
Definition: somethingToEggConverter.I:380
SomethingToEggConverter::set_start_frame
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...
Definition: somethingToEggConverter.I:104
SomethingToEggConverter::has_start_frame
bool has_start_frame() const
Returns true if the starting frame has been explicitly specified via set_start_frame(),...
Definition: somethingToEggConverter.I:115
SomethingToEggConverter::set_end_frame
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...
Definition: somethingToEggConverter.I:145
SomethingToEggConverter::has_input_frame_rate
bool has_input_frame_rate() const
Returns true if the frame rate has been explicitly specified via set_input_frame_rate(),...
Definition: somethingToEggConverter.I:277
EggData
This is the primary interface into all the egg data, and the root of the egg file structure.
Definition: eggData.h:37
SomethingToEggConverter::set_path_replace
void set_path_replace(PathReplace *path_replace)
Replaces the PathReplace object (which specifies how to mangle paths from the source to the destinati...
Definition: somethingToEggConverter.I:37
SomethingToEggConverter::get_character_name
const std::string & get_character_name() const
Returns the name of the character generated.
Definition: somethingToEggConverter.I:93
SomethingToEggConverter::get_neutral_frame
double get_neutral_frame() const
Returns the value set by a previous call to set_neutral_frame().
Definition: somethingToEggConverter.I:245
SomethingToEggConverter::clear_neutral_frame
void clear_neutral_frame()
Removes the value previously set by set_neutral_frame().
Definition: somethingToEggConverter.I:254
SomethingToEggConverter::clear_egg_data
void clear_egg_data()
Sets the EggData to NULL and makes the converter invalid.
Definition: somethingToEggConverter.I:372
SomethingToEggConverter::get_input_frame_rate
double get_input_frame_rate() const
Returns the value set by a previous call to set_input_frame_rate().
Definition: somethingToEggConverter.I:286
SomethingToEggConverter::get_animation_convert
AnimationConvert get_animation_convert() const
Returns how source animation will be converted into egg structures.
Definition: somethingToEggConverter.I:75
SomethingToEggConverter::clear_error
void clear_error()
Resets the error flag to the no-error state.
Definition: somethingToEggConverter.I:19
PathReplace
This encapsulates the user's command-line request to replace existing, incorrect pathnames to models ...
Definition: pathReplace.h:36
SomethingToEggConverter::set_animation_convert
void set_animation_convert(AnimationConvert animation_convert)
Specifies how source animation will be converted into egg structures.
Definition: somethingToEggConverter.I:67
SomethingToEggConverter::has_end_frame
bool has_end_frame() const
Returns true if the ending frame has been explicitly specified via set_end_frame(),...
Definition: somethingToEggConverter.I:156
SomethingToEggConverter::set_egg_data
void set_egg_data(EggData *egg_data)
Sets the egg data that will be filled in when convert_file() is called.
Definition: somethingToEggConverter.cxx:66
SomethingToEggConverter::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.
Definition: somethingToEggConverter.I:306
SomethingToEggConverter::get_merge_externals
bool get_merge_externals() const
Returns the current state of the merge_externals flag.
Definition: somethingToEggConverter.I:364
SomethingToEggConverter::set_merge_externals
void set_merge_externals(bool merge_externals)
Sets the merge_externals flag.
Definition: somethingToEggConverter.I:355
SomethingToEggConverter::get_frame_inc
double get_frame_inc() const
Returns the value set by a previous call to set_frame_inc().
Definition: somethingToEggConverter.I:207
SomethingToEggConverter::get_output_frame_rate
double get_output_frame_rate() const
Returns the value set by a previous call to set_output_frame_rate().
Definition: somethingToEggConverter.I:325
SomethingToEggConverter::set_input_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...
Definition: somethingToEggConverter.I:267
SomethingToEggConverter::get_start_frame
double get_start_frame() const
Returns the value set by a previous call to set_start_frame().
Definition: somethingToEggConverter.I:124
SomethingToEggConverter::convert_model_path
Filename convert_model_path(const Filename &orig_filename)
Converts the indicated model filename to a relative or absolute or whatever filename,...
Definition: somethingToEggConverter.I:389
Filename
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
SomethingToEggConverter::clear_end_frame
void clear_end_frame()
Removes the value previously set by set_end_frame().
Definition: somethingToEggConverter.I:174