X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fpmd.cpp;h=c5ac48f056a4c5aaae3c52edd55bd3a55c12abe5;hb=4b7b856e70fe8047f985e2598020032d0d87a672;hp=5b5e0c2f69d9c11b25bacac76aa931c68bab3b1c;hpb=923502c0cf0c0eaa4461d64c0b7ec621b12f6e32;p=meshio%2Fmeshio.git diff --git a/src/pmd.cpp b/src/pmd.cpp index 5b5e0c2..c5ac48f 100755 --- a/src/pmd.cpp +++ b/src/pmd.cpp @@ -5,20 +5,105 @@ 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 { return text::trim(text::to_WideChar(CP_OEMCP, 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,20 +136,17 @@ std::wstring std::string(name, name+50))); } -std::wstring - IO::getName()const - { - return text::trim(text::to_WideChar(CP_OEMCP, - std::string(name, name+20))); - } +void BoneGroup::setName(const char *src) +{ + strncpy(name, src, 50); +} -std::wstring - IO::getEnglishName()const - { - return text::trim(text::to_WideChar(CP_OEMCP, - std::string(english_name, english_name+20))); - } +void BoneGroup::setEnglishName(const char *src) +{ + strncpy(english_name, src, 50); +} +// RigidBody std::wstring RigidBody::getName()const { @@ -61,6 +154,12 @@ std::wstring std::string(name, name+20))); } +void RigidBody::setName(const char *src) +{ + strncpy(name, src, 20); +} + +// Constraint std::wstring Constraint::getName()const { @@ -68,6 +167,12 @@ std::wstring std::string(name, name+20))); } +void Constraint::setName(const char *src) +{ + strncpy(name, src, 20); +} + +// ToonTexture std::wstring ToonTexture::getName()const { @@ -75,6 +180,12 @@ std::wstring std::string(name, name+100))); } +void ToonTexture::setName(const char *src) +{ + strncpy(name, src, 100); +} + + // 38bytes template void @@ -524,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; } } @@ -668,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); } @@ -780,73 +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 Bone::setEnglishName(const char *src) -{ - strncpy(english_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); -} - -void ToonTexture::setName(const char *src) -{ - strncpy(name, src, 100); -} - } // namespace } // namespace