//TSOFileに対するnodemapを追加します。 protected void AddNodeMap(TSOFile tso) { foreach (TSONode tso_node in tso.nodes) { TMONode tmo_node; if (tmo.nodemap.TryGetValue(tso_node.Name, out tmo_node)) { nodemap.Add(tso_node, tmo_node); } } }
//TSOFileをTSOListに追加します。 public void AddTSO(TSOFile tso) { if (tmo.frames != null) { AddNodeMap(tso); } TMOFrame tmo_frame = GetTMOFrame(); UpdateBoneMatrices(tso, tmo_frame); TSOList.Add(tso); }
public List <TSOFigure> LoadPNGFile(string source_file) { List <TSOFigure> fig_list = new List <TSOFigure>(); if (File.Exists(source_file)) { try { PNGFile png = new PNGFile(); TSOFigure fig = null; TMOFile tmo = null; png.Hsav += delegate(string type) { fig = new TSOFigure(); fig_list.Add(fig); }; png.Lgta += delegate(Stream dest, int extract_length) { fig = new TSOFigure(); fig_list.Add(fig); }; png.Ftmo += delegate(Stream dest, int extract_length) { tmo = new TMOFile(); tmo.Load(dest); fig.Tmo = tmo; }; png.Figu += delegate(Stream dest, int extract_length) { }; png.Ftso += delegate(Stream dest, int extract_length, byte[] opt1) { TSOFile tso = new TSOFile(); tso.Load(dest); fig.TSOList.Add(tso); }; png.Load(source_file); } catch (Exception ex) { Console.WriteLine("Error: " + ex); } } return(fig_list); }
public List <TSOFile> LoadTSOFile(Stream source) { List <TSOFile> tso_list = new List <TSOFile>(); try { { TSOFile tso = new TSOFile(); tso.Load(source); tso_list.Add(tso); } } catch (Exception ex) { Console.WriteLine("Error: " + ex); } return(tso_list); }
protected void UpdateBoneMatrices(TSOFile tso, TMOFrame tmo_frame) { matrixStack.LoadMatrix(Matrix.Identity); UpdateBoneMatrices(tso.nodes[0], tmo_frame); }
public void UpdateCenterPosition() { if (TSOList.Count == 0) { return; } TSOFile tso = TSOList[0]; switch (GetCenterBoneType()) { case 1://Hand { TSONode tso_nodeR; TSONode tso_nodeL; string boneR = "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_RightShoulder_Dummy|W_RightShoulder|W_RightArm_Dummy|W_RightArm|W_RightArmRoll|W_RightForeArm|W_RightForeArmRoll|W_RightHand"; string boneL = "|W_Hips|W_Spine_Dummy|W_Spine1|W_Spine2|W_Spine3|W_LeftShoulder_Dummy|W_LeftShoulder|W_LeftArm_Dummy|W_LeftArm|W_LeftArmRoll|W_LeftForeArm|W_LeftForeArmRoll|W_LeftHand"; if (tso.nodemap.TryGetValue(boneR, out tso_nodeR) && tso.nodemap.TryGetValue(boneL, out tso_nodeL)) { TMOFrame tmo_frame = GetTMOFrame(); Matrix mR = combinedMatrices[tmo_frame][tso_nodeR]; Matrix mL = combinedMatrices[tmo_frame][tso_nodeL]; position = new Vector3((mR.M41 + mL.M41) / 2.0f, (mR.M42 + mL.M42) / 2.0f, -(mR.M43 + mL.M43) / 2.0f); } else { Console.WriteLine("bone not found. " + boneR); } } break; case 2://Leg { TSONode tso_nodeR; TSONode tso_nodeL; string boneR = "|W_Hips|W_RightHips_Dummy|W_RightUpLeg|W_RightUpLegRoll|W_RightLeg"; string boneL = "|W_Hips|W_LeftHips_Dummy|W_LeftUpLeg|W_LeftUpLegRoll|W_LeftLeg"; if (tso.nodemap.TryGetValue(boneR, out tso_nodeR) && tso.nodemap.TryGetValue(boneL, out tso_nodeL)) { TMOFrame tmo_frame = GetTMOFrame(); Matrix mR = combinedMatrices[tmo_frame][tso_nodeR]; Matrix mL = combinedMatrices[tmo_frame][tso_nodeL]; position = new Vector3((mR.M41 + mL.M41) / 2.0f, (mR.M42 + mL.M42) / 2.0f, -(mR.M43 + mL.M43) / 2.0f); } else { Console.WriteLine("bone not found. " + boneR); } } break; case 3://Foot { TSONode tso_nodeR; TSONode tso_nodeL; string boneR = "|W_Hips|W_RightHips_Dummy|W_RightUpLeg|W_RightUpLegRoll|W_RightLeg|W_RightLegRoll|W_RightFoot"; string boneL = "|W_Hips|W_LeftHips_Dummy|W_LeftUpLeg|W_LeftUpLegRoll|W_LeftLeg|W_LeftLegRoll|W_LeftFoot"; if (tso.nodemap.TryGetValue(boneR, out tso_nodeR) && tso.nodemap.TryGetValue(boneL, out tso_nodeL)) { TMOFrame tmo_frame = GetTMOFrame(); Matrix mR = combinedMatrices[tmo_frame][tso_nodeR]; Matrix mL = combinedMatrices[tmo_frame][tso_nodeL]; position = new Vector3((mR.M41 + mL.M41) / 2.0f, (mR.M42 + mL.M42) / 2.0f, -(mR.M43 + mL.M43) / 2.0f); } else { Console.WriteLine("bone not found. " + boneR); } } break; default: { TSONode tso_node; string bone = GetCenterBoneName(); if (tso.nodemap.TryGetValue(bone, out tso_node)) { TMOFrame tmo_frame = GetTMOFrame(); Matrix m = combinedMatrices[tmo_frame][tso_node]; position = new Vector3(m.M41, m.M42, -m.M43); } else { Console.WriteLine("bone not found. " + bone); } } break; } }