summaryrefslogtreecommitdiffstats
path: root/o3d/converter
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 00:18:29 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 00:18:29 +0000
commitcb27fe7df0f1c308ea5b87c5dc42a91a960d979e (patch)
tree0a9f5c760215d895243972a1030f76db19e40c4c /o3d/converter
parent2383c9497d4ea626fd4612f979cf81cca5a4dbbe (diff)
downloadchromium_src-cb27fe7df0f1c308ea5b87c5dc42a91a960d979e.zip
chromium_src-cb27fe7df0f1c308ea5b87c5dc42a91a960d979e.tar.gz
chromium_src-cb27fe7df0f1c308ea5b87c5dc42a91a960d979e.tar.bz2
Add --file_paths to converter to allow converter to run
with typical collada files found on the net. Often someone will export a collada file with absolute paths like "z:\someplace\somewhere\texture.tga" and "k:\shared\stuff\othertexture.tga" The converter needed a way to handle these without requiring an artist to manually edit XML files. I also refactored the original_data_ stuff to make sure we don't get 2 datas for the same path. I'm doing that in prepartion for shortening the paths where possible using base-path or some mechanism. Review URL: http://codereview.chromium.org/159118 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21352 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/converter')
-rw-r--r--o3d/converter/cross/converter.cc6
-rw-r--r--o3d/converter/cross/converter.h5
-rw-r--r--o3d/converter/cross/converter_main.cc12
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;