Skip to content

Commit b7f105e

Browse files
committed
Add a 'convert' command.
1 parent ff5a96f commit b7f105e

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

fbxcppcli/main.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ void PrintUsage()
99
std::cout << "fbxcppcli [COMMAND]" << std::endl <<
1010
std::endl <<
1111
"Available Commands" << std::endl <<
12-
" help Display this help text." << std::endl <<
13-
" info [FILENAME] Display file info about FILENAME." << std::endl <<
14-
" print [FILENAME] Display the contents of FILENAME." << std::endl <<
12+
" help Display this help text." << std::endl <<
13+
" info [FILENAME] Display file info about FILENAME." << std::endl <<
14+
" print [FILENAME] Display the contents of FILENAME." << std::endl <<
15+
" convert [SOURCE] [DEST] Open the SOURCE file and then save it as ascii at DEST." << std::endl <<
1516
std::endl;
1617
}
1718

@@ -79,6 +80,29 @@ int main (int argc, const char *argv[])
7980
return 0;
8081
}
8182

83+
if (command == "convert")
84+
{
85+
if (argc <= 2)
86+
{
87+
std::cout << "print: No source filename provided." << std::endl;
88+
PrintUsage();
89+
return 2;
90+
}
91+
if (argc <= 3)
92+
{
93+
std::cout << "print: No destination filename provided." << std::endl;
94+
PrintUsage();
95+
return 2;
96+
}
97+
98+
std::string source = argv[2];
99+
FbxScene* scene = Load(source.c_str());
100+
std::string dest = argv[3];
101+
Save(dest.c_str(), scene);
102+
return 0;
103+
}
104+
82105
std::cout << "Unknown command \"" << command << "\"" << std::endl;
106+
PrintUsage();
83107
return 1;
84108
}

fbxcppcommon/fileio.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ void Save(const char* filename, FbxScene* scene)
2929
FbxManager* manager = scene->GetFbxManager();
3030

3131
FbxIOSettings* ios = FbxIOSettings::Create(manager, IOSROOT);
32-
ios->SetEnumProp(EXP_ASCIIFBX, 1);
32+
ios->SetBoolProp(EXP_ASCIIFBX, true);
3333

3434
FbxExporter * ex = FbxExporter::Create(manager, "");
35-
36-
ex->Initialize(filename, -1, ios);
35+
int lFormat = manager->GetIOPluginRegistry()->FindWriterIDByDescription("FBX ascii (*.fbx)");
36+
ex->Initialize(filename, lFormat, ios);
3737
ex->Export(scene);
3838
}
3939

0 commit comments

Comments
 (0)