- assimp_cmd: add Debone & SplitByBoneCount to thee list of supported pp steps.
- assimp_cmd: fix code formatting # duplicate some code from ProcessHelper.h, which was previously accessible but no isn't anymore due to recent refactoring in assimp's core. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@948 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
d2a1a3f2c0
commit
2b4126a7e3
|
@ -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 <model> [<out>] [-t<n>] [-f<fmt>] [-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));
|
||||
}
|
||||
|
|
|
@ -381,16 +381,13 @@ int ProcessStandardArguments(
|
|||
// -fi --find-instances
|
||||
// -og --optimize-graph
|
||||
// -om --optimize-meshes
|
||||
// -db --debone
|
||||
// -sbc --split-by-bone-count
|
||||
//
|
||||
// -c<file> --config-file=<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;
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -175,7 +175,7 @@ template <typename T>
|
|||
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</Node>\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)
|
||||
|
|
Loading…
Reference in New Issue