//! Scene\83`\83\83\83\93\83N
struct Scene
{
- Vector3 pos;
- Vector3 lookat;
+ meshio::Vector3 pos;
+ meshio::Vector3 lookat;
float head;
float pitch;
int ortho;
float zoom2;
- Vector3 ambient;
+ meshio::Vector3 ambient;
Scene()
: head(0), pitch(0), ortho(false), zoom2(2)
{}
{
std::string name;
int shader;
- fRGBA color;
+ meshio::fRGBA color;
float diffuse;
float ambient;
float emit;
unsigned int index_count;
unsigned int indices[4];
unsigned int material_index;
- Vector2 uv[4];
- fRGBA color[4];
+ meshio::Vector2 uv[4];
+ meshio::fRGBA color[4];
Face()
: index_count(0), material_index(0)
{
std::string name;
int depth;
int folding;
- Vector3 scale;
- Vector3 rotation;
- Vector3 translation;
+ meshio::Vector3 scale;
+ meshio::Vector3 rotation;
+ meshio::Vector3 translation;
int visible;
int locking;
int shading;
float smoothing;
- Vector3 color;
+ meshio::Vector3 color;
int color_type;
int mirror;
- std::vector<Vector3> vertices;
+ std::vector<meshio::Vector3> vertices;
std::vector<Face> faces;
Object()
std::vector<Material> materials;
std::vector<Object> objects;
- bool read(binary::IReader &reader);
+ bool read(meshio::binary::IReader &reader);
bool read(const char *path);
- bool write(binary::IWriter &writer);
+ bool write(meshio::binary::IWriter &writer);
bool write(const char *path);
};
#include "binary.h"
#include <ostream>
#include <vector>
+#ifdef _MSC_VER
+#include <boost/array.hpp>
+namespace std {
+ using boost::array;
+}
+#else
#include <array>
+#endif
namespace meshio {
namespace pmd {
struct Vertex
{
//! \8dÀ\95W
- Vector3 pos;
+ meshio::Vector3 pos;
//! \96@\90ü\83x\83N\83g\83\8b
- Vector3 normal;
+ meshio::Vector3 normal;
//! \83e\83N\83X\83`\83\83UV
- Vector2 uv;
+ meshio::Vector2 uv;
//! \83u\83\8c\83\93\83f\83B\83\93\83O\83{\81[\83\931
unsigned short bone0;
//! \83u\83\8c\83\93\83f\83B\83\93\83O\83{\81[\83\932
//! \94ñ\83G\83b\83W
unsigned char edge_flag;
};
+#ifndef SWIG
inline std::ostream &operator<<(std::ostream &os, const Vertex &rhs)
{
os
;
return os;
}
+#endif
////////////////////////////////////////////////////////////
//! \8dÞ\8e¿
struct Material
{
//! Diffuse
- fRGBA diffuse;
+ meshio::fRGBA diffuse;
//! Shinness
float shinness;
//! Specular
- fRGB specular;
+ meshio::fRGB specular;
//! Ambient
- fRGB ambient;
+ meshio::fRGB ambient;
//! \83g\83D\81[\83\93\83e\83N\83X\83`\83\83
unsigned char toon_index;
//! \97Ö\8as/\89e
//! \96Ê\92¸\93_\90\94
unsigned int vertex_count;
//! \83e\83N\83X\83`\83\83
- fixed_string<20> texture;
+ meshio::fixed_string<20> texture;
};
+#ifndef SWIG
inline std::ostream &operator<<(std::ostream &os,
const Material &rhs)
{
;
return os;
}
+#endif
////////////////////////////////////////////////////////////
//! \83{\81[\83\93
struct Bone
{
//! \96¼\91O
- fixed_string<20> name;
+ meshio::fixed_string<20> name;
//! \90e\83{\81[\83\93
unsigned short parent_index;
//! \8eq\83{\81[\83\93
//! \89e\8b¿IK\83{\81[\83\93
unsigned short ik_index;
// \83{\81[\83\93\8dÀ\95W
- Vector3 pos;
+ meshio::Vector3 pos;
//! \89p\8cê\96¼
- fixed_string<20> english_name;
+ meshio::fixed_string<20> english_name;
//! \83{\81[\83\93\8aK\91w\8d\\92z\97p
Bone* parent;
- Vector3 tail;
+ meshio::Vector3 tail;
std::vector<Bone*> children;
unsigned short index;
: parent_index(-1), tail_index(-1), type(BONE_UNKNOWN), ik_index(-1), parent(0), index(-1)
{}
};
+#ifndef SWIG
inline std::ostream &operator<<(std::ostream &os,
const Bone &rhs)
{
;
return os;
}
+#endif
////////////////////////////////////////////////////////////
//! IK
//! \83G\83t\83F\83N\83^\82É\98A\93®\82·\82é\83{\81[\83\93(\8aî\96{\93I\82É\90e\83{\81[\83\93\82É\91k\82é)
std::vector<unsigned short> children;
};
+#ifndef SWIG
inline std::ostream &operator<<(std::ostream &os, const IK &rhs)
{
os
;
return os;
}
+#endif
////////////////////////////////////////////////////////////
//! \95\\8fî
struct Morph
{
//! \95\\8fî\96¼
- fixed_string<20> name;
+ meshio::fixed_string<20> name;
//! \8eg\97p\82·\82é\92¸\93_\90\94
unsigned int vertex_count;
//! \95ª\97Þ
//! \92¸\93_Index
std::vector<unsigned int> indices;
//! \88Ú\93®\97Ê
- std::vector<Vector3> pos_list;
+ std::vector<meshio::Vector3> pos_list;
//! \89p\8cê\96¼
- fixed_string<20> english_name;
+ meshio::fixed_string<20> english_name;
};
+#ifndef SWIG
inline std::ostream &operator<<(std::ostream &os, const Morph &rhs)
{
os
;
return os;
}
+#endif
////////////////////////////////////////////////////////////
//! \83{\81[\83\93\95\\8e¦\98g
////////////////////////////////////////////////////////////
struct BoneGroup
{
- fixed_string<50> name;
- fixed_string<50> english_name;
+ meshio::fixed_string<50> name;
+ meshio::fixed_string<50> english_name;
};
////////////////////////////////////////////////////////////
struct RigidBody
{
//! \8d\84\91Ì\96¼
- fixed_string<20> name;
+ meshio::fixed_string<20> name;
//! \8aÖ\98A\83{\81[\83\93(\83{\81[\83\93\92Ç\8f]\82Æ\83{\81[\83\93\88Ê\92u\8d\87\82í\82¹\82Å\95K\97v)
unsigned short boneIndex;
//! \83O\83\8b\81[\83v
float h;
float d;
//! \8ep\90¨
- Vector3 position;
- Vector3 rotation;
+ meshio::Vector3 position;
+ meshio::Vector3 rotation;
//! \8e¿\97Ê
float weight;
//! \95¨\97\9d\89\89\8eZ\83p\83\89\83\81\81[\83^(bullet)
struct Constraint
{
//! Joint\96¼
- fixed_string<20> name;
+ meshio::fixed_string<20> name;
//! \90Ú\91±\8d\84\91ÌA
unsigned int rigidA;
//! \90Ú\91±\8d\84\91ÌB
unsigned int rigidB;
//! \88Ê\92u
- Vector3 pos;
+ meshio::Vector3 pos;
//! \89ñ\93]
- Vector3 rot;
+ meshio::Vector3 rot;
//! \88Ú\93®\90§\8cÀ
- Vector3 constraintPosMin;
- Vector3 constraintPosMax;
+ meshio::Vector3 constraintPosMin;
+ meshio::Vector3 constraintPosMax;
//! \89ñ\93]\90§\8cÀ
- Vector3 constraintRotMin;
- Vector3 constraintRotMax;
+ meshio::Vector3 constraintRotMin;
+ meshio::Vector3 constraintRotMax;
//! \82Î\82Ë
- Vector3 springPos;
- Vector3 springRot;
+ meshio::Vector3 springPos;
+ meshio::Vector3 springRot;
};
struct IO
{
float version;
- fixed_string<20> name;
- fixed_string<256> comment;
+ meshio::fixed_string<20> name;
+ meshio::fixed_string<256> comment;
std::vector<Vertex> vertices;
std::vector<unsigned short> indices;
std::vector<Material> materials;
std::vector<unsigned short> face_list;
std::vector<BoneGroup> bone_group_list;
std::vector<std::pair<unsigned short, unsigned char> > bone_display_list;
- std::array<fixed_string<100>, 10> toon_textures;
+ std::array<meshio::fixed_string<100>, 10> toon_textures;
std::vector<RigidBody> rigidbodies;
std::vector<Constraint> constraints;
- fixed_string<20> english_name;
- fixed_string<256> english_comment;
+ meshio::fixed_string<20> english_name;
+ meshio::fixed_string<256> english_comment;
IO();
bool read(const char *path);
bool write(const char *path);
- bool read(binary::IReader &reader);
- bool write(binary::IWriter &writer);
+ bool read(meshio::binary::IReader &reader);
+ bool write(meshio::binary::IWriter &writer);
};
+#ifndef SWIG
inline std::ostream &operator<<(std::ostream &os, const IO &rhs)
{
os
;
return os;
}
+#endif
} // namespace pmd
return *this;
}
};
+#ifndef SWIG
inline std::ostream &operator<<(std::ostream &os, const cstr &rhs)
{
return os << rhs.str();
}
+#endif
template<int LENGTH>
class fixed_string
if(src.empty()){
return;
}
- auto it=src.begin();
- for(int i=0; i<LENGTH && *it; ++i, ++it, ++end_){
+ std::string::const_iterator it=src.begin();
+ int i;
+ for(i=0;
+ i<LENGTH && it!=src.end();
+ ++i, ++it)
+ {
begin_[i]=*it;
}
- if(std::distance(
- static_cast<char*>(begin_),
- static_cast<char*>(end_))<LENGTH)
+ if(i<LENGTH)
{
- *end_='\0';
+ begin_[i]='\0';
}
}
size_t size()const { return LENGTH; }
const char *begin() const { return begin_; }
std::string str() const
{
- auto end=begin_;
+ const char *end=begin_;
for(; end!=end_ && *end!='\0'; ++end){
}
return std::string(
static_cast<const char*>(end));
}
};
+#ifndef SWIG
template<int LENGTH>
inline std::ostream &operator<<(std::ostream &os, const fixed_string<LENGTH> &rhs)
{
return os << rhs.str();
}
+#endif
-#ifdef _WIN32
+#if defined(_WIN32) || defined(_MSC_VER)
inline std::wstring to_WideChar(UINT uCodePage, const std::string &text)
{
int size=MultiByteToWideChar(uCodePage, 0, text.c_str(), -1, NULL, 0);
{
return to_unicode(text.c_str(), "CP932");
}
-
#endif
inline std::wstring trim(const std::wstring &src){
+BOOST_ROOT='C:/boost/boost_1_46_1'
+
# swig -c++ -python -o mqo_wrap.cxx ../mqo.i
# swig -c++ -python -o pmd_wrap.cxx ../pmd.i
import os
from distutils.core import setup, Extension
if os.name=='nt':
- extra_compile_args=[]
+ # for vc
+ extra_compile_args=["/EHsc", "/wd4996"]
+ libraries=[]
+ include_dirs=['../../src', BOOST_ROOT]
else:
extra_compile_args=['-std=c++0x']
+ libraries=["iconv"]
+ include_dirs=['../../src']
setup(
name='meshio',
version='1.0',
description='3D mesh IO library',
py_modules=["__init__", "mqo", "pmd"],
+
ext_modules = [
Extension("_mqo",
language="c++",
- sources=["mqo_wrap.cxx"],
- include_dirs=["../../src"],
+ sources=["mqo_wrap.cxx", "../../src/mqo.cpp", "../../src/binary.cpp"],
+ include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
- library_dirs=["../../debug"],
- libraries=["meshio"]
+ libraries=libraries
),
+
Extension("_pmd",
language="c++",
- sources=["pmd_wrap.cxx"],
- include_dirs=["../../src"],
+ sources=["pmd_wrap.cxx", "../../src/pmd.cpp", "../../src/binary.cpp"],
+ include_dirs=include_dirs,
extra_compile_args=extra_compile_args,
- library_dirs=["../../debug"],
- libraries=["meshio"]
+ libraries=libraries
),
]
)