diff options
Diffstat (limited to 'o3d/converter')
-rw-r--r-- | o3d/converter/cross/converter.cc | 6 | ||||
-rw-r--r-- | o3d/converter/cross/converter.h | 5 | ||||
-rw-r--r-- | o3d/converter/cross/converter_main.cc | 12 |
3 files changed, 20 insertions, 3 deletions
diff --git a/o3d/converter/cross/converter.cc b/o3d/converter/cross/converter.cc index 497b8cd..9abde79 100644 --- a/o3d/converter/cross/converter.cc +++ b/o3d/converter/cross/converter.cc @@ -66,11 +66,12 @@ namespace o3d { namespace { void AddBinaryElements(const Collada& collada, TarGzGenerator* archive_generator) { - std::vector<FilePath> paths = collada.GetOriginalDataFilenames(); + const ColladaDataMap& data_map(collada.original_data_map()); + std::vector<FilePath> paths = data_map.GetOriginalDataFilenames(); for (std::vector<FilePath>::const_iterator iter = paths.begin(); iter != paths.end(); ++iter) { - const std::string& data = collada.GetOriginalData(*iter); + const std::string& data = data_map.GetOriginalData(*iter); archive_generator->AddFile(FilePathToUTF8(*iter), data.size()); archive_generator->AddFileBytes( @@ -120,6 +121,7 @@ bool Convert(const FilePath& in_filename, collada_options.condition_document = options.condition; collada_options.keep_original_data = true; collada_options.base_path = options.base_path; + collada_options.file_paths = options.file_paths; collada_options.up_axis = options.up_axis; Collada collada(pack.Get(), collada_options); bool result = collada.ImportFile(in_filename, root, param_float); diff --git a/o3d/converter/cross/converter.h b/o3d/converter/cross/converter.h index dd0141c..d613564 100644 --- a/o3d/converter/cross/converter.h +++ b/o3d/converter/cross/converter.h @@ -38,8 +38,10 @@ #ifndef O3D_CONVERTER_CROSS_CONVERTER_H_ #define O3D_CONVERTER_CROSS_CONVERTER_H_ +#include <vector> #include "base/file_path.h" #include "core/cross/types.h" +#include "utils/cross/file_path_utils.h" namespace o3d { namespace converter { @@ -55,6 +57,9 @@ struct Options { keep_materials(false) { } + // A list of paths to search for assets.. + std::vector<FilePath> file_paths; + // The path to the "base" of the model path, from which all paths // are made relative. Defaults to the current directory. FilePath base_path; diff --git a/o3d/converter/cross/converter_main.cc b/o3d/converter/cross/converter_main.cc index 650e0b7..e332db4 100644 --- a/o3d/converter/cross/converter_main.cc +++ b/o3d/converter/cross/converter_main.cc @@ -40,6 +40,7 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/file_path.h" +#include "base/string_util.h" #include "converter/cross/converter.h" #include "utils/cross/file_path_utils.h" @@ -86,7 +87,9 @@ int CrossMain(int argc, char**argv) { << "--no-condition\n" << " Stops the converter from conditioning shaders.\n" << "--base-path=<path>\n" - << " Sets the base path for finding textures and other external\n" + << " Sets the path to remove from URIs of external files\n" + << "--asset-paths=<comma separted list of paths>\n" + << " Sets the paths for finding textures and other external\n" << " files.\n" << "--up-axis=x,y,z\n" << " Converts the file to have this up axis.\n" @@ -108,6 +111,13 @@ int CrossMain(int argc, char**argv) { options.base_path = o3d::WideToFilePath( command_line->GetSwitchValue(L"base-path")); } + if (command_line->HasSwitch(L"asset-paths")) { + std::vector<std::wstring> paths; + SplitString(command_line->GetSwitchValue(L"asset-paths"), ',', &paths); + for (size_t ii = 0; ii < paths.size(); ++ii) { + options.file_paths.push_back(o3d::WideToFilePath(paths[ii])); + } + } if (command_line->HasSwitch(L"up-axis")) { wstring up_axis_string = command_line->GetSwitchValue(L"up-axis"); int x, y, z; |