54 add_path_replace_options();
55 add_path_store_options();
56 add_animation_options();
58 add_normals_options();
59 add_transform_options();
61 set_program_brief(
"convert Maya model files to .egg");
62 set_program_description
63 (
"This program converts Maya model files to egg. Static and animatable "
64 "models can be converted, with polygon or NURBS output. Animation tables "
65 "can also be generated to apply to an animatable model.");
69 "Generate polygon output only. Tesselate all NURBS surfaces to "
70 "polygons via the built-in Maya tesselator. The tesselation will "
71 "be based on the tolerance factor given by -ptol.",
72 &MayaToEgg::dispatch_none, &_polygon_output);
75 (
"ptol",
"tolerance", 0,
76 "Specify the fit tolerance for Maya polygon tesselation. The smaller "
77 "the number, the more polygons will be generated. The default is "
79 &MayaToEgg::dispatch_double,
nullptr, &_polygon_tolerance);
83 "Respect the Maya \"double sided\" rendering flag to indicate whether "
84 "polygons should be double-sided or single-sided. Since this flag "
85 "is set to double-sided by default in Maya, it is often better to "
86 "ignore this flag (unless your modelers are diligent in turning it "
87 "off where it is not desired). If this flag is not specified, the "
88 "default is to treat all polygons as single-sided, unless an "
89 "egg object type of \"double-sided\" is set.",
90 &MayaToEgg::dispatch_none, &_respect_maya_double_sided);
93 (
"suppress-vcolor",
"", 0,
94 "Ignore vertex color for geometry that has a texture applied. "
95 "(This is the way Maya normally renders internally.) The egg flag "
96 "'vertex-color' may be applied to a particular model to override "
97 "this setting locally.",
98 &MayaToEgg::dispatch_none, &_suppress_vertex_color);
101 (
"convert-cameras",
"", 0,
102 "Convert all camera nodes to locators. Will preserve position and rotation.",
103 &MayaToEgg::dispatch_none, &_convert_cameras);
106 (
"convert-lights",
"", 0,
107 "Convert all light nodes to locators. Will preserve position and rotation only.",
108 &MayaToEgg::dispatch_none, &_convert_lights);
112 "Convert all UV sets on all vertices, even those that do not appear "
113 "to be referenced by any textures.",
114 &MayaToEgg::dispatch_none, &_keep_all_uvsets);
118 "round up uv coordinates to the nearest 1/100th. i.e. -0.001 becomes"
119 "0.0; 0.444 becomes 0.44; 0.778 becomes 0.78.",
120 &MayaToEgg::dispatch_none, &_round_uvs);
123 (
"copytex",
"dir", 41,
124 "Legacy option. Same as -pc.",
125 &MayaToEgg::dispatch_filename, &_legacy_copytex, &_legacy_copytex_dir);
129 "Specifies which transforms in the Maya file should be converted to "
130 "transforms in the egg file. The option may be one of all, model, "
131 "dcs, or none. The default is model, which means only transforms on "
132 "nodes that have the model flag or the dcs flag are preserved.",
133 &MayaToEgg::dispatch_transform_type,
nullptr, &_transform_type);
136 (
"subroot",
"name", 0,
137 "Specifies that only a subroot of the geometry in the Maya file should "
138 "be converted; specifically, the geometry under the node or nodes whose "
139 "name matches the parameter (which may include globbing characters "
140 "like * or ?). This parameter may be repeated multiple times to name "
141 "multiple roots. If it is omitted altogether, the entire file is "
143 &MayaToEgg::dispatch_vector_string,
nullptr, &_subroots);
146 (
"subset",
"name", 0,
147 "Specifies that only a subset of the geometry in the Maya file should "
148 "be converted; specifically, the geometry under the node or nodes whose "
149 "name matches the parameter (which may include globbing characters "
150 "like * or ?). This parameter may be repeated multiple times to name "
151 "multiple roots. If it is omitted altogether, the entire file is "
153 &MayaToEgg::dispatch_vector_string,
nullptr, &_subsets);
156 (
"exclude",
"name", 0,
157 "Specifies that a subset of the geometry in the Maya file should "
158 "not be converted; specifically, the geometry under the node or nodes whose "
159 "name matches the parameter (which may include globbing characters "
160 "like * or ?). This parameter may be repeated multiple times to name "
162 &MayaToEgg::dispatch_vector_string,
nullptr, &_excludes);
165 (
"ignore-slider",
"name", 0,
166 "Specifies the name of a slider (blend shape deformer) that maya2egg "
167 "should not process. The slider will not be touched during conversion "
168 "and it will not become a part of the animation. This "
169 "parameter may including globbing characters, and it may be repeated "
171 &MayaToEgg::dispatch_vector_string,
nullptr, &_ignore_sliders);
174 (
"force-joint",
"name", 0,
175 "Specifies the name of a DAG node that maya2egg "
176 "should treat as a joint, even if it does not appear to be a Maya joint "
177 "and does not appear to be animated.",
178 &MayaToEgg::dispatch_vector_string,
nullptr, &_force_joints);
182 "Increase verbosity. More v's means more verbose.",
183 &MayaToEgg::dispatch_count,
nullptr, &_verbose);
186 (
"legacy-shaders",
"", 0,
187 "Use this flag to turn off modern (Phong) shader generation"
188 "and treat all shaders as if they were Lamberts (legacy).",
189 &MayaToEgg::dispatch_none, &_legacy_shader);
195 remove_option(
"noabs");
198 _polygon_tolerance = 0.01;
199 _transform_type = MayaToEggConverter::TT_model;
210 maya_cat->set_severity(NS_spam);
211 mayaegg_cat->set_severity(NS_spam);
212 }
else if (_verbose >= 2) {
213 maya_cat->set_severity(NS_debug);
214 mayaegg_cat->set_severity(NS_debug);
215 }
else if (_verbose >= 1) {
216 maya_cat->set_severity(NS_info);
217 mayaegg_cat->set_severity(NS_info);
220 if (_legacy_copytex && !_path_replace->_copy_files) {
221 _path_replace->_copy_files =
true;
222 _path_replace->_copy_into_directory = _legacy_copytex_dir;
227 if (_got_output_filename) {
229 _path_replace->_path_directory.make_absolute();
232 nout <<
"Initializing Maya.\n";
236 if (!converter.open_api(
false)) {
237 nout <<
"Unable to initialize Maya.\n";
242 converter._polygon_output = _polygon_output;
243 converter._polygon_tolerance = _polygon_tolerance;
244 converter._respect_maya_double_sided = _respect_maya_double_sided;
245 converter._always_show_vertex_color = !_suppress_vertex_color;
246 converter._keep_all_uvsets = _keep_all_uvsets;
247 converter._convert_cameras = _convert_cameras;
248 converter._convert_lights = _convert_lights;
249 converter._round_uvs = _round_uvs;
250 converter._transform_type = _transform_type;
251 converter._legacy_shader = _legacy_shader;
253 vector_string::const_iterator si;
254 if (!_subroots.empty()) {
255 converter.clear_subroots();
256 for (si = _subroots.begin(); si != _subroots.end(); ++si) {
261 if (!_subsets.empty()) {
262 converter.clear_subsets();
263 for (si = _subsets.begin(); si != _subsets.end(); ++si) {
268 if (!_excludes.empty()) {
269 converter.clear_excludes();
270 for (si = _excludes.begin(); si != _excludes.end(); ++si) {
275 if (!_ignore_sliders.empty()) {
276 converter.clear_ignore_sliders();
277 for (si = _ignore_sliders.begin(); si != _ignore_sliders.end(); ++si) {
282 if (!_force_joints.empty()) {
283 converter.clear_force_joints();
284 for (si = _force_joints.begin(); si != _force_joints.end(); ++si) {
290 apply_parameters(converter);
293 if (!_got_coordinate_system) {
294 _coordinate_system = converter._maya->get_coordinate_system();
296 _data->set_coordinate_system(_coordinate_system);
298 converter.set_egg_data(_data);
300 if (!converter.convert_file(_input_filename)) {
301 nout <<
"Errors in conversion.\n";
309 if (_input_units == DU_invalid) {
310 _input_units = converter.get_input_units();
322 dispatch_transform_type(
const std::string &opt,
const std::string &arg,
void *var) {
323 MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var;
326 if ((*ip) == MayaToEggConverter::TT_invalid) {
327 nout <<
"Invalid type for -" << opt <<
": " << arg <<
"\n"
328 <<
"Valid types are all, model, dcs, and none.\n";
335 int main(
int argc,
char *argv[]) {