| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 << " Stops the converter from changing materials to <constant> if\n" | 102 << " Stops the converter from changing materials to <constant> if\n" |
| 103 << " they are used by a mesh that has no normals.\n" | 103 << " they are used by a mesh that has no normals.\n" |
| 104 << "--no-binary\n" | 104 << "--no-binary\n" |
| 105 << " Use JSON for buffers, skins, curves instead of binary\n" | 105 << " Use JSON for buffers, skins, curves instead of binary\n" |
| 106 << "--json-only\n" | 106 << "--json-only\n" |
| 107 << " Don't make a gzipped tar file, just JSON.\n"; | 107 << " Don't make a gzipped tar file, just JSON.\n"; |
| 108 return EXIT_FAILURE; | 108 return EXIT_FAILURE; |
| 109 } | 109 } |
| 110 | 110 |
| 111 o3d::converter::Options options; | 111 o3d::converter::Options options; |
| 112 options.condition = !command_line->HasSwitch(L"no-condition"); | 112 options.condition = !command_line->HasSwitch("no-condition"); |
| 113 options.pretty_print = command_line->HasSwitch(L"pretty-print"); | 113 options.pretty_print = command_line->HasSwitch("pretty-print"); |
| 114 options.binary = !command_line->HasSwitch(L"no-binary"); | 114 options.binary = !command_line->HasSwitch("no-binary"); |
| 115 options.json_only = !command_line->HasSwitch(L"json-only"); | 115 options.json_only = !command_line->HasSwitch("json-only"); |
| 116 if (command_line->HasSwitch(L"base-path")) { | 116 if (command_line->HasSwitch("base-path")) { |
| 117 options.base_path = o3d::WideToFilePath( | 117 options.base_path = o3d::WideToFilePath( |
| 118 command_line->GetSwitchValue(L"base-path")); | 118 command_line->GetSwitchValue("base-path")); |
| 119 } | 119 } |
| 120 if (command_line->HasSwitch(L"asset-paths")) { | 120 if (command_line->HasSwitch("asset-paths")) { |
| 121 std::vector<std::wstring> paths; | 121 std::vector<std::wstring> paths; |
| 122 SplitString(command_line->GetSwitchValue(L"asset-paths"), ',', &paths); | 122 SplitString(command_line->GetSwitchValue("asset-paths"), ',', &paths); |
| 123 for (size_t ii = 0; ii < paths.size(); ++ii) { | 123 for (size_t ii = 0; ii < paths.size(); ++ii) { |
| 124 options.file_paths.push_back(o3d::WideToFilePath(paths[ii])); | 124 options.file_paths.push_back(o3d::WideToFilePath(paths[ii])); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 if (command_line->HasSwitch(L"up-axis")) { | 127 if (command_line->HasSwitch("up-axis")) { |
| 128 wstring up_axis_string = command_line->GetSwitchValue(L"up-axis"); | 128 wstring up_axis_string = command_line->GetSwitchValue("up-axis"); |
| 129 int x, y, z; | 129 int x, y, z; |
| 130 if (swscanf(up_axis_string.c_str(), L"%d,%d,%d", &x, &y, &z) != 3) { | 130 if (swscanf(up_axis_string.c_str(), L"%d,%d,%d", &x, &y, &z) != 3) { |
| 131 std::cerr << "Invalid --up-axis value. Should be --up-axis=x,y,z\n"; | 131 std::cerr << "Invalid --up-axis value. Should be --up-axis=x,y,z\n"; |
| 132 return EXIT_FAILURE; | 132 return EXIT_FAILURE; |
| 133 } | 133 } |
| 134 options.up_axis = o3d::Vector3(static_cast<float>(x), | 134 options.up_axis = o3d::Vector3(static_cast<float>(x), |
| 135 static_cast<float>(y), | 135 static_cast<float>(y), |
| 136 static_cast<float>(z)); | 136 static_cast<float>(z)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 o3d::String error_messages; | 139 o3d::String error_messages; |
| 140 bool result = o3d::converter::Convert(in_filename, | 140 bool result = o3d::converter::Convert(in_filename, |
| 141 out_filename, | 141 out_filename, |
| 142 options, | 142 options, |
| 143 &error_messages); | 143 &error_messages); |
| 144 if (result) { | 144 if (result) { |
| 145 std::cerr << "Converted '" << o3d::FilePathToUTF8(in_filename).c_str() | 145 std::cerr << "Converted '" << o3d::FilePathToUTF8(in_filename).c_str() |
| 146 << "' to '" << o3d::FilePathToUTF8(out_filename).c_str() | 146 << "' to '" << o3d::FilePathToUTF8(out_filename).c_str() |
| 147 << "'." << std::endl; | 147 << "'." << std::endl; |
| 148 return EXIT_SUCCESS; | 148 return EXIT_SUCCESS; |
| 149 } else { | 149 } else { |
| 150 std::cerr << error_messages.c_str() << std::endl; | 150 std::cerr << error_messages.c_str() << std::endl; |
| 151 std::cerr << "FAILED to convert '" | 151 std::cerr << "FAILED to convert '" |
| 152 << o3d::FilePathToUTF8(in_filename).c_str() | 152 << o3d::FilePathToUTF8(in_filename).c_str() |
| 153 << "' to '" << o3d::FilePathToUTF8(out_filename).c_str() | 153 << "' to '" << o3d::FilePathToUTF8(out_filename).c_str() |
| 154 << "'." << std::endl; | 154 << "'." << std::endl; |
| 155 return EXIT_FAILURE; | 155 return EXIT_FAILURE; |
| 156 } | 156 } |
| 157 } | 157 } |
| OLD | NEW |