MDP: fix encoding issues.
parent
b5f770e456
commit
6a3b030094
|
@ -49,17 +49,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace pmd
|
namespace pmd
|
||||||
{
|
{
|
||||||
/// ヘッダ
|
|
||||||
class PmdHeader
|
class PmdHeader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// モデル名
|
|
||||||
std::string name;
|
std::string name;
|
||||||
/// モデル名(英語)
|
|
||||||
std::string name_english;
|
std::string name_english;
|
||||||
/// コメント
|
|
||||||
std::string comment;
|
std::string comment;
|
||||||
/// コメント(英語)
|
|
||||||
std::string comment_english;
|
std::string comment_english;
|
||||||
|
|
||||||
bool Read(std::ifstream* stream)
|
bool Read(std::ifstream* stream)
|
||||||
|
@ -83,26 +78,19 @@ namespace pmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 頂点
|
|
||||||
class PmdVertex
|
class PmdVertex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
|
|
||||||
/// 法線
|
|
||||||
float normal[3];
|
float normal[3];
|
||||||
|
|
||||||
/// UV座標
|
|
||||||
float uv[2];
|
float uv[2];
|
||||||
|
|
||||||
/// 関連ボーンインデックス
|
|
||||||
uint16_t bone_index[2];
|
uint16_t bone_index[2];
|
||||||
|
|
||||||
/// ボーンウェイト
|
|
||||||
uint8_t bone_weight;
|
uint8_t bone_weight;
|
||||||
|
|
||||||
/// エッジ不可視
|
|
||||||
bool edge_invisible;
|
bool edge_invisible;
|
||||||
|
|
||||||
bool Read(std::ifstream* stream)
|
bool Read(std::ifstream* stream)
|
||||||
|
@ -117,27 +105,17 @@ namespace pmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 材質
|
|
||||||
class PmdMaterial
|
class PmdMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// 減衰色
|
|
||||||
float diffuse[4];
|
float diffuse[4];
|
||||||
/// 光沢度
|
|
||||||
float power;
|
float power;
|
||||||
/// 光沢色
|
|
||||||
float specular[3];
|
float specular[3];
|
||||||
/// 環境色
|
|
||||||
float ambient[3];
|
float ambient[3];
|
||||||
/// トーンインデックス
|
|
||||||
uint8_t toon_index;
|
uint8_t toon_index;
|
||||||
/// エッジ
|
|
||||||
uint8_t edge_flag;
|
uint8_t edge_flag;
|
||||||
/// インデックス数
|
|
||||||
uint32_t index_count;
|
uint32_t index_count;
|
||||||
/// テクスチャファイル名
|
|
||||||
std::string texture_filename;
|
std::string texture_filename;
|
||||||
/// スフィアファイル名
|
|
||||||
std::string sphere_filename;
|
std::string sphere_filename;
|
||||||
|
|
||||||
bool Read(std::ifstream* stream)
|
bool Read(std::ifstream* stream)
|
||||||
|
@ -180,23 +158,15 @@ namespace pmd
|
||||||
RotationMovement
|
RotationMovement
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ボーン
|
|
||||||
class PmdBone
|
class PmdBone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// ボーン名
|
|
||||||
std::string name;
|
std::string name;
|
||||||
/// ボーン名(英語)
|
|
||||||
std::string name_english;
|
std::string name_english;
|
||||||
/// 親ボーン番号
|
|
||||||
uint16_t parent_bone_index;
|
uint16_t parent_bone_index;
|
||||||
/// 末端ボーン番号
|
|
||||||
uint16_t tail_pos_bone_index;
|
uint16_t tail_pos_bone_index;
|
||||||
/// ボーン種類
|
|
||||||
BoneType bone_type;
|
BoneType bone_type;
|
||||||
/// IKボーン番号
|
|
||||||
uint16_t ik_parent_bone_index;
|
uint16_t ik_parent_bone_index;
|
||||||
/// ボーンのヘッドの位置
|
|
||||||
float bone_head_pos[3];
|
float bone_head_pos[3];
|
||||||
|
|
||||||
void Read(std::istream *stream)
|
void Read(std::istream *stream)
|
||||||
|
@ -219,19 +189,13 @@ namespace pmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// IK
|
|
||||||
class PmdIk
|
class PmdIk
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// IKボーン番号
|
|
||||||
uint16_t ik_bone_index;
|
uint16_t ik_bone_index;
|
||||||
/// IKターゲットボーン番号
|
|
||||||
uint16_t target_bone_index;
|
uint16_t target_bone_index;
|
||||||
/// 再帰回数
|
|
||||||
uint16_t interations;
|
uint16_t interations;
|
||||||
/// 角度制限
|
|
||||||
float angle_limit;
|
float angle_limit;
|
||||||
/// 影響下ボーン番号
|
|
||||||
std::vector<uint16_t> ik_child_bone_index;
|
std::vector<uint16_t> ik_child_bone_index;
|
||||||
|
|
||||||
void Read(std::istream *stream)
|
void Read(std::istream *stream)
|
||||||
|
@ -303,7 +267,6 @@ namespace pmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ボーン枠用の枠名
|
|
||||||
class PmdBoneDispName
|
class PmdBoneDispName
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -338,59 +301,36 @@ namespace pmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 衝突形状
|
|
||||||
enum class RigidBodyShape : uint8_t
|
enum class RigidBodyShape : uint8_t
|
||||||
{
|
{
|
||||||
/// 球
|
|
||||||
Sphere = 0,
|
Sphere = 0,
|
||||||
/// 直方体
|
|
||||||
Box = 1,
|
Box = 1,
|
||||||
/// カプセル
|
|
||||||
Cpusel = 2
|
Cpusel = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 剛体タイプ
|
|
||||||
enum class RigidBodyType : uint8_t
|
enum class RigidBodyType : uint8_t
|
||||||
{
|
{
|
||||||
/// ボーン追従
|
|
||||||
BoneConnected = 0,
|
BoneConnected = 0,
|
||||||
/// 物理演算
|
|
||||||
Physics = 1,
|
Physics = 1,
|
||||||
/// 物理演算(Bone位置合せ)
|
|
||||||
ConnectedPhysics = 2
|
ConnectedPhysics = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 剛体
|
|
||||||
class PmdRigidBody
|
class PmdRigidBody
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// 名前
|
|
||||||
std::string name;
|
std::string name;
|
||||||
/// 関連ボーン番号
|
|
||||||
uint16_t related_bone_index;
|
uint16_t related_bone_index;
|
||||||
/// グループ番号
|
|
||||||
uint8_t group_index;
|
uint8_t group_index;
|
||||||
/// マスク
|
|
||||||
uint16_t mask;
|
uint16_t mask;
|
||||||
/// 形状
|
|
||||||
RigidBodyShape shape;
|
RigidBodyShape shape;
|
||||||
/// 大きさ
|
|
||||||
float size[3];
|
float size[3];
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
/// 回転
|
|
||||||
float orientation[3];
|
float orientation[3];
|
||||||
/// 質量
|
|
||||||
float weight;
|
float weight;
|
||||||
/// 移動ダンピング
|
|
||||||
float linear_damping;
|
float linear_damping;
|
||||||
/// 回転ダンピング
|
|
||||||
float anglar_damping;
|
float anglar_damping;
|
||||||
/// 反発係数
|
|
||||||
float restitution;
|
float restitution;
|
||||||
/// 摩擦係数
|
|
||||||
float friction;
|
float friction;
|
||||||
/// 演算方法
|
|
||||||
RigidBodyType rigid_type;
|
RigidBodyType rigid_type;
|
||||||
|
|
||||||
void Read(std::istream *stream)
|
void Read(std::istream *stream)
|
||||||
|
@ -414,31 +354,19 @@ namespace pmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 剛体の拘束
|
|
||||||
class PmdConstraint
|
class PmdConstraint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// 名前
|
|
||||||
std::string name;
|
std::string name;
|
||||||
/// 剛体Aのインデックス
|
|
||||||
uint32_t rigid_body_index_a;
|
uint32_t rigid_body_index_a;
|
||||||
/// 剛体Bのインデックス
|
|
||||||
uint32_t rigid_body_index_b;
|
uint32_t rigid_body_index_b;
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
/// 回転
|
|
||||||
float orientation[3];
|
float orientation[3];
|
||||||
/// 最小移動制限
|
|
||||||
float linear_lower_limit[3];
|
float linear_lower_limit[3];
|
||||||
/// 最大移動制限
|
|
||||||
float linear_upper_limit[3];
|
float linear_upper_limit[3];
|
||||||
/// 最小回転制限
|
|
||||||
float angular_lower_limit[3];
|
float angular_lower_limit[3];
|
||||||
/// 最大回転制限
|
|
||||||
float angular_upper_limit[3];
|
float angular_upper_limit[3];
|
||||||
/// 移動に対する復元力
|
|
||||||
float linear_stiffness[3];
|
float linear_stiffness[3];
|
||||||
/// 回転に対する復元力
|
|
||||||
float angular_stiffness[3];
|
float angular_stiffness[3];
|
||||||
|
|
||||||
void Read(std::istream *stream)
|
void Read(std::istream *stream)
|
||||||
|
@ -459,7 +387,6 @@ namespace pmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// PMDモデル
|
|
||||||
class PmdModel
|
class PmdModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -491,7 +418,6 @@ namespace pmd
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ファイルからPmdModelを生成する
|
|
||||||
static std::unique_ptr<PmdModel> LoadFromStream(std::ifstream *stream)
|
static std::unique_ptr<PmdModel> LoadFromStream(std::ifstream *stream)
|
||||||
{
|
{
|
||||||
auto result = mmd::make_unique<PmdModel>();
|
auto result = mmd::make_unique<PmdModel>();
|
||||||
|
|
|
@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace pmx
|
namespace pmx
|
||||||
{
|
{
|
||||||
/// インデックス値を読み込む
|
|
||||||
int ReadIndex(std::istream *stream, int size)
|
int ReadIndex(std::istream *stream, int size)
|
||||||
{
|
{
|
||||||
switch (size)
|
switch (size)
|
||||||
|
@ -79,7 +78,6 @@ namespace pmx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 文字列を読み込む
|
|
||||||
std::string ReadString(std::istream *stream, uint8_t encoding)
|
std::string ReadString(std::istream *stream, uint8_t encoding)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
@ -607,7 +605,6 @@ namespace pmx
|
||||||
this->joints[i].Read(stream, &setting);
|
this->joints[i].Read(stream, &setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
//// ソフトボディ
|
|
||||||
//if (this->version == 2.1f)
|
//if (this->version == 2.1f)
|
||||||
//{
|
//{
|
||||||
// stream->read((char*) &this->soft_body_count, sizeof(int));
|
// stream->read((char*) &this->soft_body_count, sizeof(int));
|
||||||
|
|
|
@ -49,7 +49,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace pmx
|
namespace pmx
|
||||||
{
|
{
|
||||||
/// インデックス設定
|
|
||||||
class PmxSetting
|
class PmxSetting
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -64,26 +63,17 @@ namespace pmx
|
||||||
, rigidbody_index_size(0)
|
, rigidbody_index_size(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// エンコード方式
|
|
||||||
uint8_t encoding;
|
uint8_t encoding;
|
||||||
/// 追加UV数
|
|
||||||
uint8_t uv;
|
uint8_t uv;
|
||||||
/// 頂点インデックスサイズ
|
|
||||||
uint8_t vertex_index_size;
|
uint8_t vertex_index_size;
|
||||||
/// テクスチャインデックスサイズ
|
|
||||||
uint8_t texture_index_size;
|
uint8_t texture_index_size;
|
||||||
/// マテリアルインデックスサイズ
|
|
||||||
uint8_t material_index_size;
|
uint8_t material_index_size;
|
||||||
/// ボーンインデックスサイズ
|
|
||||||
uint8_t bone_index_size;
|
uint8_t bone_index_size;
|
||||||
/// モーフインデックスサイズ
|
|
||||||
uint8_t morph_index_size;
|
uint8_t morph_index_size;
|
||||||
/// 剛体インデックスサイズ
|
|
||||||
uint8_t rigidbody_index_size;
|
uint8_t rigidbody_index_size;
|
||||||
void Read(std::istream *stream);
|
void Read(std::istream *stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 頂点スキニングタイプ
|
|
||||||
enum class PmxVertexSkinningType : uint8_t
|
enum class PmxVertexSkinningType : uint8_t
|
||||||
{
|
{
|
||||||
BDEF1 = 0,
|
BDEF1 = 0,
|
||||||
|
@ -93,7 +83,6 @@ namespace pmx
|
||||||
QDEF = 4,
|
QDEF = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 頂点スキニング
|
|
||||||
class PmxVertexSkinning
|
class PmxVertexSkinning
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -200,7 +189,6 @@ namespace pmx
|
||||||
void Read(std::istream *stresam, PmxSetting *setting);
|
void Read(std::istream *stresam, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 頂点
|
|
||||||
class PmxVertex
|
class PmxVertex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -219,24 +207,16 @@ namespace pmx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
/// 法線
|
|
||||||
float normal[3];
|
float normal[3];
|
||||||
/// テクスチャ座標
|
|
||||||
float uv[2];
|
float uv[2];
|
||||||
/// 追加テクスチャ座標
|
|
||||||
float uva[4][4];
|
float uva[4][4];
|
||||||
/// スキニングタイプ
|
|
||||||
PmxVertexSkinningType skinning_type;
|
PmxVertexSkinningType skinning_type;
|
||||||
/// スキニング
|
|
||||||
std::unique_ptr<PmxVertexSkinning> skinning;
|
std::unique_ptr<PmxVertexSkinning> skinning;
|
||||||
/// エッジ倍率
|
|
||||||
float edge;
|
float edge;
|
||||||
void Read(std::istream *stream, PmxSetting *setting);
|
void Read(std::istream *stream, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// マテリアル
|
|
||||||
class PmxMaterial
|
class PmxMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -261,42 +241,25 @@ namespace pmx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// モデル名
|
|
||||||
std::string material_name;
|
std::string material_name;
|
||||||
/// モデル英名
|
|
||||||
std::string material_english_name;
|
std::string material_english_name;
|
||||||
/// 減衰色
|
|
||||||
float diffuse[4];
|
float diffuse[4];
|
||||||
/// 光沢色
|
|
||||||
float specular[3];
|
float specular[3];
|
||||||
/// 光沢度
|
|
||||||
float specularlity;
|
float specularlity;
|
||||||
/// 環境色
|
|
||||||
float ambient[3];
|
float ambient[3];
|
||||||
/// 描画フラグ
|
|
||||||
uint8_t flag;
|
uint8_t flag;
|
||||||
/// エッジ色
|
|
||||||
float edge_color[4];
|
float edge_color[4];
|
||||||
/// エッジサイズ
|
|
||||||
float edge_size;
|
float edge_size;
|
||||||
/// アルベドテクスチャインデックス
|
|
||||||
int diffuse_texture_index;
|
int diffuse_texture_index;
|
||||||
/// スフィアテクスチャインデックス
|
|
||||||
int sphere_texture_index;
|
int sphere_texture_index;
|
||||||
/// スフィアテクスチャ演算モード
|
|
||||||
uint8_t sphere_op_mode;
|
uint8_t sphere_op_mode;
|
||||||
/// 共有トゥーンフラグ
|
|
||||||
uint8_t common_toon_flag;
|
uint8_t common_toon_flag;
|
||||||
/// トゥーンテクスチャインデックス
|
|
||||||
int toon_texture_index;
|
int toon_texture_index;
|
||||||
/// メモ
|
|
||||||
std::string memo;
|
std::string memo;
|
||||||
/// 頂点インデックス数
|
|
||||||
int index_count;
|
int index_count;
|
||||||
void Read(std::istream *stream, PmxSetting *setting);
|
void Read(std::istream *stream, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// リンク
|
|
||||||
class PmxIkLink
|
class PmxIkLink
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -310,18 +273,13 @@ namespace pmx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// リンクボーンインデックス
|
|
||||||
int link_target;
|
int link_target;
|
||||||
/// 角度制限
|
|
||||||
uint8_t angle_lock;
|
uint8_t angle_lock;
|
||||||
/// 最大制限角度
|
|
||||||
float max_radian[3];
|
float max_radian[3];
|
||||||
/// 最小制限角度
|
|
||||||
float min_radian[3];
|
float min_radian[3];
|
||||||
void Read(std::istream *stream, PmxSetting *settingn);
|
void Read(std::istream *stream, PmxSetting *settingn);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ボーン
|
|
||||||
class PmxBone
|
class PmxBone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -347,43 +305,24 @@ namespace pmx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ボーン名
|
|
||||||
std::string bone_name;
|
std::string bone_name;
|
||||||
/// ボーン英名
|
|
||||||
std::string bone_english_name;
|
std::string bone_english_name;
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
/// 親ボーンインデックス
|
|
||||||
int parent_index;
|
int parent_index;
|
||||||
/// 階層
|
|
||||||
int level;
|
int level;
|
||||||
/// ボーンフラグ
|
|
||||||
uint16_t bone_flag;
|
uint16_t bone_flag;
|
||||||
/// 座標オフセット(has Target)
|
|
||||||
float offset[3];
|
float offset[3];
|
||||||
/// 接続先ボーンインデックス(not has Target)
|
|
||||||
int target_index;
|
int target_index;
|
||||||
/// 付与親ボーンインデックス
|
|
||||||
int grant_parent_index;
|
int grant_parent_index;
|
||||||
/// 付与率
|
|
||||||
float grant_weight;
|
float grant_weight;
|
||||||
/// 固定軸の方向
|
|
||||||
float lock_axis_orientation[3];
|
float lock_axis_orientation[3];
|
||||||
/// ローカル軸のX軸方向
|
|
||||||
float local_axis_x_orientation[3];
|
float local_axis_x_orientation[3];
|
||||||
/// ローカル軸のY軸方向
|
|
||||||
float local_axis_y_orientation[3];
|
float local_axis_y_orientation[3];
|
||||||
/// 外部親変形のkey値
|
|
||||||
int key;
|
int key;
|
||||||
/// IKターゲットボーン
|
|
||||||
int ik_target_bone_index;
|
int ik_target_bone_index;
|
||||||
/// IKループ回数
|
|
||||||
int ik_loop;
|
int ik_loop;
|
||||||
/// IKループ計算時の角度制限(ラジアン)
|
|
||||||
float ik_loop_angle_limit;
|
float ik_loop_angle_limit;
|
||||||
/// IKリンク数
|
|
||||||
int ik_link_count;
|
int ik_link_count;
|
||||||
/// IKリンク
|
|
||||||
std::unique_ptr<PmxIkLink []> ik_links;
|
std::unique_ptr<PmxIkLink []> ik_links;
|
||||||
void Read(std::istream *stream, PmxSetting *setting);
|
void Read(std::istream *stream, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
@ -543,7 +482,6 @@ namespace pmx
|
||||||
void Read(std::istream *stream, PmxSetting *setting); //override;
|
void Read(std::istream *stream, PmxSetting *setting); //override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// モーフ
|
|
||||||
class PmxMorph
|
class PmxMorph
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -551,34 +489,21 @@ namespace pmx
|
||||||
: offset_count(0)
|
: offset_count(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
/// モーフ名
|
|
||||||
std::string morph_name;
|
std::string morph_name;
|
||||||
/// モーフ英名
|
|
||||||
std::string morph_english_name;
|
std::string morph_english_name;
|
||||||
/// カテゴリ
|
|
||||||
MorphCategory category;
|
MorphCategory category;
|
||||||
/// モーフタイプ
|
|
||||||
MorphType morph_type;
|
MorphType morph_type;
|
||||||
/// オフセット数
|
|
||||||
int offset_count;
|
int offset_count;
|
||||||
/// 頂点モーフ配列
|
|
||||||
std::unique_ptr<PmxMorphVertexOffset []> vertex_offsets;
|
std::unique_ptr<PmxMorphVertexOffset []> vertex_offsets;
|
||||||
/// UVモーフ配列
|
|
||||||
std::unique_ptr<PmxMorphUVOffset []> uv_offsets;
|
std::unique_ptr<PmxMorphUVOffset []> uv_offsets;
|
||||||
/// ボーンモーフ配列
|
|
||||||
std::unique_ptr<PmxMorphBoneOffset []> bone_offsets;
|
std::unique_ptr<PmxMorphBoneOffset []> bone_offsets;
|
||||||
/// マテリアルモーフ配列
|
|
||||||
std::unique_ptr<PmxMorphMaterialOffset []> material_offsets;
|
std::unique_ptr<PmxMorphMaterialOffset []> material_offsets;
|
||||||
/// グループモーフ配列
|
|
||||||
std::unique_ptr<PmxMorphGroupOffset []> group_offsets;
|
std::unique_ptr<PmxMorphGroupOffset []> group_offsets;
|
||||||
/// フリップモーフ配列
|
|
||||||
std::unique_ptr<PmxMorphFlipOffset []> flip_offsets;
|
std::unique_ptr<PmxMorphFlipOffset []> flip_offsets;
|
||||||
/// インパルスモーフ配列
|
|
||||||
std::unique_ptr<PmxMorphImplusOffset []> implus_offsets;
|
std::unique_ptr<PmxMorphImplusOffset []> implus_offsets;
|
||||||
void Read(std::istream *stream, PmxSetting *setting);
|
void Read(std::istream *stream, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 枠内要素
|
|
||||||
class PmxFrameElement
|
class PmxFrameElement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -587,14 +512,11 @@ namespace pmx
|
||||||
, index(0)
|
, index(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
/// 要素対象
|
|
||||||
uint8_t element_target;
|
uint8_t element_target;
|
||||||
/// 要素対象インデックス
|
|
||||||
int index;
|
int index;
|
||||||
void Read(std::istream *stream, PmxSetting *setting);
|
void Read(std::istream *stream, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 表示枠
|
|
||||||
class PmxFrame
|
class PmxFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -603,15 +525,10 @@ namespace pmx
|
||||||
, element_count(0)
|
, element_count(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
/// 枠名
|
|
||||||
std::string frame_name;
|
std::string frame_name;
|
||||||
/// 枠英名
|
|
||||||
std::string frame_english_name;
|
std::string frame_english_name;
|
||||||
/// 特殊枠フラグ
|
|
||||||
uint8_t frame_flag;
|
uint8_t frame_flag;
|
||||||
/// 枠内要素数
|
|
||||||
int element_count;
|
int element_count;
|
||||||
/// 枠内要素配列
|
|
||||||
std::unique_ptr<PmxFrameElement []> elements;
|
std::unique_ptr<PmxFrameElement []> elements;
|
||||||
void Read(std::istream *stream, PmxSetting *setting);
|
void Read(std::istream *stream, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
@ -637,17 +554,11 @@ namespace pmx
|
||||||
orientation[i] = 0.0f;
|
orientation[i] = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// 剛体名
|
|
||||||
std::string girid_body_name;
|
std::string girid_body_name;
|
||||||
/// 剛体英名
|
|
||||||
std::string girid_body_english_name;
|
std::string girid_body_english_name;
|
||||||
/// 関連ボーンインデックス
|
|
||||||
int target_bone;
|
int target_bone;
|
||||||
/// グループ
|
|
||||||
uint8_t group;
|
uint8_t group;
|
||||||
/// マスク
|
|
||||||
uint16_t mask;
|
uint16_t mask;
|
||||||
/// 形状
|
|
||||||
uint8_t shape;
|
uint8_t shape;
|
||||||
float size[3];
|
float size[3];
|
||||||
float position[3];
|
float position[3];
|
||||||
|
@ -818,7 +729,6 @@ namespace pmx
|
||||||
void Read(std::istream *stream, PmxSetting *setting);
|
void Read(std::istream *stream, PmxSetting *setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// PMXモデル
|
|
||||||
class PmxModel
|
class PmxModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -836,65 +746,35 @@ namespace pmx
|
||||||
, soft_body_count(0)
|
, soft_body_count(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/// バージョン
|
|
||||||
float version;
|
float version;
|
||||||
/// 設定
|
|
||||||
PmxSetting setting;
|
PmxSetting setting;
|
||||||
/// モデル名
|
|
||||||
std::string model_name;
|
std::string model_name;
|
||||||
/// モデル英名
|
|
||||||
std::string model_english_name;
|
std::string model_english_name;
|
||||||
/// コメント
|
|
||||||
std::string model_comment;
|
std::string model_comment;
|
||||||
/// 英語コメント
|
|
||||||
std::string model_english_comment;
|
std::string model_english_comment;
|
||||||
/// 頂点数
|
|
||||||
int vertex_count;
|
int vertex_count;
|
||||||
/// 頂点配列
|
|
||||||
std::unique_ptr<PmxVertex []> vertices;
|
std::unique_ptr<PmxVertex []> vertices;
|
||||||
/// インデックス数
|
|
||||||
int index_count;
|
int index_count;
|
||||||
/// インデックス配列
|
|
||||||
std::unique_ptr<int []> indices;
|
std::unique_ptr<int []> indices;
|
||||||
/// テクスチャ数
|
|
||||||
int texture_count;
|
int texture_count;
|
||||||
/// テクスチャ配列
|
|
||||||
std::unique_ptr< std::string []> textures;
|
std::unique_ptr< std::string []> textures;
|
||||||
/// マテリアル数
|
|
||||||
int material_count;
|
int material_count;
|
||||||
/// マテリアル
|
|
||||||
std::unique_ptr<PmxMaterial []> materials;
|
std::unique_ptr<PmxMaterial []> materials;
|
||||||
/// ボーン数
|
|
||||||
int bone_count;
|
int bone_count;
|
||||||
/// ボーン配列
|
|
||||||
std::unique_ptr<PmxBone []> bones;
|
std::unique_ptr<PmxBone []> bones;
|
||||||
/// モーフ数
|
|
||||||
int morph_count;
|
int morph_count;
|
||||||
/// モーフ配列
|
|
||||||
std::unique_ptr<PmxMorph []> morphs;
|
std::unique_ptr<PmxMorph []> morphs;
|
||||||
/// 表示枠数
|
|
||||||
int frame_count;
|
int frame_count;
|
||||||
/// 表示枠配列
|
|
||||||
std::unique_ptr<PmxFrame [] > frames;
|
std::unique_ptr<PmxFrame [] > frames;
|
||||||
/// 剛体数
|
|
||||||
int rigid_body_count;
|
int rigid_body_count;
|
||||||
/// 剛体配列
|
|
||||||
std::unique_ptr<PmxRigidBody []> rigid_bodies;
|
std::unique_ptr<PmxRigidBody []> rigid_bodies;
|
||||||
/// ジョイント数
|
|
||||||
int joint_count;
|
int joint_count;
|
||||||
/// ジョイント配列
|
|
||||||
std::unique_ptr<PmxJoint []> joints;
|
std::unique_ptr<PmxJoint []> joints;
|
||||||
/// ソフトボディ数
|
|
||||||
int soft_body_count;
|
int soft_body_count;
|
||||||
/// ソフトボディ配列
|
|
||||||
std::unique_ptr<PmxSoftBody []> soft_bodies;
|
std::unique_ptr<PmxSoftBody []> soft_bodies;
|
||||||
/// モデル初期化
|
|
||||||
void Init();
|
void Init();
|
||||||
/// モデル読み込み
|
|
||||||
void Read(std::istream *stream);
|
void Read(std::istream *stream);
|
||||||
///// ファイルからモデルの読み込み
|
|
||||||
//static std::unique_ptr<PmxModel> ReadFromFile(const char *filename);
|
//static std::unique_ptr<PmxModel> ReadFromFile(const char *filename);
|
||||||
///// 入力ストリームからモデルの読み込み
|
|
||||||
//static std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream);
|
//static std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,19 +50,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace vmd
|
namespace vmd
|
||||||
{
|
{
|
||||||
/// ボーンフレーム
|
|
||||||
class VmdBoneFrame
|
class VmdBoneFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// ボーン名
|
|
||||||
std::string name;
|
std::string name;
|
||||||
/// フレーム番号
|
|
||||||
int frame;
|
int frame;
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
/// 回転
|
|
||||||
float orientation[4];
|
float orientation[4];
|
||||||
/// 補間曲線
|
|
||||||
char interpolation[4][4][4];
|
char interpolation[4][4][4];
|
||||||
|
|
||||||
void Read(std::istream* stream)
|
void Read(std::istream* stream)
|
||||||
|
@ -86,15 +80,11 @@ namespace vmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// 表情フレーム
|
|
||||||
class VmdFaceFrame
|
class VmdFaceFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// 表情名
|
|
||||||
std::string face_name;
|
std::string face_name;
|
||||||
/// 表情の重み
|
|
||||||
float weight;
|
float weight;
|
||||||
/// フレーム番号
|
|
||||||
uint32_t frame;
|
uint32_t frame;
|
||||||
|
|
||||||
void Read(std::istream* stream)
|
void Read(std::istream* stream)
|
||||||
|
@ -114,23 +104,15 @@ namespace vmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// カメラフレーム
|
|
||||||
class VmdCameraFrame
|
class VmdCameraFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// フレーム番号
|
|
||||||
int frame;
|
int frame;
|
||||||
/// 距離
|
|
||||||
float distance;
|
float distance;
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
/// 回転
|
|
||||||
float orientation[3];
|
float orientation[3];
|
||||||
/// 補間曲線
|
|
||||||
char interpolation[6][4];
|
char interpolation[6][4];
|
||||||
/// 視野角
|
|
||||||
float angle;
|
float angle;
|
||||||
/// 不明データ
|
|
||||||
char unknown[3];
|
char unknown[3];
|
||||||
|
|
||||||
void Read(std::istream *stream)
|
void Read(std::istream *stream)
|
||||||
|
@ -156,15 +138,11 @@ namespace vmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ライトフレーム
|
|
||||||
class VmdLightFrame
|
class VmdLightFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// フレーム番号
|
|
||||||
int frame;
|
int frame;
|
||||||
/// 色
|
|
||||||
float color[3];
|
float color[3];
|
||||||
/// 位置
|
|
||||||
float position[3];
|
float position[3];
|
||||||
|
|
||||||
void Read(std::istream* stream)
|
void Read(std::istream* stream)
|
||||||
|
@ -182,7 +160,6 @@ namespace vmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// IKの有効無効
|
|
||||||
class VmdIkEnable
|
class VmdIkEnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -190,7 +167,6 @@ namespace vmd
|
||||||
bool enable;
|
bool enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// IKフレーム
|
|
||||||
class VmdIkFrame
|
class VmdIkFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -229,23 +205,15 @@ namespace vmd
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// VMDモーション
|
|
||||||
class VmdMotion
|
class VmdMotion
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// モデル名
|
|
||||||
std::string model_name;
|
std::string model_name;
|
||||||
/// バージョン
|
|
||||||
int version;
|
int version;
|
||||||
/// ボーンフレーム
|
|
||||||
std::vector<VmdBoneFrame> bone_frames;
|
std::vector<VmdBoneFrame> bone_frames;
|
||||||
/// 表情フレーム
|
|
||||||
std::vector<VmdFaceFrame> face_frames;
|
std::vector<VmdFaceFrame> face_frames;
|
||||||
/// カメラフレーム
|
|
||||||
std::vector<VmdCameraFrame> camera_frames;
|
std::vector<VmdCameraFrame> camera_frames;
|
||||||
/// ライトフレーム
|
|
||||||
std::vector<VmdLightFrame> light_frames;
|
std::vector<VmdLightFrame> light_frames;
|
||||||
/// IKフレーム
|
|
||||||
std::vector<VmdIkFrame> ik_frames;
|
std::vector<VmdIkFrame> ik_frames;
|
||||||
|
|
||||||
static std::unique_ptr<VmdMotion> LoadFromFile(char const *filename)
|
static std::unique_ptr<VmdMotion> LoadFromFile(char const *filename)
|
||||||
|
|
Loading…
Reference in New Issue