- 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 "Main.h"
|
||||||
|
#include <../code/fast_atof.h>
|
||||||
|
#include <../code/StringComparison.h>
|
||||||
|
|
||||||
const char* AICMD_MSG_DUMP_HELP_E =
|
const char* AICMD_MSG_DUMP_HELP_E =
|
||||||
"assimp extract <model> [<out>] [-t<n>] [-f<fmt>] [-ba] [-s] [common parameters]\n"
|
"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
|
// Save a texture as bitmap
|
||||||
int SaveAsBMP (FILE* file, const aiTexel* data, unsigned int width, unsigned int height, bool SaveAlpha = false)
|
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);
|
const unsigned int numc = (SaveAlpha ? 4 : 3);
|
||||||
unsigned char* buffer = new unsigned char[width*height*numc];
|
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
|
// Save a texture as tga
|
||||||
int SaveAsTGA (FILE* file, const aiTexel* data, unsigned int width, unsigned int height)
|
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};
|
TGA_HEADER head = {0};
|
||||||
head.bits = 32;
|
head.bits = 32;
|
||||||
|
@ -220,8 +225,9 @@ int DoExport(const aiTexture* tx, FILE* p, const std::string& extension,
|
||||||
// Implementation of the assimp extract utility
|
// Implementation of the assimp extract utility
|
||||||
int Assimp_Extract (const char* const* params, unsigned int num)
|
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) {
|
if (num < 1) {
|
||||||
printf("assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n");
|
printf(invalid);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +239,7 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
||||||
|
|
||||||
// asssimp extract in out [options]
|
// asssimp extract in out [options]
|
||||||
if (num < 1) {
|
if (num < 1) {
|
||||||
printf("assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n");
|
printf(invalid);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +256,9 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
||||||
// process other flags
|
// process other flags
|
||||||
std::string extension = "bmp";
|
std::string extension = "bmp";
|
||||||
for (unsigned int i = (out[0] == '-' ? 1 : 2); i < num;++i) {
|
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)) {
|
if (!strncmp( params[i], "-f",2)) {
|
||||||
extension = std::string(params[i]+2);
|
extension = std::string(params[i]+2);
|
||||||
|
@ -262,10 +270,10 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
||||||
nosuffix = true;
|
nosuffix = true;
|
||||||
}
|
}
|
||||||
else if ( !strncmp( params[i], "--texture=",10)) {
|
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)) {
|
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")) {
|
else if ( !strcmp( params[i], "-ba") || !strcmp( params[i], "--bmp-with-alpha")) {
|
||||||
flags |= AI_EXTRACT_WRITE_BMP_ALPHA;
|
flags |= AI_EXTRACT_WRITE_BMP_ALPHA;
|
||||||
|
@ -277,9 +285,9 @@ int Assimp_Extract (const char* const* params, unsigned int num)
|
||||||
}
|
}
|
||||||
#endif
|
#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] == '-') {
|
if (out[0] == '-') {
|
||||||
// take file name from input file
|
// take file name from input file
|
||||||
std::string::size_type s = in.find_last_of('.');
|
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)) {
|
if (!nosuffix || (texIdx == 0xffffffff)) {
|
||||||
out_cpy.append ("_img");
|
out_cpy.append ("_img");
|
||||||
char tmp[10];
|
char tmp[10];
|
||||||
ASSIMP_itoa10(tmp,i);
|
Assimp::ASSIMP_itoa10(tmp,i);
|
||||||
|
|
||||||
out_cpy.append(std::string(tmp));
|
out_cpy.append(std::string(tmp));
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,16 +381,13 @@ int ProcessStandardArguments(
|
||||||
// -fi --find-instances
|
// -fi --find-instances
|
||||||
// -og --optimize-graph
|
// -og --optimize-graph
|
||||||
// -om --optimize-meshes
|
// -om --optimize-meshes
|
||||||
|
// -db --debone
|
||||||
|
// -sbc --split-by-bone-count
|
||||||
//
|
//
|
||||||
// -c<file> --config-file=<file>
|
// -c<file> --config-file=<file>
|
||||||
|
|
||||||
for (unsigned int i = 0; i < num;++i)
|
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")) {
|
if (! strcmp(params[i], "-ptv") || ! strcmp(params[i], "--pretransform-vertices")) {
|
||||||
fill.ppFlags |= aiProcess_PreTransformVertices;
|
fill.ppFlags |= aiProcess_PreTransformVertices;
|
||||||
}
|
}
|
||||||
|
@ -460,32 +457,28 @@ int ProcessStandardArguments(
|
||||||
else if (! strcmp(params[i], "-om") || ! strcmp(params[i], "--optimize-meshes")) {
|
else if (! strcmp(params[i], "-om") || ! strcmp(params[i], "--optimize-meshes")) {
|
||||||
fill.ppFlags |= aiProcess_OptimizeMeshes;
|
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)) {
|
else if (! strncmp(params[i], "-c",2) || ! strncmp(params[i], "--config=",9)) {
|
||||||
|
|
||||||
const unsigned int ofs = (params[i][1] == '-' ? 9 : 2);
|
const unsigned int ofs = (params[i][1] == '-' ? 9 : 2);
|
||||||
|
|
||||||
// use default configurations
|
// use default configurations
|
||||||
if (! strncmp(params[i]+ofs,"full",4))
|
if (! strncmp(params[i]+ofs,"full",4)) {
|
||||||
fill.ppFlags |= aiProcessPreset_TargetRealtime_MaxQuality;
|
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;
|
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;
|
fill.ppFlags |= aiProcessPreset_TargetRealtime_Fast;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (! strcmp(params[i], "-l") || ! strcmp(params[i], "--show-log")) {
|
else if (! strcmp(params[i], "-l") || ! strcmp(params[i], "--show-log")) {
|
||||||
fill.showLog = true;
|
fill.showLog = true;
|
||||||
|
@ -495,18 +488,15 @@ int ProcessStandardArguments(
|
||||||
}
|
}
|
||||||
else if (! strncmp(params[i], "--log-out=",10) || ! strncmp(params[i], "-lo",3)) {
|
else if (! strncmp(params[i], "--log-out=",10) || ! strncmp(params[i], "-lo",3)) {
|
||||||
fill.logFile = std::string(params[i]+(params[i][1] == '-' ? 10 : 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";
|
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;
|
fill.log = true;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <../code/AssimpPCH.h> /* to get stdint.h */
|
#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>
|
#include <../contrib/zlib/zlib.h>
|
||||||
|
|
||||||
#ifndef SIZE_MAX
|
#ifndef SIZE_MAX
|
||||||
|
@ -203,4 +199,4 @@ int Assimp_TestBatchLoad (
|
||||||
unsigned int num);
|
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)
|
inline uint32_t WriteBounds(const T* in, unsigned int size)
|
||||||
{
|
{
|
||||||
T minc,maxc;
|
T minc,maxc;
|
||||||
ArrayBounds(in,size,minc,maxc);
|
Assimp::ArrayBounds(in,size,minc,maxc);
|
||||||
fwrite(&minc,sizeof(T),1,out);
|
fwrite(&minc,sizeof(T),1,out);
|
||||||
fwrite(&maxc,sizeof(T),1,out);
|
fwrite(&maxc,sizeof(T),1,out);
|
||||||
return sizeof(T)*2;
|
return sizeof(T)*2;
|
||||||
|
@ -692,6 +692,44 @@ void WriteNode(const aiNode* node, FILE* out, unsigned int depth)
|
||||||
fprintf(out,"%s</Node>\n",prefix);
|
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
|
// Write a text model dump
|
||||||
void WriteDump(const aiScene* scene, FILE* out, const char* src, const char* cmd, bool shortened)
|
void WriteDump(const aiScene* scene, FILE* out, const char* src, const char* cmd, bool shortened)
|
||||||
|
|
Loading…
Reference in New Issue