00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "eggToMaya.h"
00016 #include "mayaEggLoader.h"
00017 #include "mayaApi.h"
00018 #ifdef _WIN32
00019 #include "pystub.h"
00020 #endif
00021
00022
00023
00024 #define _MApiVersion
00025
00026 #include "pre_maya_include.h"
00027 #include <maya/MString.h>
00028 #include <maya/MFileIO.h>
00029 #include "post_maya_include.h"
00030
00031
00032
00033
00034
00035
00036 EggToMaya::
00037 EggToMaya() :
00038 EggToSomething("Maya", ".mb", true, false)
00039 {
00040 add_units_options();
00041
00042 set_binary_output(true);
00043 set_program_description
00044 ("egg2maya converts files from egg format to Maya .mb or .ma "
00045 "format. It contains support for basic geometry (polygons with textures)."
00046 "It also supports animation for joints.");
00047
00048 add_option
00049 ("a", "", 0,
00050 "Convert animation tables.",
00051 &EggToMaya::dispatch_none, &_convert_anim);
00052
00053 add_option
00054 ("m", "", 0,
00055 "Convert polygon models. You may specify both -a and -m at the same "
00056 "time. If you specify neither, the default is -m.",
00057 &EggToMaya::dispatch_none, &_convert_model);
00058
00059 add_option
00060 ("nv", "", 0,
00061 "respect vertex and polygon normals.",
00062 &EggToMaya::dispatch_none, &_respect_normals);
00063
00064
00065 _output_units = DU_centimeters;
00066 }
00067
00068
00069
00070
00071
00072
00073 void EggToMaya::
00074 run() {
00075 if (!_convert_anim && !_convert_model) {
00076 _convert_model = true;
00077 }
00078
00079
00080
00081
00082 _output_filename.make_absolute();
00083
00084 nout << "Initializing Maya.\n";
00085 PT(MayaApi) maya = MayaApi::open_api(_program_name);
00086 if (!maya->is_valid()) {
00087 nout << "Unable to initialize Maya.\n";
00088 exit(1);
00089 }
00090
00091 MStatus status;
00092 status = MFileIO::newFile(true);
00093 if (!status) {
00094 status.perror("Could not initialize file");
00095 exit(1);
00096 }
00097
00098
00099
00100
00101
00102
00103 maya->set_units(_output_units);
00104
00105 if (_output_units != DU_centimeters && _output_units != DU_invalid) {
00106 nout << "Converting from centimeters"
00107 << " to " << format_long_unit(_output_units) << "\n";
00108 }
00109
00110
00111 if (!MayaLoadEggData(_data, true, _convert_model, _convert_anim, _respect_normals)) {
00112 nout << "Unable to convert egg file.\n";
00113 exit(1);
00114 }
00115
00116 if (!maya->write(_output_filename)) {
00117 status.perror("Could not save file");
00118 exit(1);
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 }
00135
00136 int main(int argc, char *argv[]) {
00137
00138 #ifdef _WIN32
00139
00140 pystub();
00141 #endif
00142
00143 EggToMaya prog;
00144 prog.parse_command_line(argc, argv);
00145 prog.run();
00146 return 0;
00147 }
00148