diff --git a/code/Exporter.cpp b/code/Exporter.cpp index c45c5cf6f..4129c3311 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -59,11 +59,8 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype - void ExportSceneCollada(aiExportDataBlob*, const aiScene*) { - } - - void ExportScene3DS(aiExportDataBlob*, const aiScene*) { - } +void ExportSceneCollada(aiExportDataBlob*, const aiScene*); +void ExportScene3DS(aiExportDataBlob*, const aiScene*) { } /// Function pointer type of a Export worker function typedef void (*fpExportFunc)(aiExportDataBlob*, const aiScene*); @@ -270,7 +267,26 @@ ASSIMP_API aiReturn aiExportSceneEx( const aiScene* pScene, const char* pFormatI // ------------------------------------------------------------------------------------------------ ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const aiScene* pScene, const char* pFormatId ) { - return NULL; + // find a suitable exporter + const Assimp::ExportFormatEntry* exporter = NULL; + for( size_t a = 0; a < aiGetExportFormatCount(); ++a ) + { + if( strcmp( Assimp::gExporters[a].mDescription.id, pFormatId) == 0 ) + exporter = Assimp::gExporters + a; + } + + if( !exporter ) + return NULL; + + aiExportDataBlob* blob = new aiExportDataBlob; + exporter->mExportFunction( blob, pScene); + if( !blob->data || blob->size == 0 ) + { + delete blob; + return NULL; + } + + return blob; } // ------------------------------------------------------------------------------------------------ diff --git a/code/SplitByBoneCountProcess.cpp b/code/SplitByBoneCountProcess.cpp index 47e6563cf..59ea46183 100644 --- a/code/SplitByBoneCountProcess.cpp +++ b/code/SplitByBoneCountProcess.cpp @@ -192,12 +192,14 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector& vb = vertexBones[face.mIndices[b]]; for( size_t c = 0; c < vb.size(); ++c) { + size_t boneIndex = vb[c].first; // if the bone is already used in this submesh, it's ok - if( isBoneUsed[ vb[c].first ] ) + if( isBoneUsed[boneIndex] ) continue; // if it's not used, yet, we would need to add it. Store its bone index - newBonesAtCurrentFace.push_back( vb[c].first); + if( std::find( newBonesAtCurrentFace.begin(), newBonesAtCurrentFace.end(), boneIndex) == newBonesAtCurrentFace.end() ) + newBonesAtCurrentFace.push_back( boneIndex); } } diff --git a/include/export.h b/include/export.h index a8e3f0790..5670d09d3 100644 --- a/include/export.h +++ b/include/export.h @@ -156,7 +156,7 @@ ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportSceneToBlob( const C_STRUCT * returned by aiExportScene(). * @param pData the data blob returned by aiExportScenetoBlob */ -ASSIMP_API C_STRUCT void aiReleaseExportBlob( const C_STRUCT aiExportDataBlob* pData ); +ASSIMP_API C_STRUCT void aiReleaseExportData( const C_STRUCT aiExportDataBlob* pData ); #ifdef __cplusplus } diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index 8e423afee..6d50f8818 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -183,6 +183,18 @@ DWORD WINAPI LoadThreadProc(LPVOID lpParameter) D3DCOLOR_ARGB(0xFF,0xFF,0,0)); return 1; } + + // testweise wieder rausschreiben + const aiExportDataBlob* blob = aiExportSceneToBlob( g_pcAsset->pcScene, "collada"); + if( blob ) + { + FILE* file = fopen( "test.dae", "wb"); + fwrite( blob->data, 1, blob->size, file); + fclose( file); + + aiReleaseExportData( blob); + } + return 0; } diff --git a/workspaces/vc9/assimp.vcproj b/workspaces/vc9/assimp.vcproj index 0867d9839..3c42f05ef 100644 --- a/workspaces/vc9/assimp.vcproj +++ b/workspaces/vc9/assimp.vcproj @@ -1,7 +1,7 @@ + + + + + +