42 #include "mayaToEgg.h" 43 #include "mayaToEggConverter.h" 44 #include "config_mayaegg.h" 45 #include "config_maya.h" 46 #include "globPattern.h" 60 add_path_replace_options();
61 add_path_store_options();
62 add_animation_options();
64 add_normals_options();
65 add_transform_options();
67 set_program_brief(
"convert Maya model files to .egg");
68 set_program_description
69 (
"This program converts Maya model files to egg. Static and animatable " 70 "models can be converted, with polygon or NURBS output. Animation tables " 71 "can also be generated to apply to an animatable model.");
75 "Generate polygon output only. Tesselate all NURBS surfaces to " 76 "polygons via the built-in Maya tesselator. The tesselation will " 77 "be based on the tolerance factor given by -ptol.",
78 &MayaToEgg::dispatch_none, &_polygon_output);
81 (
"ptol",
"tolerance", 0,
82 "Specify the fit tolerance for Maya polygon tesselation. The smaller " 83 "the number, the more polygons will be generated. The default is " 85 &MayaToEgg::dispatch_double, NULL, &_polygon_tolerance);
89 "Respect the Maya \"double sided\" rendering flag to indicate whether " 90 "polygons should be double-sided or single-sided. Since this flag " 91 "is set to double-sided by default in Maya, it is often better to " 92 "ignore this flag (unless your modelers are diligent in turning it " 93 "off where it is not desired). If this flag is not specified, the " 94 "default is to treat all polygons as single-sided, unless an " 95 "egg object type of \"double-sided\" is set.",
96 &MayaToEgg::dispatch_none, &_respect_maya_double_sided);
99 (
"suppress-vcolor",
"", 0,
100 "Ignore vertex color for geometry that has a texture applied. " 101 "(This is the way Maya normally renders internally.) The egg flag " 102 "'vertex-color' may be applied to a particular model to override " 103 "this setting locally.",
104 &MayaToEgg::dispatch_none, &_suppress_vertex_color);
107 (
"convert-cameras",
"", 0,
108 "Convert all camera nodes to locators. Will preserve position and rotation.",
109 &MayaToEgg::dispatch_none, &_convert_cameras);
112 (
"convert-lights",
"", 0,
113 "Convert all light nodes to locators. Will preserve position and rotation only.",
114 &MayaToEgg::dispatch_none, &_convert_lights);
118 "Convert all UV sets on all vertices, even those that do not appear " 119 "to be referenced by any textures.",
120 &MayaToEgg::dispatch_none, &_keep_all_uvsets);
124 "round up uv coordinates to the nearest 1/100th. i.e. -0.001 becomes" 125 "0.0; 0.444 becomes 0.44; 0.778 becomes 0.78.",
126 &MayaToEgg::dispatch_none, &_round_uvs);
129 (
"copytex",
"dir", 41,
130 "Legacy option. Same as -pc.",
131 &MayaToEgg::dispatch_filename, &_legacy_copytex, &_legacy_copytex_dir);
135 "Specifies which transforms in the Maya file should be converted to " 136 "transforms in the egg file. The option may be one of all, model, " 137 "dcs, or none. The default is model, which means only transforms on " 138 "nodes that have the model flag or the dcs flag are preserved.",
139 &MayaToEgg::dispatch_transform_type, NULL, &_transform_type);
142 (
"subroot",
"name", 0,
143 "Specifies that only a subroot of the geometry in the Maya file should " 144 "be converted; specifically, the geometry under the node or nodes whose " 145 "name matches the parameter (which may include globbing characters " 146 "like * or ?). This parameter may be repeated multiple times to name " 147 "multiple roots. If it is omitted altogether, the entire file is " 149 &MayaToEgg::dispatch_vector_string, NULL, &_subroots);
152 (
"subset",
"name", 0,
153 "Specifies that only a subset of the geometry in the Maya file should " 154 "be converted; specifically, the geometry under the node or nodes whose " 155 "name matches the parameter (which may include globbing characters " 156 "like * or ?). This parameter may be repeated multiple times to name " 157 "multiple roots. If it is omitted altogether, the entire file is " 159 &MayaToEgg::dispatch_vector_string, NULL, &_subsets);
162 (
"exclude",
"name", 0,
163 "Specifies that a subset of the geometry in the Maya file should " 164 "not be converted; specifically, the geometry under the node or nodes whose " 165 "name matches the parameter (which may include globbing characters " 166 "like * or ?). This parameter may be repeated multiple times to name " 168 &MayaToEgg::dispatch_vector_string, NULL, &_excludes);
171 (
"ignore-slider",
"name", 0,
172 "Specifies the name of a slider (blend shape deformer) that maya2egg " 173 "should not process. The slider will not be touched during conversion " 174 "and it will not become a part of the animation. This " 175 "parameter may including globbing characters, and it may be repeated " 177 &MayaToEgg::dispatch_vector_string, NULL, &_ignore_sliders);
180 (
"force-joint",
"name", 0,
181 "Specifies the name of a DAG node that maya2egg " 182 "should treat as a joint, even if it does not appear to be a Maya joint " 183 "and does not appear to be animated.",
184 &MayaToEgg::dispatch_vector_string, NULL, &_force_joints);
188 "Increase verbosity. More v's means more verbose.",
189 &MayaToEgg::dispatch_count, NULL, &_verbose);
192 (
"legacy-shaders",
"", 0,
193 "Use this flag to turn off modern (Phong) shader generation" 194 "and treat all shaders as if they were Lamberts (legacy).",
195 &MayaToEgg::dispatch_none, &_legacy_shader);
201 remove_option(
"noabs");
204 _polygon_tolerance = 0.01;
205 _transform_type = MayaToEggConverter::TT_model;
218 maya_cat->set_severity(NS_spam);
219 mayaegg_cat->set_severity(NS_spam);
220 }
else if (_verbose >= 2) {
221 maya_cat->set_severity(NS_debug);
222 mayaegg_cat->set_severity(NS_debug);
223 }
else if (_verbose >= 1) {
224 maya_cat->set_severity(NS_info);
225 mayaegg_cat->set_severity(NS_info);
228 if (_legacy_copytex && !_path_replace->_copy_files) {
229 _path_replace->_copy_files =
true;
230 _path_replace->_copy_into_directory = _legacy_copytex_dir;
236 if (_got_output_filename) {
237 _output_filename.make_absolute();
238 _path_replace->_path_directory.make_absolute();
241 nout <<
"Initializing Maya.\n";
245 if (!converter.open_api(
false)) {
246 nout <<
"Unable to initialize Maya.\n";
251 converter._polygon_output = _polygon_output;
252 converter._polygon_tolerance = _polygon_tolerance;
253 converter._respect_maya_double_sided = _respect_maya_double_sided;
254 converter._always_show_vertex_color = !_suppress_vertex_color;
255 converter._keep_all_uvsets = _keep_all_uvsets;
256 converter._convert_cameras = _convert_cameras;
257 converter._convert_lights = _convert_lights;
258 converter._round_uvs = _round_uvs;
259 converter._transform_type = _transform_type;
260 converter._legacy_shader = _legacy_shader;
262 vector_string::const_iterator si;
263 if (!_subroots.empty()) {
264 converter.clear_subroots();
265 for (si = _subroots.begin(); si != _subroots.end(); ++si) {
270 if (!_subsets.empty()) {
271 converter.clear_subsets();
272 for (si = _subsets.begin(); si != _subsets.end(); ++si) {
277 if (!_excludes.empty()) {
278 converter.clear_excludes();
279 for (si = _excludes.begin(); si != _excludes.end(); ++si) {
284 if (!_ignore_sliders.empty()) {
285 converter.clear_ignore_sliders();
286 for (si = _ignore_sliders.begin(); si != _ignore_sliders.end(); ++si) {
291 if (!_force_joints.empty()) {
292 converter.clear_force_joints();
293 for (si = _force_joints.begin(); si != _force_joints.end(); ++si) {
299 apply_parameters(converter);
302 if (!_got_coordinate_system) {
303 _coordinate_system = converter._maya->get_coordinate_system();
305 _data->set_coordinate_system(_coordinate_system);
307 converter.set_egg_data(_data);
309 if (!converter.convert_file(_input_filename)) {
310 nout <<
"Errors in conversion.\n";
318 if (_input_units == DU_invalid) {
319 _input_units = converter.get_input_units();
333 dispatch_transform_type(
const string &opt,
const string &arg,
void *var) {
334 MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var;
337 if ((*ip) == MayaToEggConverter::TT_invalid) {
338 nout <<
"Invalid type for -" << opt <<
": " << arg <<
"\n" 339 <<
"Valid types are all, model, dcs, and none.\n";
346 int main(
int argc,
char *argv[]) {
static TransformType string_transform_type(const string &arg)
Returns the TransformType value corresponding to the indicated string, or TT_invalid.
virtual void parse_command_line(int argc, char **argv)
Dispatches on each of the options on the command line, and passes the remaining parameters to handle_...
This class supervises the construction of an EggData structure from a single Maya file...
This is the general base class for a file-converter program that reads some model file format and gen...
This class can be used to test for string matches against standard Unix-shell filename globbing conve...