X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Fvmd.cpp;h=322344d6772fcb0152792c751f610cc92f0eefb2;hb=6f30c5ef957e1775ff7e39a41e1e1aa99864dbd1;hp=1d494baa616af91dcadf16a8724b63d687869c79;hpb=1c78f8bbdfe52be741185762123fba2c169d738a;p=meshio%2Fmeshio.git diff --git a/src/vmd.cpp b/src/vmd.cpp old mode 100644 new mode 100755 index 1d494ba..322344d --- a/src/vmd.cpp +++ b/src/vmd.cpp @@ -12,23 +12,26 @@ struct SortKeyFrameList typedef T MAP; void operator()(typename MAP::value_type &channel) { - channel.second.sort(); + channel.second->sort(); } }; template void - read(READER &reader, IO::BoneMap &channels) + readBoneMap(READER &reader, IO &io) { - std::string name=reader.getString(15); + std::wstring name= + text::trim(text::to_WideChar(CP_OEMCP, reader.getString(15, true))); unsigned int frame=reader.getUint(); - IO::BoneMap::iterator found=channels.find(name); - if(found==channels.end()){ + IO::BoneMap::iterator found=io.boneMap.find(name); + if(found==io.boneMap.end()){ // not found - found=channels.insert( - std::make_pair(name, KeyFrameList())).first; + found=io.boneMap.insert( + std::make_pair(name, + new KeyFrameList >())).first; + io.boneKeys.push_back(name); } - BoneKey &key=found->second.push(frame).key; + BoneKey &key=found->second->push(frame).key; reader.get(key.pos); reader.get(key.q); @@ -40,17 +43,20 @@ template template void - read(READER &reader, IO::MorphMap &channels) + readMorphMap(READER &reader, IO &io) { - std::string name=reader.getString(15); + std::wstring name= + text::trim(text::to_WideChar(CP_OEMCP, reader.getString(15, true))); unsigned int frame=reader.getUint(); - IO::MorphMap::iterator found=channels.find(name); - if(found==channels.end()){ + IO::MorphMap::iterator found=io.morphMap.find(name); + if(found==io.morphMap.end()){ // not found - found=channels.insert( - std::make_pair(name, KeyFrameList())).first; + found=io.morphMap.insert( + std::make_pair(name, + new KeyFrameList >())).first; + io.morphKeys.push_back(name); } - MorphKey &key=found->second.push(frame).key; + MorphKey &key=found->second->push(frame).key; reader.get(key.weight); } @@ -113,7 +119,7 @@ private: { unsigned int count=reader_.getUint(); for(unsigned int i=0; isecond; + } + boneMap.clear(); + + for(MorphMap::iterator it=morphMap.begin(); it!=morphMap.end(); ++it){ + delete it->second; + } + morphMap.clear(); + +} + bool IO::read(binary::IReader &reader) { return Implementation(*this, reader).parse(); } +bool IO::read(const wchar_t *path) +{ + std::vector all; + binary::readAll(path, all); + if(all.empty()){ + return false; + } + binary::MemoryReader reader(&all[0], all.size()); + return read(reader); +} + +bool IO::read(const char *path) +{ + std::vector all; + binary::readAll(path, all); + if(all.empty()){ + return false; + } + binary::MemoryReader reader(&all[0], all.size()); + return read(reader); +} + bool IO::write(std::ostream &os) { return false; } +BoneKeyFrameList* IO::getBoneKeyFrameList(const std::wstring &name) +{ + return boneMap[name]; +} + +MorphKeyFrameList* IO::getMorphKeyFrameList(const std::wstring &name) +{ + return morphMap[name]; +} + } // namespace vmd } // namespace meshio