diff --git a/tools/assimp_cmd/ImageExtractor.cpp b/tools/assimp_cmd/ImageExtractor.cpp index 47efccef2..c779d3ba2 100644 --- a/tools/assimp_cmd/ImageExtractor.cpp +++ b/tools/assimp_cmd/ImageExtractor.cpp @@ -44,6 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "Main.h" +#include <../code/fast_atof.h> +#include <../code/StringComparison.h> const char* AICMD_MSG_DUMP_HELP_E = "assimp extract [] [-t] [-f] [-ba] [-s] [common parameters]\n" @@ -118,7 +120,9 @@ struct TGA_HEADER // Save a texture as bitmap int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int height, bool SaveAlpha = false) { - if (!file || !data)return 1; + if (!file || !data) { + return 1; + } const unsigned int numc = (SaveAlpha ? 4 : 3); unsigned char* buffer = new unsigned char[width*height*numc]; @@ -175,8 +179,9 @@ int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int // Save a texture as tga int SaveAsTGA (FILE* file, const aiTexel* data, unsigned int width, unsigned int height) { - if (!file || !data)return 1; - + if (!file || !data) { + return 1; + } TGA_HEADER head = {0}; head.bits = 32; @@ -220,8 +225,9 @@ int DoExport(const aiTexture* tx, FILE* p, const std::string& extension, // Implementation of the assimp extract utility int Assimp_Extract (const char* const* params, unsigned int num) { + const char* const invalid = "assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n"; if (num < 1) { - printf("assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n"); + printf(invalid); return 1; } @@ -233,7 +239,7 @@ int Assimp_Extract (const char* const* params, unsigned int num) // asssimp extract in out [options] if (num < 1) { - printf("assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n"); + printf(invalid); return 1; } @@ -250,7 +256,9 @@ int Assimp_Extract (const char* const* params, unsigned int num) // process other flags std::string extension = "bmp"; for (unsigned int i = (out[0] == '-' ? 1 : 2); i < num;++i) { - if (!params[i])continue; + if (!params[i]) { + continue; + } if (!strncmp( params[i], "-f",2)) { extension = std::string(params[i]+2); @@ -262,10 +270,10 @@ int Assimp_Extract (const char* const* params, unsigned int num) nosuffix = true; } else if ( !strncmp( params[i], "--texture=",10)) { - texIdx = ::strtol10(params[i]+10); + texIdx = Assimp::strtoul10(params[i]+10); } else if ( !strncmp( params[i], "-t",2)) { - texIdx = ::strtol10(params[i]+2); + texIdx = Assimp::strtoul10(params[i]+2); } else if ( !strcmp( params[i], "-ba") || !strcmp( params[i], "--bmp-with-alpha")) { flags |= AI_EXTRACT_WRITE_BMP_ALPHA; @@ -277,9 +285,9 @@ int Assimp_Extract (const char* const* params, unsigned int num) } #endif } - for (std::string::iterator it = extension.begin();it != extension.end();++it) - *it = ::tolower(*it); + std::transform(extension.begin(),extension.end(),extension.begin(),::tolower); + if (out[0] == '-') { // take file name from input file std::string::size_type s = in.find_last_of('.'); @@ -330,7 +338,7 @@ int Assimp_Extract (const char* const* params, unsigned int num) if (!nosuffix || (texIdx == 0xffffffff)) { out_cpy.append ("_img"); char tmp[10]; - ASSIMP_itoa10(tmp,i); + Assimp::ASSIMP_itoa10(tmp,i); out_cpy.append(std::string(tmp)); } diff --git a/tools/assimp_cmd/Main.cpp b/tools/assimp_cmd/Main.cpp index ebc262041..7d014a5d5 100644 --- a/tools/assimp_cmd/Main.cpp +++ b/tools/assimp_cmd/Main.cpp @@ -381,16 +381,13 @@ int ProcessStandardArguments( // -fi --find-instances // -og --optimize-graph // -om --optimize-meshes + // -db --debone + // -sbc --split-by-bone-count // // -c --config-file= for (unsigned int i = 0; i < num;++i) { - //if (!params[i]) { // could happen if some args have already been processed - // continue; - //} - - // bool has = true; if (! strcmp(params[i], "-ptv") || ! strcmp(params[i], "--pretransform-vertices")) { fill.ppFlags |= aiProcess_PreTransformVertices; } @@ -460,32 +457,28 @@ int ProcessStandardArguments( else if (! strcmp(params[i], "-om") || ! strcmp(params[i], "--optimize-meshes")) { fill.ppFlags |= aiProcess_OptimizeMeshes; } + else if (! strcmp(params[i], "-db") || ! strcmp(params[i], "--debone")) { + fill.ppFlags |= aiProcess_Debone; + } + else if (! strcmp(params[i], "-sbc") || ! strcmp(params[i], "--split-by-bone-count")) { + fill.ppFlags |= aiProcess_SplitByBoneCount; + } -#if 0 - else if (! strcmp(params[i], "-oa") || ! strcmp(params[i], "--optimize-anims")) { - fill.ppFlags |= aiProcess_OptimizeAnims; - } - else if (! strcmp(params[i], "-gem") || ! strcmp(params[i], "--gen-entity-meshes")) { - fill.ppFlags |= aiProcess_GenEntityMeshes; - } - else if (! strcmp(params[i], "-ftp") || ! strcmp(params[i], "--fix-texture-paths")) { - fill.ppFlags |= aiProcess_FixTexturePaths; - } -#endif else if (! strncmp(params[i], "-c",2) || ! strncmp(params[i], "--config=",9)) { const unsigned int ofs = (params[i][1] == '-' ? 9 : 2); // use default configurations - if (! strncmp(params[i]+ofs,"full",4)) + if (! strncmp(params[i]+ofs,"full",4)) { fill.ppFlags |= aiProcessPreset_TargetRealtime_MaxQuality; - - else if (! strncmp(params[i]+ofs,"default",7)) + } + else if (! strncmp(params[i]+ofs,"default",7)) { fill.ppFlags |= aiProcessPreset_TargetRealtime_Quality; - - else if (! strncmp(params[i]+ofs,"fast",4)) + } + else if (! strncmp(params[i]+ofs,"fast",4)) { fill.ppFlags |= aiProcessPreset_TargetRealtime_Fast; + } } else if (! strcmp(params[i], "-l") || ! strcmp(params[i], "--show-log")) { fill.showLog = true; @@ -495,18 +488,15 @@ int ProcessStandardArguments( } else if (! strncmp(params[i], "--log-out=",10) || ! strncmp(params[i], "-lo",3)) { fill.logFile = std::string(params[i]+(params[i][1] == '-' ? 10 : 3)); - if (!fill.logFile.length()) + if (!fill.logFile.length()) { fill.logFile = "assimp-log.txt"; + } } - - //else has = false; - //if (has) { - // params[i] = NULL; - //} } - if (fill.logFile.length() || fill.showLog || fill.verbose) + if (fill.logFile.length() || fill.showLog || fill.verbose) { fill.log = true; + } return 0; } diff --git a/tools/assimp_cmd/Main.h b/tools/assimp_cmd/Main.h index 1cf246a3e..a303bf768 100644 --- a/tools/assimp_cmd/Main.h +++ b/tools/assimp_cmd/Main.h @@ -64,10 +64,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif #include <../code/AssimpPCH.h> /* to get stdint.h */ -#include <../code/fast_atof.h> -#include <../code/StringComparison.h> -#include <../code/Hash.h> - #include <../contrib/zlib/zlib.h> #ifndef SIZE_MAX @@ -203,4 +199,4 @@ int Assimp_TestBatchLoad ( unsigned int num); -#endif // !! AICMD_MAIN_INCLUDED +#endif // !! AICMD_MAIN_INCLUDED \ No newline at end of file diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index 8123ee947..5cd78627f 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -175,7 +175,7 @@ template inline uint32_t WriteBounds(const T* in, unsigned int size) { T minc,maxc; - ArrayBounds(in,size,minc,maxc); + Assimp::ArrayBounds(in,size,minc,maxc); fwrite(&minc,sizeof(T),1,out); fwrite(&maxc,sizeof(T),1,out); return sizeof(T)*2; @@ -692,6 +692,44 @@ void WriteNode(const aiNode* node, FILE* out, unsigned int depth) fprintf(out,"%s\n",prefix); } + +// ------------------------------------------------------------------------------- +const char* TextureTypeToString(aiTextureType in) +{ + switch (in) + { + case aiTextureType_NONE: + return "n/a"; + case aiTextureType_DIFFUSE: + return "Diffuse"; + case aiTextureType_SPECULAR: + return "Specular"; + case aiTextureType_AMBIENT: + return "Ambient"; + case aiTextureType_EMISSIVE: + return "Emissive"; + case aiTextureType_OPACITY: + return "Opacity"; + case aiTextureType_NORMALS: + return "Normals"; + case aiTextureType_HEIGHT: + return "Height"; + case aiTextureType_SHININESS: + return "Shininess"; + case aiTextureType_DISPLACEMENT: + return "Displacement"; + case aiTextureType_LIGHTMAP: + return "Lightmap"; + case aiTextureType_REFLECTION: + return "Reflection"; + case aiTextureType_UNKNOWN: + return "Unknown"; + } + ai_assert(false); + return "BUG"; +} + + // ----------------------------------------------------------------------------------- // Write a text model dump void WriteDump(const aiScene* scene, FILE* out, const char* src, const char* cmd, bool shortened)