Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

141 řádky
4.2 KiB

  1. %module assimp
  2. // SWIG helpers for std::string and std::vector wrapping.
  3. %include <std_string.i>
  4. %include <std_vector.i>
  5. // Globally enable enum prefix stripping.
  6. %dstripprefix;
  7. // PACK_STRUCT is a no-op for SWIG – it does not matter for the generated
  8. // bindings how the underlying C++ code manages its memory.
  9. #define PACK_STRUCT
  10. // Helper macros for wrapping the pointer-and-length arrays used in the
  11. // Assimp API.
  12. %define ASSIMP_ARRAY(CLASS, TYPE, NAME, LENGTH)
  13. %newobject CLASS::NAME;
  14. %extend CLASS {
  15. std::vector<TYPE > *NAME() const {
  16. std::vector<TYPE > *result = new std::vector<TYPE >;
  17. result->reserve(LENGTH);
  18. for (unsigned int i = 0; i < LENGTH; ++i) {
  19. result->push_back($self->NAME[i]);
  20. }
  21. return result;
  22. }
  23. }
  24. %ignore CLASS::NAME;
  25. %enddef
  26. %define ASSIMP_POINTER_ARRAY(CLASS, TYPE, NAME, LENGTH)
  27. %newobject CLASS::NAME;
  28. %extend CLASS {
  29. std::vector<TYPE *> *NAME() const {
  30. std::vector<TYPE *> *result = new std::vector<TYPE *>;
  31. result->reserve(LENGTH);
  32. TYPE *currentValue = $self->NAME;
  33. TYPE *valueLimit = $self->NAME + LENGTH;
  34. while (currentValue < valueLimit) {
  35. result->push_back(currentValue);
  36. ++currentValue;
  37. }
  38. return result;
  39. }
  40. }
  41. %ignore CLASS::NAME;
  42. %enddef
  43. %define ASSIMP_POINTER_ARRAY_ARRAY(CLASS, TYPE, NAME, OUTER_LENGTH, INNER_LENGTH)
  44. %newobject CLASS::NAME;
  45. %extend CLASS {
  46. std::vector<std::vector<TYPE *> > *NAME() const {
  47. std::vector<std::vector<TYPE *> > *result = new std::vector<std::vector<TYPE *> >;
  48. result->reserve(OUTER_LENGTH);
  49. for (unsigned int i = 0; i < OUTER_LENGTH; ++i) {
  50. std::vector<TYPE *> currentElements;
  51. if ($self->NAME[i] != 0) {
  52. currentElements.reserve(INNER_LENGTH);
  53. TYPE *currentValue = $self->NAME[i];
  54. TYPE *valueLimit = $self->NAME[i] + INNER_LENGTH;
  55. while (currentValue < valueLimit) {
  56. currentElements.push_back(currentValue);
  57. ++currentValue;
  58. }
  59. }
  60. result->push_back(currentElements);
  61. }
  62. return result;
  63. }
  64. }
  65. %ignore CLASS::NAME;
  66. %enddef
  67. %include "interface/aiDefines.i"
  68. %include "interface/aiTypes.i"
  69. %include "interface/assimp.i"
  70. %include "interface/aiTexture.i"
  71. %include "interface/aiMatrix4x4.i"
  72. %include "interface/aiMatrix3x3.i"
  73. %include "interface/aiVector3D.i"
  74. %include "interface/aiVector2D.i"
  75. %include "interface/aiColor4D.i"
  76. %include "interface/aiLight.i"
  77. %include "interface/aiCamera.i"
  78. %include "interface/aiFileIO.i"
  79. %include "interface/aiAssert.i"
  80. %include "interface/aiVersion.i"
  81. %include "interface/aiAnim.i"
  82. %include "interface/aiMaterial.i"
  83. %include "interface/aiMesh.i"
  84. %include "interface/aiPostProcess.i"
  85. %include "interface/aiConfig.i"
  86. %include "interface/assimp.i"
  87. %include "interface/aiQuaternion.i"
  88. %include "interface/aiScene.i"
  89. %include "interface/Logger.i"
  90. %include "interface/DefaultLogger.i"
  91. %include "interface/NullLogger.i"
  92. %include "interface/LogStream.i"
  93. %include "interface/IOStream.i"
  94. %include "interface/IOSystem.i"
  95. // We have to "instanciate" the templates used by the ASSSIMP_*_ARRAY macros
  96. // here at the end to avoid running into forward reference issues (SWIG would
  97. // spit out the helper functions before the header includes for the element
  98. // types otherwise).
  99. %template(UintVector) std::vector<unsigned int>;
  100. %template(aiAnimationVector) std::vector<aiAnimation *>;
  101. %template(aiAnimMeshVector) std::vector<aiAnimMesh *>;
  102. %template(aiBonesVector) std::vector<aiBone *>;
  103. %template(aiCameraVector) std::vector<aiCamera *>;
  104. %template(aiColor4DVector) std::vector<aiColor4D *>;
  105. %template(aiColor4DVectorVector) std::vector<std::vector<aiColor4D *> >;
  106. %template(aiFaceVector) std::vector<aiFace *>;
  107. %template(aiLightVector) std::vector<aiLight *>;
  108. %template(aiMaterialVector) std::vector<aiMaterial *>;
  109. %template(aiMaterialPropertyVector) std::vector<aiMaterialProperty *>;
  110. %template(aiMeshAnimVector) std::vector<aiMeshAnim *>;
  111. %template(aiMeshVector) std::vector<aiMesh *>;
  112. %template(aiNodeVector) std::vector<aiNode *>;
  113. %template(aiNodeAnimVector) std::vector<aiNodeAnim *>;
  114. %template(aiTextureVector) std::vector<aiTexture *>;
  115. %template(aiVector3DVector) std::vector<aiVector3D *>;
  116. %template(aiVector3DVectorVector) std::vector<std::vector<aiVector3D *> >;
  117. %template(aiVertexWeightVector) std::vector<aiVertexWeight *>;