14 #if defined(WIN32_VC) || defined(WIN64_VC)
30 add_path_replace_options();
31 add_path_store_options();
37 set_program_brief(
"convert Maya model files to .egg");
38 set_program_description
39 (
"This program converts Maya model files to egg. Static and animatable "
40 "models can be converted, with polygon or NURBS output. Animation tables "
41 "can also be generated to apply to an animatable model.");
45 "Generate polygon output only. Tesselate all NURBS surfaces to "
46 "polygons via the built-in Maya tesselator. The tesselation will "
47 "be based on the tolerance factor given by -ptol.",
48 &MayaToEggServer::dispatch_none, &_polygon_output);
51 (
"ptol",
"tolerance", 0,
52 "Specify the fit tolerance for Maya polygon tesselation. The smaller "
53 "the number, the more polygons will be generated. The default is "
55 &MayaToEggServer::dispatch_double,
nullptr, &_polygon_tolerance);
59 "Respect the Maya \"double sided\" rendering flag to indicate whether "
60 "polygons should be double-sided or single-sided. Since this flag "
61 "is set to double-sided by default in Maya, it is often better to "
62 "ignore this flag (unless your modelers are diligent in turning it "
63 "off where it is not desired). If this flag is not specified, the "
64 "default is to treat all polygons as single-sided, unless an "
65 "egg object type of \"double-sided\" is set.",
66 &MayaToEggServer::dispatch_none, &_respect_maya_double_sided);
69 (
"suppress-vcolor",
"", 0,
70 "Ignore vertex color for geometry that has a texture applied. "
71 "(This is the way Maya normally renders internally.) The egg flag "
72 "'vertex-color' may be applied to a particular model to override "
73 "this setting locally.",
74 &MayaToEggServer::dispatch_none, &_suppress_vertex_color);
78 "Convert all UV sets on all vertices, even those that do not appear "
79 "to be referenced by any textures.",
80 &MayaToEggServer::dispatch_none, &_keep_all_uvsets);
84 "round up uv coordinates to the nearest 1/100th. i.e. -0.001 becomes"
85 "0.0; 0.444 becomes 0.44; 0.778 becomes 0.78.",
86 &MayaToEggServer::dispatch_none, &_round_uvs);
90 "Specifies which transforms in the Maya file should be converted to "
91 "transforms in the egg file. The option may be one of all, model, "
92 "dcs, or none. The default is model, which means only transforms on "
93 "nodes that have the model flag or the dcs flag are preserved.",
94 &MayaToEggServer::dispatch_transform_type,
nullptr, &_transform_type);
97 (
"subroot",
"name", 0,
98 "Specifies that only a subroot of the geometry in the Maya file should "
99 "be converted; specifically, the geometry under the node or nodes whose "
100 "name matches the parameter (which may include globbing characters "
101 "like * or ?). This parameter may be repeated multiple times to name "
102 "multiple roots. If it is omitted altogether, the entire file is "
104 &MayaToEggServer::dispatch_vector_string,
nullptr, &_subroots);
107 (
"subset",
"name", 0,
108 "Specifies that only a subset of the geometry in the Maya file should "
109 "be converted; specifically, the geometry under the node or nodes whose "
110 "name matches the parameter (which may include globbing characters "
111 "like * or ?). This parameter may be repeated multiple times to name "
112 "multiple roots. If it is omitted altogether, the entire file is "
114 &MayaToEggServer::dispatch_vector_string,
nullptr, &_subsets);
117 (
"exclude",
"name", 0,
118 "Specifies that a subset of the geometry in the Maya file should "
119 "not be converted; specifically, the geometry under the node or nodes whose "
120 "name matches the parameter (which may include globbing characters "
121 "like * or ?). This parameter may be repeated multiple times to name "
123 &MayaToEggServer::dispatch_vector_string,
nullptr, &_excludes);
126 (
"ignore-slider",
"name", 0,
127 "Specifies the name of a slider (blend shape deformer) that maya2egg "
128 "should not process. The slider will not be touched during conversion "
129 "and it will not become a part of the animation. This "
130 "parameter may including globbing characters, and it may be repeated "
132 &MayaToEggServer::dispatch_vector_string,
nullptr, &_ignore_sliders);
135 (
"force-joint",
"name", 0,
136 "Specifies the name of a DAG node that maya2egg "
137 "should treat as a joint, even if it does not appear to be a Maya joint "
138 "and does not appear to be animated.",
139 &MayaToEggServer::dispatch_vector_string,
nullptr, &_force_joints);
143 "Increase verbosity. More v's means more verbose.",
144 &MayaToEggServer::dispatch_count,
nullptr, &_verbose);
147 (
"legacy-shaders",
"", 0,
148 "Use this flag to turn off modern (Phong) shader generation"
149 "and treat all shaders as if they were Lamberts (legacy).",
150 &MayaToEggServer::dispatch_none, &_legacy_shader);
156 remove_option(
"noabs");
159 _polygon_tolerance = 0.01;
160 _transform_type = MayaToEggConverter::TT_model;
168 nout <<
"Initializing Maya...\n";
169 if (!dummy->open_api()) {
170 nout <<
"Unable to initialize Maya.\n";
189 void MayaToEggServer::
196 maya_cat->set_severity(NS_spam);
197 mayaegg_cat->set_severity(NS_spam);
198 }
else if (_verbose >= 2) {
199 maya_cat->set_severity(NS_debug);
200 mayaegg_cat->set_severity(NS_debug);
201 }
else if (_verbose >= 1) {
202 maya_cat->set_severity(NS_info);
203 mayaegg_cat->set_severity(NS_info);
208 if (_got_output_filename) {
209 _output_filename.make_absolute();
210 _path_replace->_path_directory.make_absolute();
216 converter._polygon_output = _polygon_output;
217 converter._polygon_tolerance = _polygon_tolerance;
218 converter._respect_maya_double_sided = _respect_maya_double_sided;
219 converter._always_show_vertex_color = !_suppress_vertex_color;
220 converter._keep_all_uvsets = _keep_all_uvsets;
221 converter._round_uvs = _round_uvs;
222 converter._transform_type = _transform_type;
223 converter._legacy_shader = _legacy_shader;
225 vector_string::const_iterator si;
226 if (!_subroots.empty()) {
227 converter.clear_subroots();
228 for (si = _subroots.begin(); si != _subroots.end(); ++si) {
233 if (!_subsets.empty()) {
234 converter.clear_subsets();
235 for (si = _subsets.begin(); si != _subsets.end(); ++si) {
240 if (!_excludes.empty()) {
241 converter.clear_excludes();
242 for (si = _excludes.begin(); si != _excludes.end(); ++si) {
247 if (!_ignore_sliders.empty()) {
248 converter.clear_ignore_sliders();
249 for (si = _ignore_sliders.begin(); si != _ignore_sliders.end(); ++si) {
254 if (!_force_joints.empty()) {
255 converter.clear_force_joints();
256 for (si = _force_joints.begin(); si != _force_joints.end(); ++si) {
262 apply_parameters(converter);
265 if (!_got_coordinate_system) {
266 _coordinate_system = converter._maya->get_coordinate_system();
268 _data->set_coordinate_system(_coordinate_system);
270 converter.set_egg_data(_data);
272 if (!converter.convert_file(_input_filename)) {
273 nout <<
"Errors in conversion.\n";
281 if (_input_units == DU_invalid) {
282 _input_units = converter.get_input_units();
286 append_command_comment(_data);
293 _polygon_tolerance = 0.01;
295 _transform_type = MayaToEggConverter::TT_model;
298 _input_units = DU_invalid;
299 _output_units = DU_invalid;
301 _ignore_sliders.clear();
302 _force_joints.clear();
303 _got_transform =
false;
304 _transform = LMatrix4d::ident_mat();
305 _normals_mode = NM_preserve;
306 _normals_threshold = 0.0;
307 _got_start_frame =
false;
308 _got_end_frame =
false;
309 _got_frame_inc =
false;
310 _got_neutral_frame =
false;
311 _got_input_frame_rate =
false;
312 _got_output_frame_rate =
false;
313 _got_output_filename =
false;
314 _merge_externals =
false;
316 _got_tbnauto =
false;
317 _got_transform =
false;
318 _coordinate_system = CS_yup_right;
320 _program_args.clear();
322 _animation_convert = AC_none;
323 _character_name =
"";
331 bool MayaToEggServer::
332 dispatch_transform_type(
const std::string &opt,
const std::string &arg,
void *var) {
333 MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var;
336 if ((*ip) == MayaToEggConverter::TT_invalid) {
337 nout <<
"Invalid type for -" << opt <<
": " << arg <<
"\n"
338 <<
"Valid types are all, model, dcs, and none.\n";
362 _clients.insert(con);
370 _clients.erase(connection);
371 qManager->close_connection(connection);
383 int argc = data.get_uint8();
392 std::vector<char *> buffers;
396 for ( i = 0; i < argc; i++ ) {
397 vargv.push_back(data.get_string());
402 std::string cwd = data.get_string();
406 char ** cargv = (
char**) malloc(
sizeof(
char**) * argc);
412 for ( i = 0; i < argc; i++) {
414 const char * cptr = vargv[i].c_str();
416 char * buffer = (
char*) malloc(vargv[i].capacity()+1);
418 strcpy(buffer, cptr);
424 buffers.push_back(buffer);
442 std::vector<char *>::iterator vi;
443 for ( vi = buffers.begin() ; vi != buffers.end(); vi++) {
450 Clients::iterator ci;
451 for (ci = _clients.begin(); ci != _clients.end(); ++ci) {
452 qManager->close_connection(*ci);
457 int main(
int argc,
char *argv[]) {
460 PT(
Connection) rend = prog.qManager->open_TCP_server_rendezvous(4242, 50);
461 if (rend.is_null()) {
462 nout <<
"port opened fail";