/// <summary> /// /// </summary> /// <param name=""></param> private void SetTOBJs(HSD_TOBJ[] tobjs) { if (TOBJ != null) { TOBJ._s.References.Clear(); foreach (var r in tobjs[0]._s.References) { TOBJ._s.References.Add(r.Key, r.Value); } TOBJ._s.SetData(tobjs[0]._s.GetData()); } if (TexAnim != null) { var imgs = new List <HSD_TexBuffer>(); var pals = new List <HSD_TlutBuffer>(); foreach (var tobj in tobjs) { HSD_TexBuffer buf = new HSD_TexBuffer(); buf.Data = tobj.ImageData; imgs.Add(buf); if (ImageDataFormat.IsPalettedFormat(tobj.ImageData.Format)) { HSD_TlutBuffer palbuf = new HSD_TlutBuffer(); palbuf.Data = tobj.TlutData; pals.Add(palbuf); } } // convert tobjs into proper strip var ib = new HSDArrayAccessor <HSD_TexBuffer>(); ib.Array = imgs.ToArray(); TexAnim.ImageBuffers = ib; if (tobjs.Length > 0 && ImageDataFormat.IsPalettedFormat(tobjs[0].ImageData.Format)) { var tb = new HSDRaw.HSDArrayAccessor <HSD_TlutBuffer>(); tb.Array = pals.ToArray(); TexAnim.TlutBuffers = tb; } else { TexAnim.TlutBuffers = null; } } if (TEXG != null) { TEXG.SetFromTOBJs(tobjs); Node.Refresh(); } }
private void importFramesToolStripMenuItem_Click(object sender, EventArgs e) { if (TexAnim == null) { return; } var files = Tools.FileIO.OpenFiles(ApplicationSettings.ImageFileFilter); if (files != null) { using (TextureImportDialog td = new TextureImportDialog()) { if (td.ShowDialog() == DialogResult.OK) { var matched = new HashSet <int>(); var tobjs = new List <HSD_TexBuffer>(); var pals = new List <HSD_TlutBuffer>(); foreach (var f in files) { int num = 0; int.TryParse(Regex.Match(Path.GetFileName(f).ToLower(), @"(?<=.*_)(\d+?)(?=\.)").Name, out num); Console.WriteLine(num + " " + Regex.Match(Path.GetFileName(f).ToLower(), @"(?<=.*_)(\d+?)(?=\.)").Groups[0].Value); if (!int.TryParse(Regex.Match(Path.GetFileName(f).ToLower(), @"(?<=.*_)(\d+?)(?=\.)").Groups[0].Value, out num) || matched.Contains(num)) { throw new InvalidDataException(num + " " + Path.GetFileName(f) + " is missing index tag or has duplicate index"); } else { HSD_TOBJ temp = new HSD_TOBJ(); TOBJConverter.InjectBitmap(f, temp, td.TextureFormat, td.PaletteFormat); HSD_TexBuffer buf = new HSD_TexBuffer(); buf.Data = temp.ImageData; tobjs.Add(buf); if (ImageDataFormat.IsPalettedFormat(td.TextureFormat)) { HSD_TlutBuffer palbuf = new HSD_TlutBuffer(); palbuf.Data = temp.TlutData; pals.Add(palbuf); } matched.Add(num); } } // convert tobjs into proper strip var ib = new HSDArrayAccessor <HSD_TexBuffer>(); ib.Array = tobjs.ToArray(); TexAnim.ImageBuffers = ib; if (ImageDataFormat.IsPalettedFormat(td.TextureFormat)) { var tb = new HSDRaw.HSDArrayAccessor <HSD_TlutBuffer>(); tb.Array = pals.ToArray(); TexAnim.TlutBuffers = tb; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count < 2) { TexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc(); TexAnim.AnimationObject.FObjDesc.Next.FromFOBJ(new HSD_FOBJ() { JointTrackType = JointTrackType.HSD_A_J_SCAX, Buffer = new byte[0] }); } } else { TexAnim.TlutBuffers = null; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count > 1) { TexAnim.AnimationObject.FObjDesc.Next = null; } } Node = Node; } } } }
/// <summary> /// /// </summary> /// <param name=""></param> private void SetTOBJs(HSD_TOBJ[] tobjs) { if (TOBJ != null) { TOBJ = tobjs[0]; } if (TexAnim != null) { var imgs = new List <HSD_TexBuffer>(); var pals = new List <HSD_TlutBuffer>(); foreach (var tobj in tobjs) { HSD_TexBuffer buf = new HSD_TexBuffer(); buf.Data = tobj.ImageData; imgs.Add(buf); if (TPLConv.IsPalettedFormat(tobj.ImageData.Format)) { HSD_TlutBuffer palbuf = new HSD_TlutBuffer(); palbuf.Data = tobj.TlutData; pals.Add(palbuf); } } // convert tobjs into proper strip var ib = new HSDArrayAccessor <HSD_TexBuffer>(); ib.Array = imgs.ToArray(); TexAnim.ImageBuffers = ib; if (tobjs.Length > 0 && TPLConv.IsPalettedFormat(tobjs[0].ImageData.Format)) { var tb = new HSDRaw.HSDArrayAccessor <HSD_TlutBuffer>(); tb.Array = pals.ToArray(); TexAnim.TlutBuffers = tb; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count < 2) { TexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc(); TexAnim.AnimationObject.FObjDesc.Next.FromFOBJ(new HSD_FOBJ() { AnimationType = JointTrackType.HSD_A_J_SCAX, Buffer = new byte[0] }); } } else { TexAnim.TlutBuffers = null; if (TexAnim?.AnimationObject?.FObjDesc?.List.Count > 1) { TexAnim.AnimationObject.FObjDesc.Next = null; } } } if (TEXG != null) { TEXG.SetFromTOBJs(tobjs); } }