Refined exporter implementation

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@887 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
ulfjorensen 2011-01-06 14:16:22 +00:00
parent e5f7fe0c3a
commit cef429bb70
1 changed files with 44 additions and 39 deletions

View File

@ -41,60 +41,66 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AssimpPCH.h" #include "AssimpPCH.h"
#if 0 #ifndef ASSIMP_BUILD_NO_EXPORT
// ------------------------------------------------------------------------------------------------
// Exporters
// ------------------------------------------------------------------------------------------------
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
//# include "ColladaExporter.h"
void ExportSceneCollada (aiExportDataBlob*, const aiScene*);
#endif
#ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
void ExportScene3DS(aiExportDataBlob*, const aiScene*);
#endif
// ------------------------------------------------------------------------------------------------
// Table of export format descriptors along with the corresponding exporter functions
// ------------------------------------------------------------------------------------------------
namespace Assimp { namespace Assimp {
typedef void (*fpExportFunc) (aiExportDataBlob*, const aiScene*) /* throw DeadlyExportError */; // ------------------------------------------------------------------------------------------------
// 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*);
// /// Function pointer type of a Export worker function
aiExportFormatDesc g_aExportInfo[] = { typedef void (*fpExportFunc)(aiExportDataBlob*, const aiScene*);
// ------------------------------------------------------------------------------------------------
/// Internal description of an Assimp export format option
struct ExportFormatEntry
{ {
"collada" /// Public description structure to be returned by aiGetExportFormatDescription()
, "COLLADA Open Standard for Painful Asset Interchange" aiExportFormatDesc mDescription;
, "dae"
}, // Worker function to do the actual exporting
fpExportFunc mExportFunction;
// Constructor to fill all entries
ExportFormatEntry( const char* pId, const char* pDesc, fpExportFunc pFunction)
{ {
"3ds" mDescription.id = pId;
, "Autodesk(tm) 3DS file format" mDescription.description = pDesc;
, "3ds" mExportFunction = pFunction;
} }
}; };
fpExportFunc g_aExportFunctions[] = { // ------------------------------------------------------------------------------------------------
ExportSceneCollada, // global array of all export formats which Assimp supports in its current build
ExportScene3DS ExportFormatEntry gExporters[] =
{
#ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
ExportFormatEntry( "collada", "Collada .dae", &ExportSceneCollada),
#endif
#ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
ExportFormatEntry( "3ds", "Autodesk .3ds", &ExportScene3DS),
#endif
}; };
}
} // end of namespace Assimp
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API size_t aiGetExportFormatCount(void) ASSIMP_API size_t aiGetExportFormatCount(void)
{ {
return 0; return sizeof( Assimp::gExporters) / sizeof( Assimp::ExportFormatEntry);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex) ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex)
{ {
if( pIndex >= aiGetExportFormatCount() )
return NULL; return NULL;
return &Assimp::gExporters[pIndex].mDescription;
} }
@ -118,5 +124,4 @@ ASSIMP_API C_STRUCT void aiReleaseExportData( const aiExportDataBlob* pData )
delete pData; delete pData;
} }
#endif // !ASSIMP_BUILD_NO_EXPORT
#endif