private void parseIKList(BinaryReader br) { // the number of Vertexes short num = br.ReadInt16(); Log.Debug("PMD", "IK: " + num.ToString()); if (num > 0) { IK = new IK[num]; for (int i = 0; i < num; i++) { IK ik = new IK(); ik.ik_bone_index = br.ReadInt16(); ik.ik_target_bone_index = br.ReadInt16(); ik.ik_chain_length = br.ReadByte(); ik.iterations = br.ReadInt16(); ik.control_weight = br.ReadSingle(); ik.ik_child_bone_index = new short[ik.ik_chain_length]; for (int j = 0; j < ik.ik_chain_length; j++) { ik.ik_child_bone_index[j] = br.ReadInt16(); } IK[i] = ik; } } else { IK = null; } }
public void Load(string filename) { using(var fs = File.OpenRead(filename)) using(var bs = new BinaryReader(fs)) { // header string s = bs.ReadString(); Log.Debug("RMC", "MAGIC: " + s); // VertNormUv Log.Debug("RMC", "VertNormUv"); VertNormUv = ReadFloats(bs); // Index Log.Debug("RMC", "Index"); Index = ReadUshorts(bs); // Bone Log.Debug("RMC", "Bone"); Bones = new Bone[bs.ReadUInt32()]; Log.Debug("RMC", "count : " + Bones.Length.ToString()); for (int i = 0; i < Bones.Length; i++) { Bones[i] = new Bone(); Bones[i].name = bs.ReadString(); Bones[i].parent = bs.ReadInt16(); Bones[i].tail = bs.ReadInt16(); Bones[i].type = bs.ReadByte(); Bones[i].ik = bs.ReadInt16(); Bones[i].head_pos = ReadFloats(bs, 3); Bones[i].is_leg = bs.ReadBoolean(); } // IKs Log.Debug("RMC", "IK"); IKs = new IK[bs.ReadUInt32()]; Log.Debug("RMC", "count : " + IKs.Length.ToString()); for (int i = 0; i < IKs.Length; i++) { IKs[i] = new IK(); IKs[i].ik_bone_index = bs.ReadInt32(); IKs[i].ik_target_bone_index = bs.ReadInt32(); IKs[i].ik_chain_length = bs.ReadByte(); IKs[i].iterations = bs.ReadInt32(); IKs[i].control_weight = bs.ReadSingle(); IKs[i].ik_child_bone_index = new short[bs.ReadUInt32()]; for (int j = 0; j < IKs[i].ik_child_bone_index.Length; j++) { IKs[i].ik_child_bone_index[j] = bs.ReadInt16(); } } // Materials Log.Debug("RMC", "Material"); Materials = new FMaterial[bs.ReadUInt32()]; Log.Debug("RMC", "count : " + Materials.Length.ToString()); for (int i = 0; i < Materials.Length; i++) { Materials[i] = new FMaterial(); Materials[i].diffuse_color = ReadFloats(bs, 4); Materials[i].power = bs.ReadSingle(); Materials[i].specular_color = ReadFloats(bs, 3); Materials[i].emmisive_color = ReadFloats(bs, 3); Materials[i].toon_index = bs.ReadByte(); Materials[i].edge_flag = bs.ReadByte(); Materials[i].face_vert_count = bs.ReadInt32(); if (bs.ReadBoolean()) { Materials[i].texture = bs.ReadString(); Log.Debug("RMC", "load texture in material ... " + Materials[i].texture); } Materials[i].face_vert_offset = bs.ReadInt32(); Materials[i].bone_num = bs.ReadInt32(); Log.Debug("RMC", "Bone num: " + Materials[i].bone_num.ToString()); Materials[i].weight = bs.ReadBytes(VertNormUv.Length / 8 * 3); Materials[i].bone_inv_map = new int[48]; // ad-hock for (int j = 0; j < Materials[i].bone_inv_map.Length; j++) { Materials[i].bone_inv_map[j] = bs.ReadInt32(); } } // ToonNames Log.Debug("RMC", "ToonNames"); ToonNames = new string[11]; for (int i = 0; i < 11; i++) { ToonNames[i] = bs.ReadString(); Log.Debug("RMC", ToonNames[i]); } } }