assimp_cmd: Add --verbose flag to 'info' command, to print node transforms.
parent
fb213e4bac
commit
a8fc22fd3f
|
@ -47,9 +47,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "Main.h"
|
#include "Main.h"
|
||||||
|
|
||||||
const char* AICMD_MSG_INFO_HELP_E =
|
const char* AICMD_MSG_INFO_HELP_E =
|
||||||
"assimp info <file> [-r]\n"
|
"assimp info <file> [-r] [-v]\n"
|
||||||
"\tPrint basic structure of a 3D model\n"
|
"\tPrint basic structure of a 3D model\n"
|
||||||
"\t-r,--raw: No postprocessing, do a raw import\n";
|
"\t-r,--raw: No postprocessing, do a raw import\n"
|
||||||
|
"\t-v,--verbose: Print verbose info such as node transform data\n";
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
|
@ -184,7 +185,7 @@ std::string FindPTypes(const aiScene* scene)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
void PrintHierarchy(const aiNode* root, unsigned int maxnest, unsigned int maxline,
|
void PrintHierarchy(const aiNode* root, unsigned int maxnest, unsigned int maxline,
|
||||||
unsigned int cline, unsigned int cnest=0)
|
unsigned int cline, bool verbose, unsigned int cnest=0)
|
||||||
{
|
{
|
||||||
if (cline++ >= maxline || cnest >= maxnest) {
|
if (cline++ >= maxline || cnest >= maxnest) {
|
||||||
return;
|
return;
|
||||||
|
@ -194,8 +195,29 @@ void PrintHierarchy(const aiNode* root, unsigned int maxnest, unsigned int maxli
|
||||||
printf("-- ");
|
printf("-- ");
|
||||||
}
|
}
|
||||||
printf("\'%s\', meshes: %u\n",root->mName.data,root->mNumMeshes);
|
printf("\'%s\', meshes: %u\n",root->mName.data,root->mNumMeshes);
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
// print the actual transform
|
||||||
|
//printf(",");
|
||||||
|
aiVector3D s, r, t;
|
||||||
|
root->mTransformation.Decompose(s, r, t);
|
||||||
|
if (s.x != 1.0 || s.y != 1.0 || s.z != 1.0) {
|
||||||
|
for(unsigned int i = 0; i < cnest; ++i) { printf(" "); }
|
||||||
|
printf(" S:[%f %f %f]\n", s.x, s.y, s.z);
|
||||||
|
}
|
||||||
|
if (r.x || r.y || r.z) {
|
||||||
|
for(unsigned int i = 0; i < cnest; ++i) { printf(" "); }
|
||||||
|
printf(" R:[%f %f %f]\n", r.x, r.y, r.z);
|
||||||
|
}
|
||||||
|
if (t.x || t.y || t.z) {
|
||||||
|
for(unsigned int i = 0; i < cnest; ++i) { printf(" "); }
|
||||||
|
printf(" T:[%f %f %f]\n", t.x, t.y, t.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//printf("\n");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < root->mNumChildren; ++i ) {
|
for (unsigned int i = 0; i < root->mNumChildren; ++i ) {
|
||||||
PrintHierarchy(root->mChildren[i],maxnest,maxline,cline,cnest+1);
|
PrintHierarchy(root->mChildren[i],maxnest,maxline,cline,verbose,cnest+1);
|
||||||
if(i == root->mNumChildren-1) {
|
if(i == root->mNumChildren-1) {
|
||||||
for(unsigned int i = 0; i < cnest; ++i) {
|
for(unsigned int i = 0; i < cnest; ++i) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
|
@ -230,10 +252,23 @@ int Assimp_Info (const char* const* params, unsigned int num)
|
||||||
|
|
||||||
const std::string in = std::string(params[0]);
|
const std::string in = std::string(params[0]);
|
||||||
|
|
||||||
|
// get -r and -v arguments
|
||||||
|
bool raw = false;
|
||||||
|
bool verbose = false;
|
||||||
|
for(unsigned int i = 1; i < num; ++i) {
|
||||||
|
if (!strcmp(params[i],"--raw")||!strcmp(params[i],"-r")) {
|
||||||
|
raw = true;
|
||||||
|
}
|
||||||
|
if (!strcmp(params[i],"--verbose")||!strcmp(params[i],"-v")) {
|
||||||
|
verbose = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// do maximum post-processing unless -r was specified
|
// do maximum post-processing unless -r was specified
|
||||||
ImportData import;
|
ImportData import;
|
||||||
import.ppFlags = num>1&&(!strcmp(params[1],"--raw")||!strcmp(params[1],"-r")) ? 0
|
if (!raw) {
|
||||||
: aiProcessPreset_TargetRealtime_MaxQuality;
|
import.ppFlags = aiProcessPreset_TargetRealtime_MaxQuality;
|
||||||
|
}
|
||||||
|
|
||||||
// import the main model
|
// import the main model
|
||||||
const aiScene* scene = ImportModel(import,in);
|
const aiScene* scene = ImportModel(import,in);
|
||||||
|
@ -346,7 +381,7 @@ int Assimp_Info (const char* const* params, unsigned int num)
|
||||||
|
|
||||||
printf("\nNode hierarchy:\n");
|
printf("\nNode hierarchy:\n");
|
||||||
unsigned int cline=0;
|
unsigned int cline=0;
|
||||||
PrintHierarchy(scene->mRootNode,20,1000,cline);
|
PrintHierarchy(scene->mRootNode,20,1000,cline,verbose);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue