00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "eggToSomething.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 EggToSomething::
00026 EggToSomething(const string &format_name,
00027 const string &preferred_extension,
00028 bool allow_last_param, bool allow_stdout) :
00029 EggConverter(format_name, preferred_extension, allow_last_param,
00030 allow_stdout)
00031 {
00032 clear_runlines();
00033 if (_allow_last_param) {
00034 add_runline("[opts] input.egg output" + _preferred_extension);
00035 }
00036 add_runline("[opts] -o output" + _preferred_extension + " input.egg");
00037 if (_allow_stdout) {
00038 add_runline("[opts] input.egg >output" + _preferred_extension);
00039 }
00040
00041 string o_description;
00042
00043 if (_allow_stdout) {
00044 if (_allow_last_param) {
00045 o_description =
00046 "Specify the filename to which the resulting " + format_name +
00047 " file will be written. "
00048 "If this option is omitted, the last parameter name is taken to be the "
00049 "name of the output file, or standard output is used if there are no "
00050 "other parameters.";
00051 } else {
00052 o_description =
00053 "Specify the filename to which the resulting " + format_name +
00054 " file will be written. "
00055 "If this option is omitted, the " + format_name +
00056 " file is written to standard output.";
00057 }
00058 } else {
00059 if (_allow_last_param) {
00060 o_description =
00061 "Specify the filename to which the resulting " + format_name +
00062 " file will be written. "
00063 "If this option is omitted, the last parameter name is taken to be the "
00064 "name of the output file.";
00065 } else {
00066 o_description =
00067 "Specify the filename to which the resulting " + format_name +
00068 " file will be written.";
00069 }
00070 }
00071
00072 redescribe_option("o", o_description);
00073
00074 redescribe_option
00075 ("cs",
00076 "Specify the coordinate system of the resulting " + _format_name +
00077 " file. This may be "
00078 "one of 'y-up', 'z-up', 'y-up-left', or 'z-up-left'. The default "
00079 "is the same coordinate system as the input egg file. If this is "
00080 "different from the input egg file, a conversion will be performed.");
00081
00082 _input_units = DU_invalid;
00083 _output_units = DU_invalid;
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 void EggToSomething::
00096 add_units_options() {
00097 add_option
00098 ("ui", "units", 40,
00099 "Specify the units of the input egg file. If this is "
00100 "specified, the vertices in the egg file will be scaled as "
00101 "necessary to make the appropriate units conversion; otherwise, "
00102 "the vertices will be left as they are.",
00103 &EggToSomething::dispatch_units, NULL, &_input_units);
00104
00105 add_option
00106 ("uo", "units", 40,
00107 "Specify the units of the resulting " + _format_name +
00108 " file. Normally, the default units for the format are used.",
00109 &EggToSomething::dispatch_units, NULL, &_output_units);
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119 void EggToSomething::
00120 apply_units_scale(EggData *data) {
00121
00122
00123
00124
00125
00126
00127 DistanceUnit output_units = _output_units;
00128 if (_format_name == "Maya")
00129 _output_units = DU_centimeters;
00130
00131 if (_output_units != DU_invalid && _input_units != DU_invalid &&
00132 _input_units != _output_units) {
00133 nout << "Converting from " << format_long_unit(_input_units)
00134 << " to " << format_long_unit(_output_units) << "\n";
00135 double scale = convert_units(_input_units, _output_units);
00136 data->transform(LMatrix4d::scale_mat(scale));
00137 }
00138 _output_units = output_units;
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 void EggToSomething::
00151 pre_process_egg_file() {
00152 apply_units_scale(_data);
00153 EggConverter::pre_process_egg_file();
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 bool EggToSomething::
00165 handle_args(ProgramBase::Args &args) {
00166 if (!check_last_arg(args, 1)) {
00167 return false;
00168 }
00169
00170 return EggConverter::handle_args(args);
00171 }