DX_SkinWeights* dxExporter::MakeSkinWeights( DX_Frame* dx_frm ) { if (dx_frm->mesh == NULL) return NULL; DX_DWORD nBones = CountBones( dx_frm ); if (nBones == 0) return NULL; // SkinWeights for the Mesh frame DX_SkinWeights* dx_skms = AllocSkinWeight( NULL, dx_frm, dx_frm ); DX_Frame* dx_fbn = dx_frm->next; DX_SkinWeights* dx_skm; while (dx_fbn) { if (dx_fbn->frameType == DX_FRAME_BONE) { // SkinWeights for the Bone frame dx_skm = AllocSkinWeight( dx_skms, dx_frm, dx_fbn ); dx_fbn = dx_fbn->next; } else { dx_fbn = NULL; } } if (dx_skms != NULL) { BuildSkinWeights( dx_skms, dx_frm ); } dx_frm->mesh->skinWeights = dx_skms; return dx_skms; }
// ----------------------------------------------------------------------------------- // Implementation of the assimp info utility to print basic file info int Assimp_Info (const char* const* params, unsigned int num) { if (num < 1) { printf("assimp info: Invalid number of arguments. " "See \'assimp info --help\'\n"); return 1; } // --help if (!strcmp( params[0],"-h")||!strcmp( params[0],"--help")||!strcmp( params[0],"-?") ) { printf("%s",AICMD_MSG_INFO_HELP_E); return 0; } // asssimp info <file> [-r] if (num < 1) { printf("assimp info: Invalid number of arguments. " "See \'assimp info --help\'\n"); return 1; } const std::string in = std::string(params[0]); // do maximum post-processing unless -r was specified ImportData import; import.ppFlags = num>1&&(!strcmp(params[1],"--raw")||!strcmp(params[1],"-r")) ? 0 : aiProcessPreset_TargetRealtime_MaxQuality; // import the main model import.log = true; import.showLog = true; const aiScene* scene = ImportModel(import,in); if (!scene) { printf("assimp info: Unable to load input file %s\n", in.c_str()); return 5; } aiMemoryInfo mem; globalImporter->GetMemoryRequirements(mem); static const char* format_string = "Memory consumption: %i B\n" "Nodes: %i\n" "Maximum depth %i\n" "Meshes: %i\n" "Animations: %i\n" "Textures (embed.): %i\n" "Materials: %i\n" "Cameras: %i\n" "Lights: %i\n" "Vertices: %i\n" "Faces: %i\n" "Bones: %i\n" "Animation Channels: %i\n" "Primitive Types: %s\n" "Average faces/mesh %i\n" "Average verts/mesh %i\n" "Minimum point (%f %f %f)\n" "Maximum point (%f %f %f)\n" "Center point (%f %f %f)\n" ; aiVector3D special_points[3]; FindSpecialPoints(scene,special_points); printf(format_string, mem.total, CountNodes(scene->mRootNode), GetMaxDepth(scene->mRootNode), scene->mNumMeshes, scene->mNumAnimations, scene->mNumTextures, scene->mNumMaterials, scene->mNumCameras, scene->mNumLights, CountVertices(scene), CountFaces(scene), CountBones(scene), CountAnimChannels(scene), FindPTypes(scene).c_str(), GetAvgFacePerMesh(scene), GetAvgVertsPerMesh(scene), 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[2][0],special_points[2][1],special_points[2][2] ) ; unsigned int total=0; 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); } } if(total) { printf("\n"); } total=0; for(unsigned int i = 0;i < scene->mNumMaterials; ++i) { aiString name; static const aiTextureType types[] = { aiTextureType_NONE, aiTextureType_DIFFUSE, aiTextureType_SPECULAR, aiTextureType_AMBIENT, aiTextureType_EMISSIVE, aiTextureType_HEIGHT, aiTextureType_NORMALS, aiTextureType_SHININESS, aiTextureType_OPACITY, aiTextureType_DISPLACEMENT, aiTextureType_LIGHTMAP, aiTextureType_REFLECTION, aiTextureType_UNKNOWN }; for(unsigned int type = 0; type < sizeof(types)/sizeof(types[0]); ++type) { for(unsigned int idx = 0;AI_SUCCESS==aiGetMaterialString(scene->mMaterials[i], AI_MATKEY_TEXTURE(types[type],idx),&name); ++idx) { printf("%s\n \'%s\'",(total++?"":"\nTexture Refs:" ),name.data); } } } if(total) { printf("\n"); } total=0; for(unsigned int i = 0;i < scene->mNumAnimations; ++i) { if (scene->mAnimations[i]->mName.length) { printf("%s\n \'%s\'",(total++?"":"\nNamed Animations:" ),scene->mAnimations[i]->mName.data); } } if(total) { printf("\n"); } printf("\nNode hierarchy:\n"); unsigned int cline=0; PrintHierarchy(scene->mRootNode,20,1000,cline); printf("\n"); return 0; }
// ----------------------------------------------------------------------------------- // Implementation of the assimp info utility to print basic file info int Assimp_Info(const aiScene* scene, Assimp::Importer *globalImporter) { aiMemoryInfo mem; globalImporter->GetMemoryRequirements(mem); static const char* format_string = "Memory consumption: %i B\n" "Nodes: %i\n" "Maximum depth %i\n" "Meshes: %i\n" "Animations: %i\n" "Textures (embed.): %i\n" "Materials: %i\n" "Cameras: %i\n" "Lights: %i\n" "Vertices: %i\n" "Faces: %i\n" "Bones: %i\n" "Animation Channels: %i\n" "Primitive Types: %s\n" "Average faces/mesh %i\n" "Average verts/mesh %i\n" "Minimum point (%f %f %f)\n" "Maximum point (%f %f %f)\n" "Center point (%f %f %f)\n" ; aiVector3D special_points[3]; FindSpecialPoints(scene, special_points); fprintf(stderr, format_string, mem.total, CountNodes(scene->mRootNode), GetMaxDepth(scene->mRootNode), scene->mNumMeshes, scene->mNumAnimations, scene->mNumTextures, scene->mNumMaterials, scene->mNumCameras, scene->mNumLights, CountVertices(scene), CountFaces(scene), CountBones(scene), CountAnimChannels(scene), FindPTypes(scene).c_str(), GetAvgFacePerMesh(scene), GetAvgVertsPerMesh(scene), 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[2][0], special_points[2][1], special_points[2][2] ) ; #define FULLLOG #ifdef FULLLOG unsigned int total = 0; for (unsigned int i = 0; i < scene->mNumMaterials; ++i) { aiString name; if (AI_SUCCESS == aiGetMaterialString(scene->mMaterials[i], AI_MATKEY_NAME, &name)) { fprintf(stderr, "%s\n \'%s\'", (total++ ? "" : "\nNamed Materials:"), name.data); } } if (total) { fprintf(stderr, "\n"); } total = 0; for (unsigned int i = 0; i < scene->mNumMaterials; ++i) { aiString name; static const aiTextureType types[] = { aiTextureType_NONE, aiTextureType_DIFFUSE, aiTextureType_SPECULAR, aiTextureType_AMBIENT, aiTextureType_EMISSIVE, aiTextureType_HEIGHT, aiTextureType_NORMALS, aiTextureType_SHININESS, aiTextureType_OPACITY, aiTextureType_DISPLACEMENT, aiTextureType_LIGHTMAP, aiTextureType_REFLECTION, aiTextureType_UNKNOWN }; for (unsigned int type = 0; type < sizeof(types) / sizeof(types[0]); ++type) { for (unsigned int idx = 0; AI_SUCCESS == aiGetMaterialString(scene->mMaterials[i], AI_MATKEY_TEXTURE(types[type], idx), &name); ++idx) { fprintf(stderr, "%s\n \'%s\'", (total++ ? "" : "\nTexture Refs:"), name.data); } } } if (total) { fprintf(stderr, "\n"); } total = 0; for (unsigned int i = 0; i < scene->mNumAnimations; ++i) { if (scene->mAnimations[i]->mName.length) { fprintf(stderr, "%s\n \'%s\'", (total++ ? "" : "\nNamed Animations:"), scene->mAnimations[i]->mName.data); } } if (total) { fprintf(stderr, "\n"); } /* fprintf(stderr, "\nNode hierarchy:\n"); unsigned int cline = 0; PrintHierarchy(scene->mRootNode, 20, 1000, cline); */ #endif fprintf(stderr, "\n"); return 0; }
DX_XSkinMeshHeader* dxExporter::MakeXSkinMesh( DX_Frame* dx_frm ) { if (dx_frm->mesh == NULL) return NULL; DX_DWORD nBones = CountBones( dx_frm ); if (nBones == 0) return NULL; DX_XSkinMeshHeader* dx_xsk = new DX_XSkinMeshHeader; dx_xsk->nMaxSkinWeightsPerVertex = 0; dx_xsk->nMaxSkinWeightsPerFace = 0; dx_xsk->nBones = 0; if (dx_frm->mesh->skinWeights) { DX_Mesh* dx_msh = dx_frm->mesh; DX_DWORD nArray = dx_msh->nVertices > dx_msh->nFaces ? dx_msh->nVertices : dx_msh->nFaces; DX_DWORD* nWeights = new DX_DWORD[nArray]; DX_DWORD idx, n; DX_SkinWeights* dx_skm = dx_frm->mesh->skinWeights; memset( nWeights, 0, sizeof(DX_DWORD) * nArray ); while (dx_skm) { for (n = 0; n < dx_skm->nWeights; n++) { idx = dx_skm->vertexIndices[n]; nWeights[ idx ] += 1; if (nWeights[ idx ] > dx_xsk->nMaxSkinWeightsPerVertex) { dx_xsk->nMaxSkinWeightsPerVertex = nWeights[ idx ]; } } if (dx_skm->nWeights > 0) { dx_xsk->nBones++; } dx_skm = dx_skm->next; } DX_SharedFaces* dx_shf = DX_MakeSharedFaces( dx_msh ); DX_DWORD* nFaces = new DX_DWORD[dx_msh->nFaces]; memset( nWeights, 0x00, dx_msh->nFaces * sizeof(DX_DWORD) ); DX_FaceEntry* entry; dx_skm = dx_frm->mesh->skinWeights; while (dx_skm) { memset( nFaces, 0x00, dx_msh->nFaces * sizeof(DX_DWORD) ); for (n = 0; n < dx_skm->nWeights; n++) { idx = dx_skm->vertexIndices[n]; entry = dx_shf->entries[idx].next; while (entry) { if (nFaces[ entry->number ] == FALSE) { nFaces [ entry->number ] = TRUE; nWeights[ entry->number ] += 1; if (nWeights[ entry->number ] > dx_xsk->nMaxSkinWeightsPerFace) { dx_xsk->nMaxSkinWeightsPerFace = nWeights[ entry->number ]; } } entry = entry->next; } } dx_skm = dx_skm->next; } DX_DisposeSharedFaces( &dx_shf ); delete nWeights; delete nFaces; } else { dx_xsk->nMaxSkinWeightsPerVertex = nBones + 1; dx_xsk->nMaxSkinWeightsPerFace = nBones + 1; dx_xsk->nBones = nBones + 1; } dx_frm->mesh->xskinMeshHeader = dx_xsk; return dx_xsk; }