3 ///////////////////////////////////////////////////////////////////////////////
5 ///////////////////////////////////////////////////////////////////////////////
7 %pybuffer_string(const char *src);
11 using namespace meshio;
14 %include "std_vector.i"
15 %include "std_wstring.i"
16 %include "std_string.i"
18 %include "../include/color.h"
19 %include "../include/la.h"
20 %include "../include/pmd.h"
22 %template(VertexVector) std::vector<meshio::pmd::Vertex>;
23 %template(MaterialVector) std::vector<meshio::pmd::Material*>;
24 %template(BoneVector) std::vector<meshio::pmd::Bone>;
25 %template(IKVector) std::vector<meshio::pmd::IK>;
26 %template(MorphVector) std::vector<meshio::pmd::Morph>;
27 %template(RigidBodyVector) std::vector<meshio::pmd::RigidBody>;
28 %template(ConstraintVector) std::vector<meshio::pmd::Constraint>;
29 %template(UintVector) std::vector<unsigned int>;
30 %template(UshortVector) std::vector<unsigned short>;
31 %template(Vector3Vector) std::vector<meshio::pmd::Vector3>;
32 %template(PBoneVector) std::vector<meshio::pmd::Bone*>;
33 %template(BoneGroupVector) std::vector<meshio::pmd::BoneGroup>;
34 %template(DisplayPair) std::pair<unsigned short, unsigned char>;
35 %template(BoneDisplayVector) std::vector<std::pair<unsigned short, unsigned char> >;
37 ///////////////////////////////////////////////////////////////////////////////
38 // meshio::pmd::IO::each_vertex
39 ///////////////////////////////////////////////////////////////////////////////
41 //! Thin wrapper for ONLY the increment operator
42 void _vertices_incr(std::vector<meshio::pmd::Vertex>::const_iterator* iter)
44 // increment the iterator
49 %extend meshio::pmd::IO {
51 def each_vertex(self):
52 iter = self._beginVertices()
54 vertex = self._dereferenceVertex(iter)
62 //! get the first element in the vector
63 std::vector<meshio::pmd::Vertex>::const_iterator* _beginVertices()
65 return new std::vector<meshio::pmd::Vertex>::const_iterator(
66 ($self->vertices.begin()));
69 //! dereference the iterator; return NULL if at the end
70 const meshio::pmd::Vertex* _dereferenceVertex(
71 const std::vector<meshio::pmd::Vertex>::const_iterator* iter )
73 // if at the end, return NULL
74 if (*iter == ($self)->vertices.end() ) {
77 // otherwise, return the face to which this iterator points
82 ///////////////////////////////////////////////////////////////////////////////
93 ///////////////////////////////////////////////////////////////////////////////
94 %extend meshio::pmd::IO {
96 meshio::pmd::Vertex * addVertex()
98 $self->vertices.push_back(meshio::pmd::Vertex());
99 return &($self->vertices.back());
102 meshio::pmd::Material *addMaterial()
104 $self->materials.push_back(new meshio::pmd::Material);
105 return $self->materials.back();
108 meshio::pmd::Bone *addBone()
110 $self->bones.push_back(meshio::pmd::Bone());
111 return &($self->bones.back());
114 meshio::pmd::Morph *addMorph()
116 $self->morph_list.push_back(meshio::pmd::Morph());
117 return &($self->morph_list.back());
120 meshio::pmd::IK *addIK()
122 $self->ik_list.push_back(meshio::pmd::IK());
123 return &($self->ik_list.back());
126 void addBoneDisplay(unsigned short bone_index, unsigned char display_index)
128 $self->bone_display_list.push_back(
129 std::make_pair(bone_index, display_index));
132 meshio::pmd::BoneGroup *addBoneGroup()
134 $self->bone_group_list.push_back(meshio::pmd::BoneGroup());
135 return &($self->bone_group_list.back());
138 meshio::pmd::ToonTexture *getToonTexture(int index)
140 return &($self->toon_textures[index]);
143 meshio::pmd::RigidBody *addRigidBody()
145 $self->rigidbodies.push_back(meshio::pmd::RigidBody());
146 return &($self->rigidbodies.back());
149 meshio::pmd::Constraint *addConstraint()
151 $self->constraints.push_back(meshio::pmd::Constraint());
152 return &($self->constraints.back());