2015-07-02 11:07:50 +00:00
|
|
|
/*
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
Open Asset Import Library (assimp)
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2024-02-23 21:30:05 +00:00
|
|
|
Copyright (c) 2006-2024, assimp team
|
2018-01-28 18:42:05 +00:00
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
All rights reserved.
|
|
|
|
|
2021-07-29 11:28:51 +00:00
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
|
|
with or without modification, are permitted provided that the following
|
2015-07-02 11:07:50 +00:00
|
|
|
conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
copyright notice, this list of conditions and the
|
|
|
|
following disclaimer in the documentation and/or other
|
|
|
|
materials provided with the distribution.
|
|
|
|
|
|
|
|
* Neither the name of the assimp team, nor the names of its
|
|
|
|
contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior
|
|
|
|
written permission of the assimp team.
|
|
|
|
|
2021-07-29 11:28:51 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
2015-07-02 11:07:50 +00:00
|
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
2021-07-29 11:28:51 +00:00
|
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
2015-07-02 11:07:50 +00:00
|
|
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
2021-07-29 11:28:51 +00:00
|
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
2015-07-02 11:07:50 +00:00
|
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
2021-07-29 11:28:51 +00:00
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
2015-07-02 11:07:50 +00:00
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file Main.cpp
|
|
|
|
* @brief main() function of assimp_cmd
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Main.h"
|
|
|
|
|
2021-12-26 10:16:02 +00:00
|
|
|
#include <assimp/ProgressHandler.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
class ConsoleProgressHandler : public ProgressHandler {
|
|
|
|
public:
|
|
|
|
ConsoleProgressHandler() :
|
|
|
|
ProgressHandler() {
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
2022-09-01 15:37:53 +00:00
|
|
|
~ConsoleProgressHandler() override = default;
|
2021-12-26 10:16:02 +00:00
|
|
|
|
|
|
|
bool Update(float percentage) override {
|
2022-09-16 19:55:14 +00:00
|
|
|
std::cout << "\r" << percentage * 100.0f << " %";
|
2021-12-26 10:16:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2022-09-16 19:55:14 +00:00
|
|
|
|
|
|
|
constexpr char AICMD_MSG_ABOUT[] =
|
2015-07-02 11:07:50 +00:00
|
|
|
"------------------------------------------------------ \n"
|
2017-07-30 19:21:51 +00:00
|
|
|
"Open Asset Import Library (\"Assimp\", https://github.com/assimp/assimp) \n"
|
2015-07-02 11:07:50 +00:00
|
|
|
" -- Commandline toolchain --\n"
|
|
|
|
"------------------------------------------------------ \n\n"
|
|
|
|
|
|
|
|
"Version %i.%i %s%s%s%s%s(GIT commit %x)\n\n";
|
|
|
|
|
2022-09-16 19:55:14 +00:00
|
|
|
constexpr char AICMD_MSG_HELP[] =
|
2015-07-02 11:07:50 +00:00
|
|
|
"assimp <verb> <parameters>\n\n"
|
|
|
|
" verbs:\n"
|
|
|
|
" \tinfo - Quick file stats\n"
|
|
|
|
" \tlistext - List all known file extensions available for import\n"
|
|
|
|
" \tknowext - Check whether a file extension is recognized by Assimp\n"
|
|
|
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
|
|
|
" \texport - Export a file to one of the supported output formats\n"
|
|
|
|
" \tlistexport - List all supported export formats\n"
|
|
|
|
" \texportinfo - Show basic information on a specific export format\n"
|
|
|
|
#endif
|
|
|
|
" \textract - Extract embedded texture images\n"
|
|
|
|
" \tdump - Convert models to a binary or textual dump (ASSBIN/ASSXML)\n"
|
|
|
|
" \tcmpdump - Compare dumps created using \'assimp dump <file> -s ...\'\n"
|
|
|
|
" \tversion - Display Assimp version\n"
|
|
|
|
"\n Use \'assimp <verb> --help\' for detailed help on a command.\n"
|
|
|
|
;
|
|
|
|
|
2021-12-26 10:16:02 +00:00
|
|
|
/*extern*/ Assimp::Importer* globalImporter = nullptr;
|
2015-07-02 11:07:50 +00:00
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
2021-12-26 10:16:02 +00:00
|
|
|
/*extern*/ Assimp::Exporter* globalExporter = nullptr;
|
2015-07-02 11:07:50 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
// Application entry point
|
2022-09-16 19:55:14 +00:00
|
|
|
int main (int argc, char* argv[]) {
|
2015-07-02 11:07:50 +00:00
|
|
|
if (argc <= 1) {
|
|
|
|
printf("assimp: No command specified. Use \'assimp help\' for a detailed command list\n");
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// assimp version
|
|
|
|
// Display version information
|
|
|
|
if (! strcmp(argv[1], "version")) {
|
|
|
|
const unsigned int flags = aiGetCompileFlags();
|
|
|
|
printf(AICMD_MSG_ABOUT,
|
|
|
|
aiGetVersionMajor(),
|
|
|
|
aiGetVersionMinor(),
|
|
|
|
(flags & ASSIMP_CFLAGS_DEBUG ? "-debug " : ""),
|
|
|
|
(flags & ASSIMP_CFLAGS_NOBOOST ? "-noboost " : ""),
|
|
|
|
(flags & ASSIMP_CFLAGS_SHARED ? "-shared " : ""),
|
|
|
|
(flags & ASSIMP_CFLAGS_SINGLETHREADED ? "-st " : ""),
|
|
|
|
(flags & ASSIMP_CFLAGS_STLPORT ? "-stlport " : ""),
|
|
|
|
aiGetVersionRevision());
|
|
|
|
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// assimp help
|
2021-07-29 11:28:51 +00:00
|
|
|
// Display some basic help (--help and -h work as well
|
2015-07-02 11:07:50 +00:00
|
|
|
// because people could try them intuitively)
|
|
|
|
if (!strcmp(argv[1], "help") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
|
|
|
|
printf("%s",AICMD_MSG_HELP);
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// assimp cmpdump
|
2021-07-29 11:28:51 +00:00
|
|
|
// Compare two mini model dumps (regression suite)
|
2015-07-02 11:07:50 +00:00
|
|
|
if (! strcmp(argv[1], "cmpdump")) {
|
|
|
|
return Assimp_CompareDump (&argv[2],argc-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// construct global importer and exporter instances
|
|
|
|
Assimp::Importer imp;
|
|
|
|
imp.SetPropertyBool("GLOB_MEASURE_TIME",true);
|
|
|
|
globalImporter = &imp;
|
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
2021-07-29 11:28:51 +00:00
|
|
|
//
|
2015-07-02 11:07:50 +00:00
|
|
|
Assimp::Exporter exp;
|
|
|
|
globalExporter = &exp;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// assimp listext
|
|
|
|
// List all file extensions supported by Assimp
|
|
|
|
if (! strcmp(argv[1], "listext")) {
|
|
|
|
aiString s;
|
|
|
|
imp.GetExtensionList(s);
|
|
|
|
|
|
|
|
printf("%s\n",s.data);
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
|
|
|
// assimp listexport
|
|
|
|
// List all export file formats supported by Assimp (not the file extensions, just the format identifiers!)
|
|
|
|
if (! strcmp(argv[1], "listexport")) {
|
|
|
|
aiString s;
|
2021-07-29 11:28:51 +00:00
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) {
|
|
|
|
const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i);
|
|
|
|
s.Append( e->id );
|
|
|
|
if (i!=end-1) {
|
|
|
|
s.Append("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%s\n",s.data);
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// assimp exportinfo
|
|
|
|
// stat an export format
|
|
|
|
if (! strcmp(argv[1], "exportinfo")) {
|
|
|
|
aiString s;
|
|
|
|
|
|
|
|
if (argc<3) {
|
|
|
|
printf("Expected file format id\n");
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::NoFileFormatSpecified;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) {
|
|
|
|
const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i);
|
|
|
|
if (!strcmp(e->id,argv[2])) {
|
|
|
|
printf("%s\n%s\n%s\n",e->id,e->fileExtension,e->description);
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-29 11:28:51 +00:00
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
printf("Unknown file format id: \'%s\'\n",argv[2]);
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::UnknownFileFormat;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// assimp export
|
|
|
|
// Export a model to a file
|
|
|
|
if (! strcmp(argv[1], "export")) {
|
|
|
|
return Assimp_Export (&argv[2],argc-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// assimp knowext
|
|
|
|
// Check whether a particular file extension is known by us, return 0 on success
|
|
|
|
if (! strcmp(argv[1], "knowext")) {
|
|
|
|
if (argc<3) {
|
|
|
|
printf("Expected file extension");
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::NoFileExtensionSpecified;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
const bool b = imp.IsExtensionSupported(argv[2]);
|
|
|
|
printf("File extension \'%s\' is %sknown\n",argv[2],(b?"":"not "));
|
2020-01-26 18:10:21 +00:00
|
|
|
return b? AssimpCmdError::Success : AssimpCmdError::UnknownFileExtension;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// assimp info
|
|
|
|
// Print basic model statistics
|
|
|
|
if (! strcmp(argv[1], "info")) {
|
|
|
|
return Assimp_Info ((const char**)&argv[2],argc-2);
|
|
|
|
}
|
|
|
|
|
2021-07-29 11:28:51 +00:00
|
|
|
// assimp dump
|
|
|
|
// Dump a model to a file
|
2015-07-02 11:07:50 +00:00
|
|
|
if (! strcmp(argv[1], "dump")) {
|
|
|
|
return Assimp_Dump (&argv[2],argc-2);
|
|
|
|
}
|
|
|
|
|
2021-07-29 11:28:51 +00:00
|
|
|
// assimp extract
|
2015-07-02 11:07:50 +00:00
|
|
|
// Extract an embedded texture from a file
|
|
|
|
if (! strcmp(argv[1], "extract")) {
|
|
|
|
return Assimp_Extract (&argv[2],argc-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// assimp testbatchload
|
|
|
|
// Used by /test/other/streamload.py to load a list of files
|
|
|
|
// using the same importer instance to check for incompatible
|
|
|
|
// importers.
|
|
|
|
if (! strcmp(argv[1], "testbatchload")) {
|
|
|
|
return Assimp_TestBatchLoad (&argv[2],argc-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Unrecognized command. Use \'assimp help\' for a detailed command list\n");
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::UnrecognizedCommand;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
void SetLogStreams(const ImportData& imp)
|
|
|
|
{
|
|
|
|
printf("\nAttaching log stream ... OK\n");
|
2021-07-29 11:28:51 +00:00
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
unsigned int flags = 0;
|
|
|
|
if (imp.logFile.length()) {
|
|
|
|
flags |= aiDefaultLogStream_FILE;
|
|
|
|
}
|
|
|
|
if (imp.showLog) {
|
|
|
|
flags |= aiDefaultLogStream_STDERR;
|
|
|
|
}
|
|
|
|
DefaultLogger::create(imp.logFile.c_str(),imp.verbose ? Logger::VERBOSE : Logger::NORMAL,flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
void FreeLogStreams()
|
|
|
|
{
|
|
|
|
DefaultLogger::kill();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
void PrintHorBar()
|
|
|
|
{
|
|
|
|
printf("-----------------------------------------------------------------\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
// Import a specific file
|
|
|
|
const aiScene* ImportModel(
|
2021-07-29 11:28:51 +00:00
|
|
|
const ImportData& imp,
|
2015-07-02 11:07:50 +00:00
|
|
|
const std::string& path)
|
|
|
|
{
|
|
|
|
// Attach log streams
|
|
|
|
if (imp.log) {
|
|
|
|
SetLogStreams(imp);
|
|
|
|
}
|
|
|
|
printf("Launching asset import ... OK\n");
|
|
|
|
|
|
|
|
// Now validate this flag combination
|
|
|
|
if(!globalImporter->ValidateFlags(imp.ppFlags)) {
|
|
|
|
printf("ERROR: Unsupported post-processing flags \n");
|
2022-11-08 16:13:14 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2015-07-02 11:07:50 +00:00
|
|
|
printf("Validating postprocessing flags ... OK\n");
|
|
|
|
if (imp.showLog) {
|
|
|
|
PrintHorBar();
|
|
|
|
}
|
2021-07-29 11:28:51 +00:00
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
|
|
|
|
// do the actual import, measure time
|
|
|
|
const clock_t first = clock();
|
2021-12-26 10:16:02 +00:00
|
|
|
ConsoleProgressHandler *ph = new ConsoleProgressHandler;
|
|
|
|
globalImporter->SetProgressHandler(ph);
|
2023-01-16 08:12:35 +00:00
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
const aiScene* scene = globalImporter->ReadFile(path,imp.ppFlags);
|
|
|
|
|
|
|
|
if (imp.showLog) {
|
|
|
|
PrintHorBar();
|
|
|
|
}
|
|
|
|
if (!scene) {
|
2015-12-14 06:12:25 +00:00
|
|
|
printf("ERROR: Failed to load file: %s\n", globalImporter->GetErrorString());
|
2022-11-08 16:13:14 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2015-07-02 11:07:50 +00:00
|
|
|
|
|
|
|
const clock_t second = ::clock();
|
|
|
|
const double seconds = static_cast<double>(second-first) / CLOCKS_PER_SEC;
|
|
|
|
|
|
|
|
printf("Importing file ... OK \n import took approx. %.5f seconds\n"
|
|
|
|
"\n",seconds);
|
|
|
|
|
2021-07-29 11:28:51 +00:00
|
|
|
if (imp.log) {
|
2015-07-02 11:07:50 +00:00
|
|
|
FreeLogStreams();
|
|
|
|
}
|
2021-12-26 10:16:02 +00:00
|
|
|
globalImporter->SetProgressHandler(nullptr);
|
|
|
|
delete ph;
|
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
return scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef ASSIMP_BUILD_NO_EXPORT
|
|
|
|
// ------------------------------------------------------------------------------
|
2021-07-29 11:28:51 +00:00
|
|
|
bool ExportModel(const aiScene* pOut,
|
|
|
|
const ImportData& imp,
|
2015-07-02 11:07:50 +00:00
|
|
|
const std::string& path,
|
|
|
|
const char* pID)
|
|
|
|
{
|
|
|
|
// Attach log streams
|
|
|
|
if (imp.log) {
|
|
|
|
SetLogStreams(imp);
|
|
|
|
}
|
|
|
|
printf("Launching asset export ... OK\n");
|
|
|
|
|
|
|
|
if (imp.showLog) {
|
|
|
|
PrintHorBar();
|
|
|
|
}
|
|
|
|
|
2021-03-10 09:06:42 +00:00
|
|
|
aiMatrix4x4 rx, ry, rz;
|
|
|
|
aiMatrix4x4::RotationX(imp.rot.x, rx);
|
2021-03-15 01:23:17 +00:00
|
|
|
aiMatrix4x4::RotationY(imp.rot.y, ry);
|
|
|
|
aiMatrix4x4::RotationZ(imp.rot.z, rz);
|
2021-03-10 09:06:42 +00:00
|
|
|
pOut->mRootNode->mTransformation *= rx;
|
|
|
|
pOut->mRootNode->mTransformation *= ry;
|
|
|
|
pOut->mRootNode->mTransformation *= rz;
|
|
|
|
|
2015-07-02 11:07:50 +00:00
|
|
|
// do the actual export, measure time
|
|
|
|
const clock_t first = clock();
|
|
|
|
const aiReturn res = globalExporter->Export(pOut,pID,path);
|
|
|
|
|
|
|
|
if (imp.showLog) {
|
|
|
|
PrintHorBar();
|
|
|
|
}
|
|
|
|
if (res != AI_SUCCESS) {
|
2018-02-25 09:10:07 +00:00
|
|
|
printf("Failed to write file\n");
|
|
|
|
printf("ERROR: %s\n", globalExporter->GetErrorString());
|
2015-07-02 11:07:50 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const clock_t second = ::clock();
|
|
|
|
const double seconds = static_cast<double>(second-first) / CLOCKS_PER_SEC;
|
|
|
|
|
|
|
|
printf("Exporting file ... OK \n export took approx. %.5f seconds\n"
|
|
|
|
"\n",seconds);
|
|
|
|
|
2021-07-29 11:28:51 +00:00
|
|
|
if (imp.log) {
|
2015-07-02 11:07:50 +00:00
|
|
|
FreeLogStreams();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
// Process standard arguments
|
|
|
|
int ProcessStandardArguments(
|
2021-07-29 11:28:51 +00:00
|
|
|
ImportData& fill,
|
2015-07-02 11:07:50 +00:00
|
|
|
const char* const * params,
|
|
|
|
unsigned int num)
|
|
|
|
{
|
|
|
|
// -ptv --pretransform-vertices
|
|
|
|
// -gsn --gen-smooth-normals
|
|
|
|
// -gn --gen-normals
|
|
|
|
// -cts --calc-tangent-space
|
|
|
|
// -jiv --join-identical-vertices
|
|
|
|
// -rrm --remove-redundant-materials
|
|
|
|
// -fd --find-degenerates
|
|
|
|
// -slm --split-large-meshes
|
|
|
|
// -lbw --limit-bone-weights
|
|
|
|
// -vds --validate-data-structure
|
|
|
|
// -icl --improve-cache-locality
|
|
|
|
// -sbpt --sort-by-ptype
|
|
|
|
// -lh --convert-to-lh
|
|
|
|
// -fuv --flip-uv
|
|
|
|
// -fwo --flip-winding-order
|
|
|
|
// -tuv --transform-uv-coords
|
|
|
|
// -guv --gen-uvcoords
|
|
|
|
// -fid --find-invalid-data
|
|
|
|
// -fixn --fix normals
|
|
|
|
// -tri --triangulate
|
|
|
|
// -fi --find-instances
|
|
|
|
// -og --optimize-graph
|
|
|
|
// -om --optimize-meshes
|
|
|
|
// -db --debone
|
|
|
|
// -sbc --split-by-bone-count
|
2019-08-12 18:17:07 +00:00
|
|
|
// -gs --global-scale
|
2015-07-02 11:07:50 +00:00
|
|
|
//
|
|
|
|
// -c<file> --config-file=<file>
|
|
|
|
|
2021-07-29 11:28:51 +00:00
|
|
|
for (unsigned int i = 0; i < num;++i)
|
2015-07-02 11:07:50 +00:00
|
|
|
{
|
2018-05-10 12:21:43 +00:00
|
|
|
const char *param = params[ i ];
|
|
|
|
printf( "param = %s\n", param );
|
|
|
|
if (! strcmp( param, "-ptv") || ! strcmp( param, "--pretransform-vertices")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_PreTransformVertices;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-gsn") || ! strcmp( param, "--gen-smooth-normals")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_GenSmoothNormals;
|
|
|
|
}
|
2018-10-29 15:23:11 +00:00
|
|
|
else if (! strcmp( param, "-dn") || ! strcmp( param, "--drop-normals")) {
|
|
|
|
fill.ppFlags |= aiProcess_DropNormals;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-gn") || ! strcmp( param, "--gen-normals")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_GenNormals;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-jiv") || ! strcmp( param, "--join-identical-vertices")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_JoinIdenticalVertices;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-rrm") || ! strcmp( param, "--remove-redundant-materials")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_RemoveRedundantMaterials;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-fd") || ! strcmp( param, "--find-degenerates")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_FindDegenerates;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-slm") || ! strcmp( param, "--split-large-meshes")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_SplitLargeMeshes;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-lbw") || ! strcmp( param, "--limit-bone-weights")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_LimitBoneWeights;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-vds") || ! strcmp( param, "--validate-data-structure")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_ValidateDataStructure;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-icl") || ! strcmp( param, "--improve-cache-locality")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_ImproveCacheLocality;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-sbpt") || ! strcmp( param, "--sort-by-ptype")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_SortByPType;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-lh") || ! strcmp( param, "--left-handed")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_ConvertToLeftHanded;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-fuv") || ! strcmp( param, "--flip-uv")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_FlipUVs;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-fwo") || ! strcmp( param, "--flip-winding-order")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_FlipWindingOrder;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-tuv") || ! strcmp( param, "--transform-uv-coords")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_TransformUVCoords;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-guv") || ! strcmp( param, "--gen-uvcoords")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_GenUVCoords;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-fid") || ! strcmp( param, "--find-invalid-data")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_FindInvalidData;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-fixn") || ! strcmp( param, "--fix-normals")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_FixInfacingNormals;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-tri") || ! strcmp( param, "--triangulate")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_Triangulate;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-cts") || ! strcmp( param, "--calc-tangent-space")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_CalcTangentSpace;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-fi") || ! strcmp( param, "--find-instances")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_FindInstances;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-og") || ! strcmp( param, "--optimize-graph")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_OptimizeGraph;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-om") || ! strcmp( param, "--optimize-meshes")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_OptimizeMeshes;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-db") || ! strcmp( param, "--debone")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_Debone;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-sbc") || ! strcmp( param, "--split-by-bone-count")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcess_SplitByBoneCount;
|
|
|
|
}
|
2018-09-21 17:35:54 +00:00
|
|
|
else if (!strcmp(param, "-embtex") || ! strcmp(param, "--embed-textures")) {
|
|
|
|
fill.ppFlags |= aiProcess_EmbedTextures;
|
|
|
|
}
|
2019-08-12 18:17:07 +00:00
|
|
|
else if (!strcmp(param, "-gs") || ! strcmp(param, "--global-scale")) {
|
|
|
|
fill.ppFlags |= aiProcess_GlobalScale;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strncmp( param, "-c",2) || ! strncmp( param, "--config=",9)) {
|
2015-07-02 11:07:50 +00:00
|
|
|
const unsigned int ofs = (params[i][1] == '-' ? 9 : 2);
|
|
|
|
|
|
|
|
// use default configurations
|
2018-05-10 12:21:43 +00:00
|
|
|
if (!strncmp( param + ofs, "full", 4 )) {
|
|
|
|
fill.ppFlags |= aiProcessPreset_TargetRealtime_MaxQuality;
|
|
|
|
} else if (!strncmp( param + ofs, "default", 7 )) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcessPreset_TargetRealtime_Quality;
|
2018-05-10 12:21:43 +00:00
|
|
|
} else if (! strncmp( param +ofs,"fast",4)) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.ppFlags |= aiProcessPreset_TargetRealtime_Fast;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
} else if (! strcmp( param, "-l") || ! strcmp( param, "--show-log")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.showLog = true;
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strcmp( param, "-v") || ! strcmp( param, "--verbose")) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.verbose = true;
|
|
|
|
}
|
2021-03-10 09:06:42 +00:00
|
|
|
else if (!strncmp(params[i], "-rx=", 4) || !strncmp(params[i], "--rotation-x=", 13)) {
|
|
|
|
std::string value = std::string(params[i] + (params[i][1] == '-' ? 13 : 4));
|
|
|
|
fill.rot.x = std::stof(value);
|
2021-07-29 11:28:51 +00:00
|
|
|
}
|
2021-03-10 09:06:42 +00:00
|
|
|
else if (!strncmp(params[i], "-ry=", 4) || !strncmp(params[i], "--rotation-y=", 13)) {
|
|
|
|
std::string value = std::string(params[i] + (params[i][1] == '-' ? 13 : 4));
|
|
|
|
fill.rot.y = std::stof(value);
|
2021-07-29 11:28:51 +00:00
|
|
|
}
|
2021-03-10 09:06:42 +00:00
|
|
|
else if (!strncmp(params[i], "-rz=", 4) || !strncmp(params[i], "--rotation-z=", 13)) {
|
|
|
|
std::string value = std::string(params[i] + (params[i][1] == '-' ? 13 : 4));
|
|
|
|
fill.rot.z = std::stof(value);
|
|
|
|
}
|
2018-05-10 12:21:43 +00:00
|
|
|
else if (! strncmp( param, "--log-out=",10) || ! strncmp( param, "-lo",3)) {
|
2015-07-02 11:07:50 +00:00
|
|
|
fill.logFile = std::string(params[i]+(params[i][1] == '-' ? 10 : 3));
|
|
|
|
if (!fill.logFile.length()) {
|
|
|
|
fill.logFile = "assimp-log.txt";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fill.logFile.length() || fill.showLog || fill.verbose) {
|
|
|
|
fill.log = true;
|
|
|
|
}
|
|
|
|
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
2022-09-16 19:55:14 +00:00
|
|
|
int Assimp_TestBatchLoad(const char* const* params, unsigned int num) {
|
2015-07-02 11:07:50 +00:00
|
|
|
for(unsigned int i = 0; i < num; ++i) {
|
|
|
|
globalImporter->ReadFile(params[i],aiProcessPreset_TargetRealtime_MaxQuality);
|
|
|
|
// we're totally silent. scene destructs automatically.
|
|
|
|
}
|
2020-01-26 18:10:21 +00:00
|
|
|
return AssimpCmdError::Success;
|
2015-07-02 11:07:50 +00:00
|
|
|
}
|