Exporter.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2010, ASSIMP Development Team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the ASSIMP team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the ASSIMP Development Team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. #include "AssimpPCH.h"
  35. #ifndef ASSIMP_BUILD_NO_EXPORT
  36. namespace Assimp {
  37. // ------------------------------------------------------------------------------------------------
  38. // Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype
  39. void ExportSceneCollada(aiExportDataBlob*, const aiScene*);
  40. void ExportScene3DS(aiExportDataBlob*, const aiScene*);
  41. /// Function pointer type of a Export worker function
  42. typedef void (*fpExportFunc)(aiExportDataBlob*, const aiScene*);
  43. // ------------------------------------------------------------------------------------------------
  44. /// Internal description of an Assimp export format option
  45. struct ExportFormatEntry
  46. {
  47. /// Public description structure to be returned by aiGetExportFormatDescription()
  48. aiExportFormatDesc mDescription;
  49. // Worker function to do the actual exporting
  50. fpExportFunc mExportFunction;
  51. // Constructor to fill all entries
  52. ExportFormatEntry( const char* pId, const char* pDesc, fpExportFunc pFunction)
  53. {
  54. mDescription.id = pId;
  55. mDescription.description = pDesc;
  56. mExportFunction = pFunction;
  57. }
  58. };
  59. // ------------------------------------------------------------------------------------------------
  60. // global array of all export formats which Assimp supports in its current build
  61. ExportFormatEntry gExporters[] =
  62. {
  63. #ifndef ASSIMP_BUILD_NO_COLLADA_EXPORTER
  64. ExportFormatEntry( "collada", "Collada .dae", &ExportSceneCollada),
  65. #endif
  66. #ifndef ASSIMP_BUILD_NO_3DS_EXPORTER
  67. ExportFormatEntry( "3ds", "Autodesk .3ds", &ExportScene3DS),
  68. #endif
  69. };
  70. } // end of namespace Assimp
  71. // ------------------------------------------------------------------------------------------------
  72. ASSIMP_API size_t aiGetExportFormatCount(void)
  73. {
  74. return sizeof( Assimp::gExporters) / sizeof( Assimp::ExportFormatEntry);
  75. }
  76. // ------------------------------------------------------------------------------------------------
  77. ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex)
  78. {
  79. if( pIndex >= aiGetExportFormatCount() )
  80. return NULL;
  81. return &Assimp::gExporters[pIndex].mDescription;
  82. }
  83. // ------------------------------------------------------------------------------------------------
  84. ASSIMP_API const C_STRUCT aiExportDataBlob* aiExportScene( const aiScene* pScene, const char* pFormatId )
  85. {
  86. return NULL;
  87. }
  88. // ------------------------------------------------------------------------------------------------
  89. ASSIMP_API C_STRUCT aiReturn aiWriteBlobToFile( const C_STRUCT aiExportDataBlob* pBlob, const char* pPath, const aiFileIO* pIOSystem )
  90. {
  91. return AI_FAILURE;
  92. }
  93. // ------------------------------------------------------------------------------------------------
  94. ASSIMP_API C_STRUCT void aiReleaseExportData( const aiExportDataBlob* pData )
  95. {
  96. delete pData;
  97. }
  98. #endif // !ASSIMP_BUILD_NO_EXPORT