Merge branch 'master' into hl1-mdl-fix-texture-format
commit
2c430bc82a
|
@ -885,19 +885,19 @@ int Assimp_CompareDump (const char* const* params, unsigned int num)
|
|||
// --help
|
||||
if ((num == 1 && !strcmp( params[0], "-h")) || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) {
|
||||
printf("%s",AICMD_MSG_CMPDUMP_HELP);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// assimp cmpdump actual expected
|
||||
if (num < 2) {
|
||||
std::cout << "assimp cmpdump: Invalid number of arguments. "
|
||||
"See \'assimp cmpdump --help\'\r\n" << std::endl;
|
||||
return 1;
|
||||
return AssimpCmdError::InvalidNumberOfArguments;
|
||||
}
|
||||
|
||||
if(!strcmp(params[0],params[1])) {
|
||||
std::cout << "assimp cmpdump: same file, same content." << std::endl;
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
class file_ptr
|
||||
|
@ -924,13 +924,13 @@ int Assimp_CompareDump (const char* const* params, unsigned int num)
|
|||
if (!actual) {
|
||||
std::cout << "assimp cmpdump: Failure reading ACTUAL data from " <<
|
||||
params[0] << std::endl;
|
||||
return -5;
|
||||
return AssimpCmdError::FailedToLoadInputFile;
|
||||
}
|
||||
file_ptr expected(fopen(params[1],"rb"));
|
||||
if (!expected) {
|
||||
std::cout << "assimp cmpdump: Failure reading EXPECT data from " <<
|
||||
params[1] << std::endl;
|
||||
return -6;
|
||||
return AssimpCmdCompareDumpError::FailedToLoadExpectedInputFile;
|
||||
}
|
||||
|
||||
comparer_context comp(actual,expected);
|
||||
|
@ -940,17 +940,17 @@ int Assimp_CompareDump (const char* const* params, unsigned int num)
|
|||
}
|
||||
catch(const compare_fails_exception& ex) {
|
||||
printf("%s",ex.what());
|
||||
return -1;
|
||||
return AssimpCmdCompareDumpError::FileComparaisonFailure;
|
||||
}
|
||||
catch(...) {
|
||||
// we don't bother checking too rigourously here, so
|
||||
// we might end up here ...
|
||||
std::cout << "Unknown failure, are the input files well-defined?";
|
||||
return -3;
|
||||
return AssimpCmdCompareDumpError::UnknownFailure;
|
||||
}
|
||||
|
||||
std::cout << "Success (totally " << std::dec << comp.get_num_chunks() <<
|
||||
" chunks)" << std::endl;
|
||||
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
|
|
@ -76,13 +76,13 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
const char* const invalid = "assimp export: Invalid number of arguments. See \'assimp export --help\'\n";
|
||||
if (num < 1) {
|
||||
printf(invalid);
|
||||
return 1;
|
||||
return AssimpCmdError::InvalidNumberOfArguments;
|
||||
}
|
||||
|
||||
// --help
|
||||
if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) {
|
||||
printf("%s",AICMD_MSG_EXPORT_HELP_E);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
std::string in = std::string(params[0]);
|
||||
|
@ -156,7 +156,7 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
// import the model
|
||||
const aiScene* scene = ImportModel(import,in);
|
||||
if (!scene) {
|
||||
return -39;
|
||||
return AssimpCmdExportError::FailedToImportModel;
|
||||
}
|
||||
|
||||
// derive the final file name
|
||||
|
@ -164,10 +164,10 @@ int Assimp_Export(const char* const* params, unsigned int num)
|
|||
|
||||
// and call the export routine
|
||||
if(!ExportModel(scene, import, out,e->id)) {
|
||||
return -25;
|
||||
return AssimpCmdExportError::FailedToExportModel;
|
||||
}
|
||||
printf("assimp export: wrote output file: %s\n",out.c_str());
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
#endif // no export
|
||||
|
|
|
@ -219,9 +219,9 @@ int DoExport(const aiTexture* tx, FILE* p, const std::string& extension,
|
|||
}
|
||||
else {
|
||||
printf("assimp extract: No available texture encoder found for %s\n", extension.c_str());
|
||||
return 1;
|
||||
return AssimpCmdExtractError::NoAvailableTextureEncoderFound;
|
||||
}
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
@ -232,13 +232,13 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
// assimp extract in out [options]
|
||||
if (num < 1) {
|
||||
printf(invalid);
|
||||
return 1;
|
||||
return AssimpCmdError::InvalidNumberOfArguments;
|
||||
}
|
||||
|
||||
// --help
|
||||
if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) {
|
||||
printf("%s",AICMD_MSG_DUMP_HELP_E);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,7 +308,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
const aiScene* scene = ImportModel(import,in);
|
||||
if (!scene) {
|
||||
printf("assimp extract: Unable to load input file %s\n",in.c_str());
|
||||
return 5;
|
||||
return AssimpCmdError::FailedToLoadInputFile;
|
||||
}
|
||||
|
||||
// get the texture(s) to be exported
|
||||
|
@ -318,7 +318,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
if (texIdx >= scene->mNumTextures) {
|
||||
::printf("assimp extract: Texture %i requested, but there are just %i textures\n",
|
||||
texIdx, scene->mNumTextures);
|
||||
return 6;
|
||||
return AssimpCmdExtractError::TextureIndexIsOutOfRange;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -358,12 +358,14 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
FILE* p = ::fopen(out_cpy.c_str(),"wb");
|
||||
if (!p) {
|
||||
printf("assimp extract: Unable to open output file %s\n",out_cpy.c_str());
|
||||
return 7;
|
||||
return AssimpCmdError::FailedToOpenOutputFile;
|
||||
}
|
||||
int m;
|
||||
|
||||
if (!tex->mHeight) {
|
||||
m = (1 != fwrite(tex->pcData,tex->mWidth,1,p));
|
||||
m = (1 != fwrite(tex->pcData,tex->mWidth,1,p))
|
||||
? static_cast<int>(AssimpCmdError::Success)
|
||||
: static_cast<int>(AssimpCmdExtractError::FailedToExportCompressedTexture);
|
||||
}
|
||||
else m = DoExport(tex,p,extension,flags);
|
||||
::fclose(p);
|
||||
|
@ -372,5 +374,5 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
|||
if (texIdx != 0xffffffff)
|
||||
return m;
|
||||
}
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
|
|
@ -283,14 +283,14 @@ int Assimp_Info (const char* const* params, unsigned int num) {
|
|||
// --help
|
||||
if (!strcmp( params[0],"-h")||!strcmp( params[0],"--help")||!strcmp( params[0],"-?") ) {
|
||||
printf("%s",AICMD_MSG_INFO_HELP_E);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// asssimp info <file> [-r]
|
||||
if (num < 1) {
|
||||
printf("assimp info: Invalid number of arguments. "
|
||||
"See \'assimp info --help\'\n");
|
||||
return 1;
|
||||
return AssimpCmdError::InvalidNumberOfArguments;
|
||||
}
|
||||
|
||||
const std::string in = std::string(params[0]);
|
||||
|
@ -314,7 +314,7 @@ int Assimp_Info (const char* const* params, unsigned int num) {
|
|||
// Verbose and silent at the same time are not allowed
|
||||
if ( verbose && silent ) {
|
||||
printf("assimp info: Invalid arguments, verbose and silent at the same time are forbitten. ");
|
||||
return 1;
|
||||
return AssimpCmdInfoError::InvalidCombinaisonOfArguments;
|
||||
}
|
||||
|
||||
// Parse post-processing flags unless -r was specified
|
||||
|
@ -333,7 +333,7 @@ int Assimp_Info (const char* const* params, unsigned int num) {
|
|||
if (!scene) {
|
||||
printf("assimp info: Unable to load input file %s\n",
|
||||
in.c_str());
|
||||
return 5;
|
||||
return AssimpCmdError::FailedToLoadInputFile;
|
||||
}
|
||||
|
||||
aiMemoryInfo mem;
|
||||
|
@ -391,7 +391,7 @@ int Assimp_Info (const char* const* params, unsigned int num) {
|
|||
if (silent)
|
||||
{
|
||||
printf("\n");
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// meshes
|
||||
|
@ -473,5 +473,5 @@ int Assimp_Info (const char* const* params, unsigned int num) {
|
|||
PrintHierarchy(scene->mRootNode,"",verbose);
|
||||
|
||||
printf("\n");
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ int main (int argc, char* argv[])
|
|||
{
|
||||
if (argc <= 1) {
|
||||
printf("assimp: No command specified. Use \'assimp help\' for a detailed command list\n");
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// assimp version
|
||||
|
@ -102,7 +102,7 @@ int main (int argc, char* argv[])
|
|||
(flags & ASSIMP_CFLAGS_STLPORT ? "-stlport " : ""),
|
||||
aiGetVersionRevision());
|
||||
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// assimp help
|
||||
|
@ -110,7 +110,7 @@ int main (int argc, char* argv[])
|
|||
// because people could try them intuitively)
|
||||
if (!strcmp(argv[1], "help") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
|
||||
printf("%s",AICMD_MSG_HELP);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// assimp cmpdump
|
||||
|
@ -137,7 +137,7 @@ int main (int argc, char* argv[])
|
|||
imp.GetExtensionList(s);
|
||||
|
||||
printf("%s\n",s.data);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
|
@ -155,7 +155,7 @@ int main (int argc, char* argv[])
|
|||
}
|
||||
|
||||
printf("%s\n",s.data);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,19 +166,19 @@ int main (int argc, char* argv[])
|
|||
|
||||
if (argc<3) {
|
||||
printf("Expected file format id\n");
|
||||
return -11;
|
||||
return AssimpCmdError::NoFileFormatSpecified;
|
||||
}
|
||||
|
||||
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);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Unknown file format id: \'%s\'\n",argv[2]);
|
||||
return -12;
|
||||
return AssimpCmdError::UnknownFileFormat;
|
||||
}
|
||||
|
||||
// assimp export
|
||||
|
@ -194,11 +194,11 @@ int main (int argc, char* argv[])
|
|||
if (! strcmp(argv[1], "knowext")) {
|
||||
if (argc<3) {
|
||||
printf("Expected file extension");
|
||||
return -10;
|
||||
return AssimpCmdError::NoFileExtensionSpecified;
|
||||
}
|
||||
const bool b = imp.IsExtensionSupported(argv[2]);
|
||||
printf("File extension \'%s\' is %sknown\n",argv[2],(b?"":"not "));
|
||||
return b?0:-1;
|
||||
return b? AssimpCmdError::Success : AssimpCmdError::UnknownFileExtension;
|
||||
}
|
||||
|
||||
// assimp info
|
||||
|
@ -228,7 +228,7 @@ int main (int argc, char* argv[])
|
|||
}
|
||||
|
||||
printf("Unrecognized command. Use \'assimp help\' for a detailed command list\n");
|
||||
return 1;
|
||||
return AssimpCmdError::UnrecognizedCommand;
|
||||
}
|
||||
|
||||
|
||||
|
@ -505,7 +505,7 @@ int ProcessStandardArguments(
|
|||
fill.log = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
@ -517,5 +517,5 @@ int Assimp_TestBatchLoad (
|
|||
globalImporter->ReadFile(params[i],aiProcessPreset_TargetRealtime_MaxQuality);
|
||||
// we're totally silent. scene destructs automatically.
|
||||
}
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
|
|
@ -114,13 +114,31 @@ struct ImportData {
|
|||
bool log;
|
||||
};
|
||||
|
||||
/// \enum AssimpCmdError
|
||||
/// \brief General error codes used among assimp_cmd's utilities.
|
||||
enum AssimpCmdError {
|
||||
Success = 0,
|
||||
InvalidNumberOfArguments,
|
||||
UnrecognizedCommand,
|
||||
FailedToLoadInputFile,
|
||||
FailedToOpenOutputFile,
|
||||
NoFileFormatSpecified,
|
||||
UnknownFileFormat,
|
||||
NoFileExtensionSpecified,
|
||||
UnknownFileExtension,
|
||||
|
||||
// Add new error codes here...
|
||||
|
||||
LastAssimpCmdError, // Must be last.
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** Process standard arguments
|
||||
*
|
||||
* @param fill Filled by function
|
||||
* @param params Command line parameters to be processed
|
||||
* @param num NUmber of params
|
||||
* @return 0 for success */
|
||||
* @return An #AssimpCmdError value. */
|
||||
int ProcessStandardArguments(ImportData& fill,
|
||||
const char* const* params,
|
||||
unsigned int num);
|
||||
|
@ -151,43 +169,88 @@ bool ExportModel(const aiScene* pOut,
|
|||
/** assimp_dump utility
|
||||
* @param params Command line parameters to 'assimp dumb'
|
||||
* @param Number of params
|
||||
* @return 0 for success*/
|
||||
* @return An #AssimpCmdError value.*/
|
||||
int Assimp_Dump (
|
||||
const char* const* params,
|
||||
unsigned int num);
|
||||
|
||||
/// \enum AssimpCmdExportError
|
||||
/// \brief Error codes used by the 'Export' utility.
|
||||
enum AssimpCmdExportError {
|
||||
FailedToImportModel = AssimpCmdError::LastAssimpCmdError,
|
||||
FailedToExportModel,
|
||||
|
||||
// Add new error codes here...
|
||||
|
||||
LastAssimpCmdExportError, // Must be last.
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** assimp_export utility
|
||||
* @param params Command line parameters to 'assimp export'
|
||||
* @param Number of params
|
||||
* @return 0 for success*/
|
||||
* @return Either an #AssimpCmdError or #AssimpCmdExportError value. */
|
||||
int Assimp_Export (
|
||||
const char* const* params,
|
||||
unsigned int num);
|
||||
|
||||
/// \enum AssimpCmdExtractError
|
||||
/// \brief Error codes used by the 'Image Extractor' utility.
|
||||
enum AssimpCmdExtractError {
|
||||
TextureIndexIsOutOfRange = AssimpCmdError::LastAssimpCmdError,
|
||||
NoAvailableTextureEncoderFound,
|
||||
FailedToExportCompressedTexture,
|
||||
|
||||
// Add new error codes here...
|
||||
|
||||
LastAssimpCmdExtractError, // Must be last.
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** assimp_extract utility
|
||||
* @param params Command line parameters to 'assimp extract'
|
||||
* @param Number of params
|
||||
* @return 0 for success*/
|
||||
* @return Either an #AssimpCmdError or #AssimpCmdExtractError value. */
|
||||
int Assimp_Extract (
|
||||
const char* const* params,
|
||||
unsigned int num);
|
||||
|
||||
/// \enum AssimpCmdCompareDumpError
|
||||
/// \brief Error codes used by the 'Compare Dump' utility.
|
||||
enum AssimpCmdCompareDumpError {
|
||||
FailedToLoadExpectedInputFile = AssimpCmdError::LastAssimpCmdError,
|
||||
FileComparaisonFailure,
|
||||
UnknownFailure,
|
||||
|
||||
// Add new error codes here...
|
||||
|
||||
LastAssimpCmdCompareDumpError, // Must be last.
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** assimp_cmpdump utility
|
||||
* @param params Command line parameters to 'assimp cmpdump'
|
||||
* @param Number of params
|
||||
* @return 0 for success*/
|
||||
* @return Either an #AssimpCmdError or #AssimpCmdCompareDumpError. */
|
||||
int Assimp_CompareDump (
|
||||
const char* const* params,
|
||||
unsigned int num);
|
||||
|
||||
/// \enum AssimpCmdInfoError
|
||||
/// \brief Error codes used by the 'Info' utility.
|
||||
enum AssimpCmdInfoError {
|
||||
InvalidCombinaisonOfArguments = AssimpCmdError::LastAssimpCmdError,
|
||||
|
||||
// Add new error codes here...
|
||||
|
||||
LastAssimpCmdInfoError, // Must be last.
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** @brief assimp info utility
|
||||
* @param params Command line parameters to 'assimp info'
|
||||
* @param Number of params
|
||||
* @return 0 for success */
|
||||
* @return Either an #AssimpCmdError or #AssimpCmdInfoError value. */
|
||||
int Assimp_Info (
|
||||
const char* const* params,
|
||||
unsigned int num);
|
||||
|
@ -196,7 +259,7 @@ int Assimp_Info (
|
|||
/** @brief assimp testbatchload utility
|
||||
* @param params Command line parameters to 'assimp testbatchload'
|
||||
* @param Number of params
|
||||
* @return 0 for success */
|
||||
* @return An #AssimpCmdError value. */
|
||||
int Assimp_TestBatchLoad (
|
||||
const char* const* params,
|
||||
unsigned int num);
|
||||
|
|
|
@ -1341,13 +1341,13 @@ int Assimp_Dump (const char* const* params, unsigned int num)
|
|||
// --help
|
||||
if (!strcmp( params[0], "-h") || !strcmp( params[0], "--help") || !strcmp( params[0], "-?") ) {
|
||||
printf("%s",AICMD_MSG_DUMP_HELP);
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
// asssimp dump in out [options]
|
||||
if (num < 1) {
|
||||
printf("%s", fail);
|
||||
return 1;
|
||||
return AssimpCmdError::InvalidNumberOfArguments;
|
||||
}
|
||||
|
||||
std::string in = std::string(params[0]);
|
||||
|
@ -1405,14 +1405,14 @@ int Assimp_Dump (const char* const* params, unsigned int num)
|
|||
const aiScene* scene = ImportModel(import,in);
|
||||
if (!scene) {
|
||||
printf("assimp dump: Unable to load input file %s\n",in.c_str());
|
||||
return 5;
|
||||
return AssimpCmdError::FailedToLoadInputFile;
|
||||
}
|
||||
|
||||
// open the output file and build the dump
|
||||
FILE* o = ::fopen(out.c_str(),(binary ? "wb" : "wt"));
|
||||
if (!o) {
|
||||
printf("assimp dump: Unable to open output file %s\n",out.c_str());
|
||||
return 12;
|
||||
return AssimpCmdError::FailedToOpenOutputFile;
|
||||
}
|
||||
|
||||
if (binary) {
|
||||
|
@ -1426,6 +1426,6 @@ int Assimp_Dump (const char* const* params, unsigned int num)
|
|||
}
|
||||
|
||||
printf("assimp dump: Wrote output dump %s\n",out.c_str());
|
||||
return 0;
|
||||
return AssimpCmdError::Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue