10 struct SortKeyFrameList
13 void operator()(typename MAP::value_type &channel)
15 channel.second.sort();
19 template<class READER>
21 read(READER &reader, IO::BoneMap &channels)
23 std::string name=reader.getString(15);
24 unsigned int frame=reader.getUint();
25 IO::BoneMap::iterator found=channels.find(name);
26 if(found==channels.end()){
28 found=channels.insert(
29 std::make_pair(name, KeyFrameList<BoneKey>())).first;
31 BoneKey &key=found->second.push(frame).key;
35 reader.get(key.interpolationX);
36 reader.get(key.interpolationY);
37 reader.get(key.interpolationZ);
38 reader.get(key.interpolationRot);
41 template<class READER>
43 read(READER &reader, IO::MorphMap &channels)
45 std::string name=reader.getString(15);
46 unsigned int frame=reader.getUint();
47 IO::MorphMap::iterator found=channels.find(name);
48 if(found==channels.end()){
50 found=channels.insert(
51 std::make_pair(name, KeyFrameList<MorphKey>())).first;
53 MorphKey &key=found->second.push(frame).key;
55 reader.get(key.weight);
61 binary::IReader &reader_;
64 Implementation(IO &io, binary::IReader &reader)
65 : io_(io), reader_(reader)
71 std::string line=reader_.getString(30, true);
72 if(line=="Vocaloid Motion Data file"){
74 text::copyStringAndFillZero(io_.name, reader_.getString(10));
77 else if(line=="Vocaloid Motion Data 0002"){
79 text::copyStringAndFillZero(io_.name, reader_.getString(20));
83 //std::cout << "unknown header:" << line << std::endl;
105 std::for_each(io_.boneMap.begin(), io_.boneMap.end(),
106 SortKeyFrameList<IO::BoneMap>());
107 std::for_each(io_.morphMap.begin(), io_.morphMap.end(),
108 SortKeyFrameList<IO::MorphMap>());
114 unsigned int count=reader_.getUint();
115 for(unsigned int i=0; i<count; ++i){
116 read(reader_, io_.morphMap);
123 unsigned int count=reader_.getUint();
124 for(unsigned int i=0; i<count; ++i){
125 read(reader_, io_.boneMap);
142 ///////////////////////////////////////////////////////////////////////////////
144 ///////////////////////////////////////////////////////////////////////////////
149 bool IO::read(binary::IReader &reader)
151 return Implementation(*this, reader).parse();
154 bool IO::write(std::ostream &os)
160 } // namespace meshio