namespace meshio {
namespace vmd {
-typedef la::Vector2 Vector2;
-typedef la::Vector3 Vector3;
-typedef la::Quaternion Quaternion;
-typedef color::fRGB fRGB;
+typedef ::meshio::la::Vector2 Vector2;
+typedef ::meshio::la::Vector3 Vector3;
+typedef ::meshio::la::Quaternion Quaternion;
+typedef ::meshio::color::fRGB fRGB;
////////////////////////////////////////////////////////////
//! \83\82\81[\83V\83\87\83\93
};
////////////////////////////////////////////////////////////
+//! KeyFrame
+////////////////////////////////////////////////////////////
+template<typename T>
+struct KeyFrame
+{
+ typedef T VALUE_TYPE;
+
+ //! \83t\83\8c\81[\83\80\94Ô\8d\86
+ unsigned int frame;
+ //! \83L\81[
+ T key;
+
+ //! \83t\83\8c\81[\83\80\94Ô\8d\86\82Å\83L\81[\82ð\83\\81[\83g\82·\82é
+ bool operator<(const KeyFrame &rhs)const{ return frame<rhs.frame; }
+};
+
+////////////////////////////////////////////////////////////
//! 1\83`\83\83\83\93\83l\83\8b\95ª\82Ì\83L\81[\83t\83\8c\81[\83\80\82Ì\83\8a\83X\83g\81B
//! \93Ç\82Ý\8d\9e\82ñ\82¾\8cã\82Å\83t\83\8c\81[\83\80\94Ô\8d\86\82Å\83\\81[\83g\82·\82é\81B
////////////////////////////////////////////////////////////
template<typename T>
struct KeyFrameList
{
- struct KeyFrame
- {
- //! \83t\83\8c\81[\83\80\94Ô\8d\86
- unsigned int frame;
- //! \83L\81[
- T key;
-
- //! \83t\83\8c\81[\83\80\94Ô\8d\86\82Å\83L\81[\82ð\83\\81[\83g\82·\82é
- bool operator<(const KeyFrame &rhs)const{ return frame<rhs.frame; }
- };
- std::vector<KeyFrame> list;
+ typedef T KEYFRAME_TYPE;
+
+ std::vector<KEYFRAME_TYPE> list;
void sort(){ std::sort(list.begin(), list.end()); }
- KeyFrame& push(unsigned int frame)
+ KEYFRAME_TYPE& push(unsigned int frame)
{
- list.push_back(KeyFrame());
- KeyFrame &keyFrame=list.back();
+ list.push_back(KEYFRAME_TYPE());
+ KEYFRAME_TYPE &keyFrame=list.back();
keyFrame.frame=frame;
return keyFrame;
}
+ unsigned int getFrame(int index)
+ {
+ return list[index].frame;
+ }
+ typename KEYFRAME_TYPE::VALUE_TYPE* getKey(int index)
+ {
+ return &list[index].key;
+ }
};
////////////////////////////////////////////////////////////
//! IO
////////////////////////////////////////////////////////////
+typedef KeyFrame<BoneKey> BoneKeyFrame;
+typedef KeyFrameList<BoneKeyFrame> BoneKeyFrameList;
+
+typedef KeyFrame<MorphKey> MorphKeyFrame;
+typedef KeyFrameList<MorphKeyFrame> MorphKeyFrameList;
+
struct IO
{
std::string version;
char name[20];
//! \83\82\81[\83V\83\87\83\93
- typedef std::map<std::string, KeyFrameList<BoneKey> > BoneMap;
+ typedef std::map<std::wstring, BoneKeyFrameList*> BoneMap;
BoneMap boneMap;
+ std::vector<std::wstring> boneKeys;
+
//! \95\\8fî
- typedef std::map<std::string, KeyFrameList<MorphKey> > MorphMap;
+ typedef std::map<std::wstring, MorphKeyFrameList*> MorphMap;
MorphMap morphMap;
- //! \83J\83\81\83\89\83\82\81[\83V\83\87\83\93
- typedef std::map<std::string, KeyFrameList<CameraKey> > CameraMap;
- CameraMap cameraKey;
- //! \8fÆ\96¾
- typedef std::map<std::string, KeyFrameList<LightKey> > LightMap;
- LightMap lightMap;
- //! \83Z\83\8b\83t\83V\83\83\83h\81[
- typedef std::map<std::string, KeyFrameList<SelfShadowKey> > SelfShadowMap;
- SelfShadowMap selfShadowMap;
+ std::vector<std::wstring> morphKeys;
IO();
+ ~IO();
bool read(binary::IReader &reader);
+ bool read(const wchar_t *path);
+ bool read(const char *path);
bool write(std::ostream &os);
+
+ BoneKeyFrameList* getBoneKeyFrameList(const std::wstring &name);
+ MorphKeyFrameList* getMorphKeyFrameList(const std::wstring &name);
};
inline std::ostream& operator<<(std::ostream &os, const IO &rhs)
{