From a2543e715127b7bb94255fd06597dd92d6b26a7e Mon Sep 17 00:00:00 2001 From: Sergio Acereda Date: Fri, 4 Mar 2022 17:09:29 +0100 Subject: [PATCH] Add properties information on assimp info command line --- tools/assimp_cmd/Info.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tools/assimp_cmd/Info.cpp b/tools/assimp_cmd/Info.cpp index 6c06d6af3..3e83b88bb 100644 --- a/tools/assimp_cmd/Info.cpp +++ b/tools/assimp_cmd/Info.cpp @@ -425,19 +425,31 @@ int Assimp_Info(const char *const *params, unsigned int num) { } // materials - unsigned int total = 0; + if (scene->mNumMaterials) + printf("\nNamed Materials:"); for (unsigned int i = 0; i < scene->mNumMaterials; ++i) { - aiString name; - if (AI_SUCCESS == aiGetMaterialString(scene->mMaterials[i], AI_MATKEY_NAME, &name)) { - printf("%s\n \'%s\'", (total++ ? "" : "\nNamed Materials:"), name.data); + const aiMaterial *mat = scene->mMaterials[i]; + aiString name = mat->GetName(); + printf("\n \'%s\'", name.data); + if (mat->mNumProperties) + printf(" (prop) [index / bytes | texture semantic]"); + for (unsigned p = 0; p < mat->mNumProperties; p++) { + const aiMaterialProperty *prop = mat->mProperties[p]; + const aiTextureType textype = static_cast(prop->mSemantic); + printf("\n %d (%s): [%d / %d | %s]", + p, + prop->mKey.data, + prop->mIndex, + prop->mDataLength, + TextureTypeToString(textype)); } } - if (total) { + if (scene->mNumMaterials) { printf("\n"); } // textures - total = 0; + unsigned int total = 0; for (unsigned int i = 0; i < scene->mNumMaterials; ++i) { aiString name; static const aiTextureType types[] = {