23 const std::string &preferred_extension,
24 bool allow_last_param,
bool allow_stdout) :
25 EggConverter(format_name, preferred_extension, allow_last_param,
29 if (_allow_last_param) {
30 add_runline(
"[opts] input.egg output" + _preferred_extension);
32 add_runline(
"[opts] -o output" + _preferred_extension +
" input.egg");
34 add_runline(
"[opts] input.egg >output" + _preferred_extension);
37 std::string o_description;
40 if (_allow_last_param) {
42 "Specify the filename to which the resulting " + format_name +
43 " file will be written. " 44 "If this option is omitted, the last parameter name is taken to be the " 45 "name of the output file, or standard output is used if there are no " 49 "Specify the filename to which the resulting " + format_name +
50 " file will be written. " 51 "If this option is omitted, the " + format_name +
52 " file is written to standard output.";
55 if (_allow_last_param) {
57 "Specify the filename to which the resulting " + format_name +
58 " file will be written. " 59 "If this option is omitted, the last parameter name is taken to be the " 60 "name of the output file.";
63 "Specify the filename to which the resulting " + format_name +
64 " file will be written.";
68 redescribe_option(
"o", o_description);
72 "Specify the coordinate system of the resulting " + _format_name +
74 "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default " 75 "is the same coordinate system as the input egg file. If this is " 76 "different from the input egg file, a conversion will be performed.");
78 _input_units = DU_invalid;
79 _output_units = DU_invalid;
92 "Specify the units of the input egg file. If this is " 93 "specified, the vertices in the egg file will be scaled as " 94 "necessary to make the appropriate units conversion; otherwise, " 95 "the vertices will be left as they are.",
96 &EggToSomething::dispatch_units,
nullptr, &_input_units);
100 "Specify the units of the resulting " + _format_name +
101 " file. Normally, the default units for the format are used.",
102 &EggToSomething::dispatch_units,
nullptr, &_output_units);
109 void EggToSomething::
110 apply_units_scale(
EggData *data) {
117 if (_format_name ==
"Maya")
118 _output_units = DU_centimeters;
120 if (_output_units != DU_invalid && _input_units != DU_invalid &&
121 _input_units != _output_units) {
125 data->transform(LMatrix4d::scale_mat(scale));
127 _output_units = output_units;
137 void EggToSomething::
138 pre_process_egg_file() {
139 apply_units_scale(_data);
148 bool EggToSomething::
150 if (!check_last_arg(args, 1)) {
154 return EggConverter::handle_args(args);
string format_long_unit(DistanceUnit unit)
Returns the string representing the full name (plural) for the given unit.
double convert_units(DistanceUnit from, DistanceUnit to)
Returns the scaling factor that must be applied to convert from units of "from" to "to".
This is the primary interface into all the egg data, and the root of the egg file structure.
DistanceUnit
This enumerated type lists all the kinds of units we're likely to come across in model conversion pro...
This is a general base class for programs that convert between egg files and some other format.
EggToSomething(const std::string &format_name, const std::string &preferred_extension=std::string(), bool allow_last_param=true, bool allow_stdout=true)
The first parameter to the constructor should be the one-word name of the file format that is to be r...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void pre_process_egg_file()
Performs any processing of the egg file that is appropriate after reading it in.
void add_units_options()
Adds -ui and -uo as valid options for this program.