OSDN Git Service

separate vertex with uv or normal.
[meshio/meshio.git] / swig / pmd.i
index 0547d37..f858e8b 100644 (file)
@@ -1,4 +1,11 @@
 %module pmd
+
+///////////////////////////////////////////////////////////////////////////////
+// bytearray typemap
+///////////////////////////////////////////////////////////////////////////////
+%include <pybuffer.i>
+%pybuffer_string(const char *src);
+
 %{
 #include <pmd.h>
 using namespace meshio;
@@ -6,6 +13,8 @@ using namespace pmd;
 %}
 %include "std_vector.i"
 %include "std_wstring.i"
+%include "std_string.i"
+%include "std_pair.i"
 %include "../include/color.h"
 %include "../include/la.h"
 %include "../include/pmd.h"
@@ -21,9 +30,12 @@ using namespace pmd;
 %template(UshortVector) std::vector<unsigned short>;
 %template(Vector3Vector) std::vector<meshio::pmd::Vector3>;
 %template(PBoneVector) std::vector<meshio::pmd::Bone*>;
+%template(BoneGroupVector) std::vector<meshio::pmd::BoneGroup>;
+%template(DisplayPair) std::pair<unsigned short, unsigned char>;
+%template(BoneDisplayVector) std::vector<std::pair<unsigned short, unsigned char> >;
 
 ///////////////////////////////////////////////////////////////////////////////
-// vertices
+// meshio::pmd::IO::each_vertex
 ///////////////////////////////////////////////////////////////////////////////
 %inline %{
 //! Thin wrapper for ONLY the increment operator
@@ -67,3 +79,78 @@ const meshio::pmd::Vertex* _dereferenceVertex(
 }
 }
 
+///////////////////////////////////////////////////////////////////////////////
+// addVertex
+// addMaterial
+// addBone
+// addMorph
+// addIK
+// addBoneDisplay
+// addBoneGroup
+// getToonTexture
+// addRigidBody
+// addConstraint
+///////////////////////////////////////////////////////////////////////////////
+%extend meshio::pmd::IO {
+
+meshio::pmd::Vertex * addVertex()
+{
+    $self->vertices.push_back(meshio::pmd::Vertex());
+    return &($self->vertices.back());
+}
+
+meshio::pmd::Material *addMaterial()
+{
+    $self->materials.push_back(new meshio::pmd::Material);
+    return $self->materials.back();
+}
+
+meshio::pmd::Bone *addBone()
+{
+    $self->bones.push_back(meshio::pmd::Bone());
+    return &($self->bones.back());
+}
+
+meshio::pmd::Morph *addMorph()
+{
+    $self->morph_list.push_back(meshio::pmd::Morph());
+    return &($self->morph_list.back());
+}
+
+meshio::pmd::IK *addIK()
+{
+    $self->ik_list.push_back(meshio::pmd::IK());
+    return &($self->ik_list.back());
+}
+
+void addBoneDisplay(unsigned short bone_index, unsigned char display_index)
+{
+    $self->bone_display_list.push_back(
+            std::make_pair(bone_index, display_index));
+}
+
+meshio::pmd::BoneGroup *addBoneGroup()
+{
+    $self->bone_group_list.push_back(meshio::pmd::BoneGroup());
+    return &($self->bone_group_list.back());
+}
+
+meshio::pmd::ToonTexture *getToonTexture(int index)
+{
+    return &($self->toon_textures[index]);
+}
+
+meshio::pmd::RigidBody *addRigidBody()
+{
+    $self->rigidbodies.push_back(meshio::pmd::RigidBody());
+    return &($self->rigidbodies.back());
+}
+
+meshio::pmd::Constraint *addConstraint()
+{
+    $self->constraints.push_back(meshio::pmd::Constraint());
+    return &($self->constraints.back());
+}
+
+}
+