15 #include "eggToSomething.h" 27 const string &preferred_extension,
28 bool allow_last_param,
bool allow_stdout) :
29 EggConverter(format_name, preferred_extension, allow_last_param,
33 if (_allow_last_param) {
34 add_runline(
"[opts] input.egg output" + _preferred_extension);
36 add_runline(
"[opts] -o output" + _preferred_extension +
" input.egg");
38 add_runline(
"[opts] input.egg >output" + _preferred_extension);
44 if (_allow_last_param) {
46 "Specify the filename to which the resulting " + format_name +
47 " file will be written. " 48 "If this option is omitted, the last parameter name is taken to be the " 49 "name of the output file, or standard output is used if there are no " 53 "Specify the filename to which the resulting " + format_name +
54 " file will be written. " 55 "If this option is omitted, the " + format_name +
56 " file is written to standard output.";
59 if (_allow_last_param) {
61 "Specify the filename to which the resulting " + format_name +
62 " file will be written. " 63 "If this option is omitted, the last parameter name is taken to be the " 64 "name of the output file.";
67 "Specify the filename to which the resulting " + format_name +
68 " file will be written.";
72 redescribe_option(
"o", o_description);
76 "Specify the coordinate system of the resulting " + _format_name +
78 "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default " 79 "is the same coordinate system as the input egg file. If this is " 80 "different from the input egg file, a conversion will be performed.");
82 _input_units = DU_invalid;
83 _output_units = DU_invalid;
99 "Specify the units of the input egg file. If this is " 100 "specified, the vertices in the egg file will be scaled as " 101 "necessary to make the appropriate units conversion; otherwise, " 102 "the vertices will be left as they are.",
103 &EggToSomething::dispatch_units, NULL, &_input_units);
107 "Specify the units of the resulting " + _format_name +
108 " file. Normally, the default units for the format are used.",
109 &EggToSomething::dispatch_units, NULL, &_output_units);
119 void EggToSomething::
120 apply_units_scale(
EggData *data) {
127 DistanceUnit output_units = _output_units;
128 if (_format_name ==
"Maya")
129 _output_units = DU_centimeters;
131 if (_output_units != DU_invalid && _input_units != DU_invalid &&
132 _input_units != _output_units) {
133 nout <<
"Converting from " << format_long_unit(_input_units)
134 <<
" to " << format_long_unit(_output_units) <<
"\n";
135 double scale = convert_units(_input_units, _output_units);
138 _output_units = output_units;
150 void EggToSomething::
151 pre_process_egg_file() {
152 apply_units_scale(_data);
164 bool EggToSomething::
166 if (!check_last_arg(args, 1)) {
170 return EggConverter::handle_args(args);
void transform(const LMatrix4d &mat)
Applies the indicated transformation to the node and all of its descendants.
static LMatrix4d scale_mat(const LVecBase3d &scale)
Returns a matrix that applies the indicated scale in each of the three axes.
This is the primary interface into all the egg data, and the root of the egg file structure...
This is a general base class for programs that convert between egg files and some other format...
EggToSomething(const string &format_name, const string &preferred_extension=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...
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.