assimp info now prints min,max and center points of a model.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@586 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2010-03-04 21:09:51 +00:00
parent a7f298e6c3
commit b26cee19a0
2 changed files with 39 additions and 17 deletions

View File

@ -120,13 +120,42 @@ unsigned int GetAvgVertsPerMesh(const aiScene* scene) {
return static_cast<unsigned int>(CountVertices(scene)/scene->mNumMeshes); return static_cast<unsigned int>(CountVertices(scene)/scene->mNumMeshes);
} }
#if 0 // -----------------------------------------------------------------------------------
void FindSpecialPoints(const aiScene* scene,const aiNode* root,aiVector3D special_points[3],const aiMatrix4x4& mat=aiMatrix4x4())
{
// XXX that could be greatly simplified by using code from code/ProcessHelper.h
// XXX I just don't want to include it here.
const aiMatrix4x4 trafo = root->mTransformation*mat;
for(unsigned int i = 0; i < root->mNumMeshes; ++i) {
const aiMesh* mesh = scene->mMeshes[root->mMeshes[i]];
for(unsigned int a = 0; a < mesh->mNumVertices; ++a) {
aiVector3D v = trafo*mesh->mVertices[a];
special_points[0].x = std::min(special_points[0].x,v.x);
special_points[0].y = std::min(special_points[0].y,v.y);
special_points[0].z = std::min(special_points[0].z,v.z);
special_points[1].x = std::max(special_points[1].x,v.x);
special_points[1].y = std::max(special_points[1].y,v.y);
special_points[1].z = std::max(special_points[1].z,v.z);
}
}
for(unsigned int i = 0; i < root->mNumChildren; ++i) {
FindSpecialPoints(scene,root->mChildren[i],special_points,trafo);
}
}
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
void FindSpecialPoints(const aiScene* scene,aiVector3D special_points[3]) void FindSpecialPoints(const aiScene* scene,aiVector3D special_points[3])
{ {
// XXX include code/ProcessHelper.h from here or rewrite everything from scratch? special_points[0] = aiVector3D(1e10f,1e10f,1e10f);
special_points[1] = aiVector3D(-1e10f,-1e10f,-1e10f);
FindSpecialPoints(scene,scene->mRootNode,special_points);
special_points[2] = 0.5f*(special_points[0]+special_points[1]);
} }
#endif
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
std::string FindPTypes(const aiScene* scene) std::string FindPTypes(const aiScene* scene)
@ -233,18 +262,14 @@ int Assimp_Info (const char** params, unsigned int num)
"Primitive Types: %s\n" "Primitive Types: %s\n"
"Average faces/mesh %i\n" "Average faces/mesh %i\n"
"Average verts/mesh %i\n" "Average verts/mesh %i\n"
#if 0
"Center point (%f %f %f)\n"
"Minimum point (%f %f %f)\n" "Minimum point (%f %f %f)\n"
"Maximum point (%f %f %f)\n" "Maximum point (%f %f %f)\n"
#endif "Center point (%f %f %f)\n"
; ;
#if 0
aiVector3D special_points[3]; aiVector3D special_points[3];
FindSpecialPoints(scene,special_points); FindSpecialPoints(scene,special_points);
#endif
printf(format_string, printf(format_string,
mem.total, mem.total,
CountNodes(scene->mRootNode), CountNodes(scene->mRootNode),
@ -261,13 +286,10 @@ int Assimp_Info (const char** params, unsigned int num)
CountAnimChannels(scene), CountAnimChannels(scene),
FindPTypes(scene).c_str(), FindPTypes(scene).c_str(),
GetAvgFacePerMesh(scene), GetAvgFacePerMesh(scene),
GetAvgVertsPerMesh(scene) GetAvgVertsPerMesh(scene),
#if 0 special_points[0][0],special_points[0][1],special_points[0][2],
, special_points[1][0],special_points[1][1],special_points[1][2],
special_points[0], special_points[2][0],special_points[2][1],special_points[2][2]
special_points[1],
special_points[2]
#endif
) )
; ;
unsigned int total=0; unsigned int total=0;

View File

@ -54,10 +54,10 @@ const char* AICMD_MSG_ABOUT =
"Version %i.%i-%s%s%s%s%s (SVNREV %i)\n\n"; "Version %i.%i-%s%s%s%s%s (SVNREV %i)\n\n";
const char* AICMD_MSG_HELP = const char* AICMD_MSG_HELP =
"assimp <verb> <arguments>\n\n" "assimp <verb> <arguments>\n\n"
"\tverbs:\n" "\tverbs:\n"
"\t\tinfo - Display statistics and structure of a 3D model\n"
"\t\tversion - Display Assimp version\n" "\t\tversion - Display Assimp version\n"
"\t\tlistext - List all known file extension\n" "\t\tlistext - List all known file extension\n"
"\t\tknowext - Check whether a file extension is recognized by Assimp\n" "\t\tknowext - Check whether a file extension is recognized by Assimp\n"