From 60bdcc7dc4e1bec28341c5324703c029cd86e31e Mon Sep 17 00:00:00 2001 From: asCeo Date: Wed, 23 Feb 2022 21:03:32 +0800 Subject: [PATCH 1/3] Update Vmd.h --- MikuMikuFormats/Vmd.h | 57 ++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/MikuMikuFormats/Vmd.h b/MikuMikuFormats/Vmd.h index 4a4f6e7..cfd0107 100644 --- a/MikuMikuFormats/Vmd.h +++ b/MikuMikuFormats/Vmd.h @@ -1,15 +1,11 @@ #pragma once - #include #include #include #include #include #include - -namespace vmd -{ - /// ボーンフレーム +namespace vmd{ class VmdBoneFrame { public: @@ -49,11 +45,8 @@ namespace vmd class VmdFaceFrame { public: - /// 表情名 std::string face_name; - /// 表情の重み float weight; - /// フレーム番号 uint32_t frame; void Read(std::istream* stream) @@ -73,7 +66,6 @@ namespace vmd } }; - /// カメラフレーム class VmdCameraFrame { public: @@ -85,12 +77,12 @@ namespace vmd float position[3]; /// 回転 float orientation[3]; - /// 補間曲線 + char interpolation[6][4]; - /// 視野角 - float angle; - /// 不明データ - char unknown[3]; + + int angle; + + uint8_t isPerspective; void Read(std::istream *stream) { @@ -99,8 +91,8 @@ namespace vmd stream->read((char*) position, sizeof(float) * 3); stream->read((char*) orientation, sizeof(float) * 3); stream->read((char*) interpolation, sizeof(char) * 24); - stream->read((char*) &angle, sizeof(float)); - stream->read((char*) unknown, sizeof(char) * 3); + stream->read((char*) &angle, sizeof(int)); + stream->read((char*) &isPerspective, sizeof(char) ); } void Write(std::ostream *stream) @@ -110,20 +102,20 @@ namespace vmd stream->write((char*)position, sizeof(float) * 3); stream->write((char*)orientation, sizeof(float) * 3); stream->write((char*)interpolation, sizeof(char) * 24); - stream->write((char*)&angle, sizeof(float)); - stream->write((char*)unknown, sizeof(char) * 3); + stream->write((char*)&angle, sizeof(int)); + stream->write((char*)&isPerspective, sizeof(char)); } }; - /// ライトフレーム + class VmdLightFrame { public: - /// フレーム番号 + int frame; - /// 色 + float color[3]; - /// 位置 + float position[3]; void Read(std::istream* stream) @@ -141,7 +133,7 @@ namespace vmd } }; - /// IKの有効無効 + class VmdIkEnable { public: @@ -188,26 +180,19 @@ namespace vmd } }; - /// VMDモーション + class VmdMotion { public: - /// モデル名 std::string model_name; - /// バージョン int version; - /// ボーンフレーム std::vector bone_frames; - /// 表情フレーム std::vector face_frames; - /// カメラフレーム std::vector camera_frames; - /// ライトフレーム std::vector light_frames; - /// IKフレーム std::vector ik_frames; - static std::unique_ptr LoadFromFile(char const *filename) + static std::shared_ptr LoadFromFile(char const *filename) { std::ifstream stream(filename, std::ios::binary); auto result = LoadFromStream(&stream); @@ -215,11 +200,11 @@ namespace vmd return result; } - static std::unique_ptr LoadFromStream(std::ifstream *stream) + static std::shared_ptr LoadFromStream(std::ifstream *stream) { char buffer[30]; - auto result = std::make_unique(); + auto result = std::make_shared(); // magic and version stream->read((char*) buffer, 30); @@ -293,7 +278,7 @@ namespace vmd return result; } - bool SaveToFile(const std::u16string& filename) + bool SaveToFile(const std::wstring& filename) { std::ofstream stream(filename.c_str(), std::ios::binary); auto result = SaveToStream(&stream); @@ -359,4 +344,4 @@ namespace vmd return true; } }; -} \ No newline at end of file +} From dc37b85e3994aa35f8055aeb46651e89cfa1452a Mon Sep 17 00:00:00 2001 From: axilesoft Date: Wed, 23 Feb 2022 21:11:02 +0800 Subject: [PATCH 2/3] Revert "Update Vmd.h" This reverts commit 60bdcc7dc4e1bec28341c5324703c029cd86e31e. --- MikuMikuFormats/Vmd.h | 57 +++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/MikuMikuFormats/Vmd.h b/MikuMikuFormats/Vmd.h index cfd0107..4a4f6e7 100644 --- a/MikuMikuFormats/Vmd.h +++ b/MikuMikuFormats/Vmd.h @@ -1,11 +1,15 @@ #pragma once + #include #include #include #include #include #include -namespace vmd{ + +namespace vmd +{ + /// ボーンフレーム class VmdBoneFrame { public: @@ -45,8 +49,11 @@ namespace vmd{ class VmdFaceFrame { public: + /// 表情名 std::string face_name; + /// 表情の重み float weight; + /// フレーム番号 uint32_t frame; void Read(std::istream* stream) @@ -66,6 +73,7 @@ namespace vmd{ } }; + /// カメラフレーム class VmdCameraFrame { public: @@ -77,12 +85,12 @@ namespace vmd{ float position[3]; /// 回転 float orientation[3]; - + /// 補間曲線 char interpolation[6][4]; - - int angle; - - uint8_t isPerspective; + /// 視野角 + float angle; + /// 不明データ + char unknown[3]; void Read(std::istream *stream) { @@ -91,8 +99,8 @@ namespace vmd{ stream->read((char*) position, sizeof(float) * 3); stream->read((char*) orientation, sizeof(float) * 3); stream->read((char*) interpolation, sizeof(char) * 24); - stream->read((char*) &angle, sizeof(int)); - stream->read((char*) &isPerspective, sizeof(char) ); + stream->read((char*) &angle, sizeof(float)); + stream->read((char*) unknown, sizeof(char) * 3); } void Write(std::ostream *stream) @@ -102,20 +110,20 @@ namespace vmd{ stream->write((char*)position, sizeof(float) * 3); stream->write((char*)orientation, sizeof(float) * 3); stream->write((char*)interpolation, sizeof(char) * 24); - stream->write((char*)&angle, sizeof(int)); - stream->write((char*)&isPerspective, sizeof(char)); + stream->write((char*)&angle, sizeof(float)); + stream->write((char*)unknown, sizeof(char) * 3); } }; - + /// ライトフレーム class VmdLightFrame { public: - + /// フレーム番号 int frame; - + /// 色 float color[3]; - + /// 位置 float position[3]; void Read(std::istream* stream) @@ -133,7 +141,7 @@ namespace vmd{ } }; - + /// IKの有効無効 class VmdIkEnable { public: @@ -180,19 +188,26 @@ namespace vmd{ } }; - + /// VMDモーション class VmdMotion { public: + /// モデル名 std::string model_name; + /// バージョン int version; + /// ボーンフレーム std::vector bone_frames; + /// 表情フレーム std::vector face_frames; + /// カメラフレーム std::vector camera_frames; + /// ライトフレーム std::vector light_frames; + /// IKフレーム std::vector ik_frames; - static std::shared_ptr LoadFromFile(char const *filename) + static std::unique_ptr LoadFromFile(char const *filename) { std::ifstream stream(filename, std::ios::binary); auto result = LoadFromStream(&stream); @@ -200,11 +215,11 @@ namespace vmd{ return result; } - static std::shared_ptr LoadFromStream(std::ifstream *stream) + static std::unique_ptr LoadFromStream(std::ifstream *stream) { char buffer[30]; - auto result = std::make_shared(); + auto result = std::make_unique(); // magic and version stream->read((char*) buffer, 30); @@ -278,7 +293,7 @@ namespace vmd{ return result; } - bool SaveToFile(const std::wstring& filename) + bool SaveToFile(const std::u16string& filename) { std::ofstream stream(filename.c_str(), std::ios::binary); auto result = SaveToStream(&stream); @@ -344,4 +359,4 @@ namespace vmd{ return true; } }; -} +} \ No newline at end of file From 90cae26a7f17a6e07f8a70cfd2e94ca9fcb47a25 Mon Sep 17 00:00:00 2001 From: asCeo Date: Wed, 23 Feb 2022 21:12:32 +0800 Subject: [PATCH 3/3] Update Vmd.h --- MikuMikuFormats/Vmd.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/MikuMikuFormats/Vmd.h b/MikuMikuFormats/Vmd.h index 4a4f6e7..937f204 100644 --- a/MikuMikuFormats/Vmd.h +++ b/MikuMikuFormats/Vmd.h @@ -88,9 +88,9 @@ namespace vmd /// 補間曲線 char interpolation[6][4]; /// 視野角 - float angle; - /// 不明データ - char unknown[3]; + int angle; + + uint8_t isPerspective; void Read(std::istream *stream) { @@ -99,8 +99,8 @@ namespace vmd stream->read((char*) position, sizeof(float) * 3); stream->read((char*) orientation, sizeof(float) * 3); stream->read((char*) interpolation, sizeof(char) * 24); - stream->read((char*) &angle, sizeof(float)); - stream->read((char*) unknown, sizeof(char) * 3); + stream->read((char*) &angle, sizeof(int)); + stream->read((char*) &isPerspective, sizeof(char) ); } void Write(std::ostream *stream) @@ -110,8 +110,8 @@ namespace vmd stream->write((char*)position, sizeof(float) * 3); stream->write((char*)orientation, sizeof(float) * 3); stream->write((char*)interpolation, sizeof(char) * 24); - stream->write((char*)&angle, sizeof(float)); - stream->write((char*)unknown, sizeof(char) * 3); + stream->write((char*)&angle, sizeof(int)); + stream->write((char*)&isPerspective, sizeof(char)); } }; @@ -359,4 +359,4 @@ namespace vmd return true; } }; -} \ No newline at end of file +}