X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fpmd.cpp;h=c5ac48f056a4c5aaae3c52edd55bd3a55c12abe5;hb=4b7b856e70fe8047f985e2598020032d0d87a672;hp=6155e13d32b356be34786aa7bda574a3e415f7dd;hpb=1dc10e62bc1226d596b1616a12e4d5a66241559d;p=meshio%2Fmeshio.git diff --git a/src/pmd.cpp b/src/pmd.cpp index 6155e13..c5ac48f 100755 --- a/src/pmd.cpp +++ b/src/pmd.cpp @@ -5,13 +5,87 @@ namespace meshio { namespace pmd { +// IO +bool IO::write(const char *path) +{ + binary::FileWriter w(path); + return write(w); +} + +bool IO::write(const wchar_t *path) +{ + binary::FileWriter w(path); + return write(w); +} + std::wstring - Material::getTexture()const - { - return text::trim(text::to_WideChar(CP_OEMCP, - std::string(texture, texture+20))); - } +IO::getName()const +{ + return text::trim(text::to_WideChar(CP_OEMCP, + std::string(name, name+20))); +} + +std::wstring +IO::getComment()const +{ + return text::trim(text::to_WideChar(CP_OEMCP, + std::string(comment, comment+256))); +} + +std::wstring +IO::getEnglishName()const +{ + return text::trim(text::to_WideChar(CP_OEMCP, + std::string(english_name, english_name+20))); +} + +std::wstring +IO::getEnglishComment()const +{ + return text::trim(text::to_WideChar(CP_OEMCP, + std::string(english_comment, english_comment+256))); +} + +const Vector2* IO::getUV(int index)const +{ + return &vertices[index].uv; +} + +void IO::setName(const char *src) +{ + strncpy(name, src, 20); +} + +void IO::setComment(const char *src) +{ + strncpy(comment, src, 256); +} +void IO::setEnglishName(const char *src) +{ + strncpy(english_name, src, 20); +} + +void IO::setEnglishComment(const char *src) +{ + strncpy(english_comment, src, 256); +} + + +// Material +std::wstring +Material::getTexture()const +{ + return text::trim(text::to_WideChar(CP_OEMCP, + std::string(texture, texture+20))); +} + +void Material::setTexture(const char *src) +{ + strncpy(texture, src, 20); +} + +// Bone std::wstring Bone::getName()const { @@ -19,6 +93,17 @@ std::wstring std::string(name, name+20))); } +void Bone::setName(const char *src) +{ + strncpy(name, src, 20); +} + +void Bone::setEnglishName(const char *src) +{ + strncpy(english_name, src, 20); +} + +// Morph std::wstring Morph::getName()const { @@ -33,6 +118,17 @@ void pos_list.push_back(Vector3(x, y, z)); } +void Morph::setName(const char *src) +{ + strncpy(name, src, 20); +} + +void Morph::setEnglishName(const char *src) +{ + strncpy(english_name, src, 20); +} + +// BoneGroup std::wstring BoneGroup::getName()const { @@ -40,34 +136,56 @@ std::wstring std::string(name, name+50))); } +void BoneGroup::setName(const char *src) +{ + strncpy(name, src, 50); +} + +void BoneGroup::setEnglishName(const char *src) +{ + strncpy(english_name, src, 50); +} + +// RigidBody std::wstring - IO::getName()const + RigidBody::getName()const { return text::trim(text::to_WideChar(CP_OEMCP, std::string(name, name+20))); } -std::wstring - IO::getEnglishName()const - { - return text::trim(text::to_WideChar(CP_OEMCP, - std::string(english_name, english_name+20))); - } +void RigidBody::setName(const char *src) +{ + strncpy(name, src, 20); +} +// Constraint std::wstring - RigidBody::getName()const + Constraint::getName()const { return text::trim(text::to_WideChar(CP_OEMCP, std::string(name, name+20))); } +void Constraint::setName(const char *src) +{ + strncpy(name, src, 20); +} + +// ToonTexture std::wstring - Constraint::getName()const + ToonTexture::getName()const { return text::trim(text::to_WideChar(CP_OEMCP, - std::string(name, name+20))); + std::string(name, name+100))); } +void ToonTexture::setName(const char *src) +{ + strncpy(name, src, 100); +} + + // 38bytes template void @@ -313,7 +431,9 @@ private: bool parseToonTextures() { for(size_t i=0; i<10; ++i){ - reader_.getString(100); + text::copyStringAndFillZero( + io_.toon_textures[i].name, + reader_.getString(100)); } return true; } @@ -515,7 +635,10 @@ bool IO::read(binary::IReader &input) bone.parent=&bones[bone.parent_index]; bone.parent->children.push_back(&bone); } - if(bone.tail_index!=0){ + if(bone.tail_index==0){ + bone.tail=Vector3(0, 0, 0); + } + else{ bone.tail=bones[bone.tail_index].pos; } } @@ -659,7 +782,7 @@ bool IO::write(binary::IWriter &w) w.writeArray(&face_list[0], face_list.size()); } - // bone naem list + // bone name list //std::cout << "bone name list" << std::endl; w.writeValue(bone_group_list.size()); for(size_t i=0; i(bones[i].english_name, 20); } + // skip base for(size_t i=1; i(morph_list[i].english_name, 20); } @@ -771,63 +895,6 @@ bool IO::write(binary::IWriter &w) return true; } -bool IO::write(const char *path) -{ - binary::FileWriter w(path); - return write(w); -} - -bool IO::write(const wchar_t *path) -{ - binary::FileWriter w(path); - return write(w); -} - -const Vector2* IO::getUV(int index)const -{ - return &vertices[index].uv; -} - -void Bone::setName(const char *src) -{ - strncpy(name, src, 20); -} - -void BoneGroup::setName(const char *src) -{ - strncpy(name, src, 20); -} - -void BoneGroup::setEnglishName(const char *src) -{ - strncpy(english_name, src, 20); -} - -void Morph::setName(const char *src) -{ - strncpy(name, src, 20); -} - -void Morph::setEnglishName(const char *src) -{ - strncpy(english_name, src, 20); -} - -void RigidBody::setName(const char *src) -{ - strncpy(name, src, 20); -} - -void Constraint::setName(const char *src) -{ - strncpy(name, src, 20); -} - -void Material::setTexture(const char *src) -{ - strncpy(texture, src, 20); -} - } // namespace } // namespace