On request, merged current state of the SWIG bindings for the D programming language.
The interface files are by no means complete yet and only work with the not-yet-released D SWIG backend, although adding support for other languages should not be too much of problem via #ifdefs. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@596 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
07558b15a3
commit
11aa5c339d
|
@ -0,0 +1,134 @@
|
||||||
|
%module assimp
|
||||||
|
|
||||||
|
// SWIG helpers for std::string and std::vector wrapping.
|
||||||
|
%include <std_string.i>
|
||||||
|
%include <std_vector.i>
|
||||||
|
|
||||||
|
// Globally enable enum prefix stripping.
|
||||||
|
%dstripprefix;
|
||||||
|
|
||||||
|
|
||||||
|
// PACK_STRUCT is a no-op for SWIG – it does not matter for the generated
|
||||||
|
// bindings how the underlying C++ code manages its memory.
|
||||||
|
#define PACK_STRUCT
|
||||||
|
|
||||||
|
|
||||||
|
// Helper macros for wrapping the pointer-and-length arrays used in the
|
||||||
|
// Assimp API.
|
||||||
|
|
||||||
|
%define ASSIMP_ARRAY(CLASS, TYPE, NAME, LENGTH)
|
||||||
|
%newobject CLASS::NAME;
|
||||||
|
%extend CLASS {
|
||||||
|
std::vector<TYPE > *NAME() {
|
||||||
|
std::vector<TYPE > *result = new std::vector<TYPE >;
|
||||||
|
result->reserve(LENGTH);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < LENGTH; ++i) {
|
||||||
|
result->push_back($self->NAME[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%ignore CLASS::NAME;
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
%define ASSIMP_POINTER_ARRAY(CLASS, TYPE, NAME, LENGTH)
|
||||||
|
%newobject CLASS::NAME;
|
||||||
|
%extend CLASS {
|
||||||
|
std::vector<TYPE *> *NAME() {
|
||||||
|
std::vector<TYPE *> *result = new std::vector<TYPE *>;
|
||||||
|
result->reserve(LENGTH);
|
||||||
|
|
||||||
|
TYPE *currentValue = $self->NAME;
|
||||||
|
TYPE *valueLimit = $self->NAME + LENGTH;
|
||||||
|
while (currentValue < valueLimit) {
|
||||||
|
result->push_back(currentValue);
|
||||||
|
++currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%ignore CLASS::NAME;
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
%define ASSIMP_POINTER_ARRAY_ARRAY(CLASS, TYPE, NAME, OUTER_LENGTH, INNER_LENGTH)
|
||||||
|
%newobject CLASS::NAME;
|
||||||
|
%extend CLASS {
|
||||||
|
std::vector<std::vector<TYPE *> > *NAME() {
|
||||||
|
std::vector<std::vector<TYPE *> > *result = new std::vector<std::vector<TYPE *> >;
|
||||||
|
result->reserve(OUTER_LENGTH);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < OUTER_LENGTH; ++i) {
|
||||||
|
std::vector<TYPE *> currentElements;
|
||||||
|
|
||||||
|
if ($self->NAME[i] != 0) {
|
||||||
|
currentElements.reserve(INNER_LENGTH);
|
||||||
|
|
||||||
|
TYPE *currentValue = $self->NAME[i];
|
||||||
|
TYPE *valueLimit = $self->NAME[i] + INNER_LENGTH;
|
||||||
|
while (currentValue < valueLimit) {
|
||||||
|
currentElements.push_back(currentValue);
|
||||||
|
++currentValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result->push_back(currentElements);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%ignore CLASS::NAME;
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
|
||||||
|
%include "interface/aiDefines.i"
|
||||||
|
%include "interface/aiTypes.i"
|
||||||
|
%include "interface/assimp.i"
|
||||||
|
%include "interface/aiTexture.i"
|
||||||
|
%include "interface/aiMatrix4x4.i"
|
||||||
|
%include "interface/aiMatrix3x3.i"
|
||||||
|
%include "interface/aiVector3D.i"
|
||||||
|
%include "interface/aiVector2D.i"
|
||||||
|
%include "interface/aiColor4D.i"
|
||||||
|
%include "interface/aiLight.i"
|
||||||
|
%include "interface/aiCamera.i"
|
||||||
|
%include "interface/aiFileIO.i"
|
||||||
|
%include "interface/aiAssert.i"
|
||||||
|
%include "interface/aiVersion.i"
|
||||||
|
%include "interface/aiAnim.i"
|
||||||
|
%include "interface/aiMaterial.i"
|
||||||
|
%include "interface/aiMesh.i"
|
||||||
|
%include "interface/aiPostProcess.i"
|
||||||
|
%include "interface/aiConfig.i"
|
||||||
|
%include "interface/assimp.i"
|
||||||
|
%include "interface/aiQuaternion.i"
|
||||||
|
%include "interface/aiScene.i"
|
||||||
|
%include "interface/Logger.i"
|
||||||
|
%include "interface/DefaultLogger.i"
|
||||||
|
%include "interface/NullLogger.i"
|
||||||
|
%include "interface/LogStream.i"
|
||||||
|
%include "interface/IOStream.i"
|
||||||
|
%include "interface/IOSystem.i"
|
||||||
|
|
||||||
|
|
||||||
|
// We have to "instanciate" the templates at the end to avoid running into
|
||||||
|
// forward reference issues (SWIG would spit out the vector helper functions
|
||||||
|
// before the header includes otherwise).
|
||||||
|
|
||||||
|
%template(UintVector) std::vector<unsigned int>;
|
||||||
|
%template(aiAnimationVector) std::vector<aiAnimation *>;
|
||||||
|
%template(aiCameraVector) std::vector<aiCamera *>;
|
||||||
|
%template(aiColor4DVector) std::vector<aiColor4D *>;
|
||||||
|
%template(aiColor4DVectorVector) std::vector<std::vector<aiColor4D *> >;
|
||||||
|
%template(aiFaceVector) std::vector<aiFace *>;
|
||||||
|
%template(aiLightVector) std::vector<aiLight *>;
|
||||||
|
%template(aiMaterialVector) std::vector<aiMaterial *>;
|
||||||
|
%template(aiMeshVector) std::vector<aiMesh *>;
|
||||||
|
%template(aiNodeVector) std::vector<aiNode *>;
|
||||||
|
%template(aiNodeAnimVector) std::vector<aiNodeAnim *>;
|
||||||
|
%template(aiTextureVector) std::vector<aiTexture *>;
|
||||||
|
%template(aiVector3DVector) std::vector<aiVector3D *>;
|
||||||
|
%template(aiVector3DVectorVector) std::vector<std::vector<aiVector3D *> >;
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
gcc -shared -fPIC -g3 -I../../../include/ -lassimp -olibassimp_wrap.so assimp_wrap.cxx
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
rm -rf assimp/
|
||||||
|
mkdir assimp
|
||||||
|
swig -c++ -d -outcurrentdir -I../../../include -splitproxy -package assimp $@ ../assimp.i
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "DefaultLogger.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "DefaultLogger.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "IOStream.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "IOStream.h"
|
|
@ -0,0 +1,11 @@
|
||||||
|
%{
|
||||||
|
#include "IOSystem.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
// The const char* overload is used instead.
|
||||||
|
%ignore Assimp::IOSystem::Exists(const std::string&) const;
|
||||||
|
%ignore Assimp::IOSystem::Open(const std::string& pFile);
|
||||||
|
%ignore Assimp::IOSystem::Open(const std::string& pFile, const std::string& pMode);
|
||||||
|
%ignore Assimp::IOSystem::ComparePaths(const std::string& one, const std::string& second) const;
|
||||||
|
|
||||||
|
%include "IOSystem.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "LogStream.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "LogStream.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "Logger.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "Logger.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "NullLogger.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "NullLogger.h"
|
|
@ -0,0 +1,7 @@
|
||||||
|
%{
|
||||||
|
#include "aiAnim.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
ASSIMP_ARRAY(aiAnimation, aiNodeAnim*, mChannels, $self->mNumChannels);
|
||||||
|
|
||||||
|
%include "aiAnim.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiAssert.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiAssert.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiCamera.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiCamera.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiColor4D.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiColor4D.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiConfig.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiConfig.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiDefines.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiDefines.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiFileIO.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiFileIO.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiLight.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiLight.h"
|
|
@ -0,0 +1,18 @@
|
||||||
|
%{
|
||||||
|
#include "aiMaterial.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiMaterial.h"
|
||||||
|
|
||||||
|
%include <typemaps.i>
|
||||||
|
%apply int &OUTPUT { int &pOut };
|
||||||
|
%apply float &OUTPUT { float &pOut };
|
||||||
|
|
||||||
|
%template(GetInteger) aiMaterial::Get<int>;
|
||||||
|
%template(GetFloat) aiMaterial::Get<float>;
|
||||||
|
%template(GetColor4D) aiMaterial::Get<aiColor4D>;
|
||||||
|
%template(GetColor3D) aiMaterial::Get<aiColor3D>;
|
||||||
|
%template(GetString) aiMaterial::Get<aiString>;
|
||||||
|
|
||||||
|
%clear int &pOut;
|
||||||
|
%clear float &pOut;
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiMatrix3x3.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiMatrix3x3.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiMatrix4x4.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiMatrix4x4.h"
|
|
@ -0,0 +1,16 @@
|
||||||
|
%{
|
||||||
|
#include "aiMesh.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
ASSIMP_ARRAY(aiMesh, unsigned int, mNumUVComponents, AI_MAX_NUMBER_OF_TEXTURECOORDS);
|
||||||
|
ASSIMP_POINTER_ARRAY(aiMesh, aiVector3D, mVertices, $self->mNumVertices);
|
||||||
|
ASSIMP_POINTER_ARRAY(aiMesh, aiVector3D, mNormals, $self->mNumVertices);
|
||||||
|
ASSIMP_POINTER_ARRAY(aiMesh, aiFace, mFaces, $self->mNumFaces);
|
||||||
|
ASSIMP_POINTER_ARRAY_ARRAY(aiMesh, aiVector3D, mTextureCoords, AI_MAX_NUMBER_OF_TEXTURECOORDS, $self->mNumVertices);
|
||||||
|
ASSIMP_POINTER_ARRAY_ARRAY(aiMesh, aiColor4D, mColors, AI_MAX_NUMBER_OF_COLOR_SETS, $self->mNumVertices);
|
||||||
|
|
||||||
|
ASSIMP_ARRAY(aiFace, unsigned int, mIndices, $self->mNumIndices);
|
||||||
|
|
||||||
|
|
||||||
|
%include "aiMesh.h"
|
|
@ -0,0 +1,7 @@
|
||||||
|
%{
|
||||||
|
#include "aiPostProcess.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%feature("d:stripprefix", "aiProcess_") aiPostProcessSteps;
|
||||||
|
|
||||||
|
%include "aiPostProcess.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiQuaternion.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiQuaternion.h"
|
|
@ -0,0 +1,17 @@
|
||||||
|
%{
|
||||||
|
#include "aiScene.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
ASSIMP_ARRAY(aiScene, aiAnimation*, mAnimations, $self->mNumAnimations);
|
||||||
|
ASSIMP_ARRAY(aiScene, aiCamera*, mCameras, $self->mNumCameras);
|
||||||
|
ASSIMP_ARRAY(aiScene, aiLight*, mLights, $self->mNumLights);
|
||||||
|
ASSIMP_ARRAY(aiScene, aiMaterial*, mMaterials, $self->mNumMaterials);
|
||||||
|
ASSIMP_ARRAY(aiScene, aiMesh*, mMeshes, $self->mNumMeshes);
|
||||||
|
ASSIMP_ARRAY(aiScene, aiTexture*, mTextures, $self->mNumTextures);
|
||||||
|
|
||||||
|
ASSIMP_ARRAY(aiNode, aiNode*, mChildren, $self->mNumChildren);
|
||||||
|
ASSIMP_ARRAY(aiNode, unsigned int, mMeshes, $self->mNumMeshes);
|
||||||
|
|
||||||
|
|
||||||
|
%include "aiScene.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiTexture.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiTexture.h"
|
|
@ -0,0 +1,8 @@
|
||||||
|
%{
|
||||||
|
#include "aiTypes.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
// The const char* overload is used instead.
|
||||||
|
%ignore aiString::Set(const std::string& pString);
|
||||||
|
|
||||||
|
%include "aiTypes.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiVector2D.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiVector2D.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiVector3D.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiVector3D.h"
|
|
@ -0,0 +1,5 @@
|
||||||
|
%{
|
||||||
|
#include "aiVersion.h"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "aiVersion.h"
|
|
@ -0,0 +1,41 @@
|
||||||
|
%{
|
||||||
|
#include "assimp.hpp"
|
||||||
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
namespace Assimp {
|
||||||
|
|
||||||
|
// See docs in assimp.hpp.
|
||||||
|
%ignore Importer::ReadFile(const std::string& pFile, unsigned int pFlags);
|
||||||
|
%ignore Importer::GetExtensionList(std::string& szOut);
|
||||||
|
%ignore Importer::IsExtensionSupported(const std::string& szExtension);
|
||||||
|
|
||||||
|
// These are only neccessary for extending Assimp with custom importers or post
|
||||||
|
// processing steps, which would require wrapping the internal BaseImporter and
|
||||||
|
// BaseProcess classes.
|
||||||
|
%ignore Importer::RegisterLoader(BaseImporter* pImp);
|
||||||
|
%ignore Importer::UnregisterLoader(BaseImporter* pImp);
|
||||||
|
%ignore Importer::RegisterPPStep(BaseProcess* pImp);
|
||||||
|
%ignore Importer::UnregisterPPStep(BaseProcess* pImp);
|
||||||
|
%ignore Importer::FindLoader(const char* szExtension);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Each aiScene has to keep a reference to the Importer to prevent it from
|
||||||
|
// being garbage collected, whose destructor would release the underlying
|
||||||
|
// C++ memory the scene is stored in.
|
||||||
|
%typemap(dcode) aiScene "package Object m_importer;"
|
||||||
|
%typemap(dout)
|
||||||
|
aiScene* GetScene,
|
||||||
|
aiScene* ReadFile,
|
||||||
|
aiScene* ApplyPostProcessing,
|
||||||
|
aiScene* ReadFileFromMemory {
|
||||||
|
void* cPtr = $wcall;
|
||||||
|
$dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode
|
||||||
|
ret.m_importer = this;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
%include "assimp.hpp"
|
Loading…
Reference in New Issue