public void ImportAnimation(string filename) { if (filename.ToLower().EndsWith(".pac")) { PAC p = new PAC(); p.Read(filename); AnimationGroupNode animGroup = new AnimationGroupNode() { Text = filename }; string groupname = null; foreach (var pair in p.Files) { if (pair.Key.EndsWith(".omo")) { var anim = OMOOld.read(new FileData(pair.Value)); animGroup.Nodes.Add(anim); string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString(); if (!string.IsNullOrEmpty(AnimName)) { if (groupname == null) { groupname = pair.Key.Replace(AnimName, ""); } anim.Text = AnimName; } //Runtime.acmdEditor.updateCrcList(); } else if (pair.Key.EndsWith(".mta")) { MTA mta = new MTA(); mta.read(new FileData(pair.Value)); mta.Text = pair.Key; animGroup.Nodes.Add(mta); } } if (groupname != null && !groupname.Equals("")) { animGroup.UseGroupName = true; animGroup.Text = groupname; } treeView1.Nodes.Add(animGroup); } }
public void OpenPacs(List <string> pacs) { foreach (string pac in pacs) { PAC p = new PAC(); p.Read(pac); byte[] data; if (p.Files.TryGetValue("display", out data)) { MTA mta = new MTA(); mta.read(new FileData(data)); NUD.ApplyMta(mta, 0); } if (p.Files.TryGetValue("default.mta", out data)) { MTA mta = new MTA(); mta.read(new FileData(data)); NUD.ApplyMta(mta, 0); } } }
public static void MakePichu(string path = "C:\\Pichu\\") { if (!path.EndsWith("\\")) { path += "\\"; } DAT dat = new DAT(); dat.Read(new FileData(path + "PlPcNr.dat")); dat.PreRender(); dat.ExportTextures(path, 0x401B1000); BoneNameFix(dat.bones); // model-------------------------------------------------------- ModelContainer converted = dat.wrapToNUD(); NUD nud = converted.NUD; float sca = 0.6f; removeLowPolyNr(nud); nud.UpdateRenderMeshes(); //Runtime.ModelContainers.Add(converted); //------------------------------------------------- Runtime.TargetVBN = converted.VBN; MainForm.HashMatch(); Dictionary <string, SkelAnimation> anims = DAT_Animation.LoadAJ(path + "PlPcAJ.dat", converted.VBN); //ArrangeBones(converted.vbn, converted.nud); // note bone 40 - 51 is disabled for pika foreach (string an in anims.Keys) { effectiveScale(anims[an], Matrix4.CreateTranslation(0, 0, 0) * Matrix4.CreateScale(sca, sca, sca)); } effectiveScale(converted.NUD, converted.VBN, Matrix4.CreateTranslation(0, 0, 0) * Matrix4.CreateScale(sca, sca, sca)); Directory.CreateDirectory(path + "build\\model\\body\\c00\\"); nud.Save(path + "build\\model\\body\\c00\\model.nud"); converted.VBN.Endian = Endianness.Little; converted.VBN.Save(path + "build\\model\\body\\c00\\model.vbn"); PAC org = new PAC(); PAC npac = new PAC(); org.Read(path + "main.pac"); foreach (string key in org.Files.Keys) { byte[] d = org.Files[key]; foreach (string an in anims.Keys) { string name = an.Replace("PlyPichu5K_Share_ACTION_", "").Replace("_figatree", ""); if (key.Contains(name)) { Console.WriteLine("Matched " + name + " with " + key); if (!anims[an].getNodes(true).Contains(0) && !key.Contains("Cliff")) { KeyNode node = anims[an].getNode(0, 0); node.t_type = 1; } d = OMOOld.createOMO(anims[an], converted.VBN); break; } } npac.Files.Add(key, d); } Directory.CreateDirectory(path + "build\\motion\\"); npac.Save(path + "build\\motion\\main.pac"); /*FileOutput omo = new FileOutput(); * converted.vbn.reset(); * converted.vbn.totalBoneCount = (uint)converted.vbn.bones.Count; * omo.writeBytes(OMO.createOMO(anims["PlyPichu5K_Share_ACTION_Wait1_figatree"], converted.vbn)); * omo.save(path + "PlyPichu5K_Share_ACTION_Wait1_figatree.omo");*/ }
//<summary> //Open an animation based on filename //</summary> public void openAnimation(string filename) { //Runtime.Animations.Clear(); if (filename.EndsWith(".mta")) { MTA mta = new MTA(); try { mta.Read(filename); Runtime.MaterialAnimations.Add(filename, mta); mtaNode.Nodes.Add(filename); MainForm.Instance.viewports[0].loadMTA(mta); Runtime.TargetMTAString = filename; } catch (EndOfStreamException) { mta = null; } } else if (filename.EndsWith(".smd")) { var anim = new SkelAnimation(); if (Runtime.TargetVBN == null) { Runtime.TargetVBN = new VBN(); } SMD.read(filename, anim, Runtime.TargetVBN); leftPanel.treeRefresh(); Runtime.Animations.Add(filename, anim); animNode.Nodes.Add(filename); } else if (filename.EndsWith(".pac")) { PAC p = new PAC(); p.Read(filename); foreach (var pair in p.Files) { if (pair.Key.EndsWith(".omo")) { var anim = OMO.read(new FileData(pair.Value)); string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString(); //AnimName = pair.Key; //AnimName = AnimName.Remove(AnimName.Length - 4); //AnimName = AnimName.Insert(3, "_"); if (!string.IsNullOrEmpty(AnimName)) { if (Runtime.Animations.ContainsKey(AnimName)) { Runtime.Animations[AnimName].children.Add(anim); } else { animNode.Nodes.Add(AnimName); Runtime.Animations.Add(AnimName, anim); } } else { if (Runtime.Animations.ContainsKey(pair.Key)) { Runtime.Animations[pair.Key].children.Add(anim); } else { animNode.Nodes.Add(pair.Key); Runtime.Animations.Add(pair.Key, anim); } } } else if (pair.Key.EndsWith(".mta")) { MTA mta = new MTA(); try { if (!Runtime.MaterialAnimations.ContainsKey(pair.Key)) { mta.read(new FileData(pair.Value)); Runtime.MaterialAnimations.Add(pair.Key, mta); mtaNode.Nodes.Add(pair.Key); } // matching string AnimName = Regex.Match(pair.Key, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString().Replace(".mta", ".omo"); if (Runtime.Animations.ContainsKey(AnimName)) { Runtime.Animations[AnimName].children.Add(mta); } } catch (EndOfStreamException) { mta = null; } } } } if (filename.EndsWith(".dat")) { if (!filename.EndsWith("AJ.dat")) { MessageBox.Show("Not a DAT animation"); } else { if (Runtime.ModelContainers[0].dat_melee == null) { MessageBox.Show("Load a DAT model first"); } else { DAT_Animation.LoadAJ(filename, Runtime.ModelContainers[0].dat_melee.bones); } } } //if (Runtime.TargetVBN.bones.Count > 0) //{ if (filename.EndsWith(".omo")) { Runtime.Animations.Add(filename, OMO.read(new FileData(filename))); animNode.Nodes.Add(filename); } if (filename.EndsWith(".chr0")) { Runtime.Animations.Add(filename, CHR0.read(new FileData(filename), Runtime.TargetVBN)); animNode.Nodes.Add(filename); } if (filename.EndsWith(".anim")) { Runtime.Animations.Add(filename, ANIM.read(filename, Runtime.TargetVBN)); animNode.Nodes.Add(filename); } }
private void openNud(string filename, string name = "") { string[] files = Directory.GetFiles(System.IO.Path.GetDirectoryName(filename)); string pnud = filename; string pnut = ""; string pjtb = ""; string pvbn = ""; string pmta = ""; string psb = ""; string pmoi = ""; List <string> pacs = new List <string>(); foreach (string s in files) { if (s.EndsWith(".nut")) { pnut = s; } if (s.EndsWith(".vbn")) { pvbn = s; } if (s.EndsWith(".jtb")) { pjtb = s; } if (s.EndsWith(".mta")) { pmta = s; } if (s.EndsWith(".sb")) { psb = s; } if (s.EndsWith(".moi")) { pmoi = s; } if (s.EndsWith(".pac")) { pacs.Add(s); } } ModelContainer model = new ModelContainer(); model.name = name; if (!pvbn.Equals("")) { model.vbn = new VBN(pvbn); Runtime.TargetVBN = model.vbn; if (!pjtb.Equals("")) { model.vbn.readJointTable(pjtb); } if (!psb.Equals("")) { model.vbn.swingBones.Read(psb); } } if (!pnut.Equals("")) { NUT nut = new NUT(pnut); Runtime.TextureContainers.Add(nut); } if (!pnud.Equals("")) { model.nud = new NUD(pnud); //AddDockedControl(new NUDMaterialEditor(model.nud.mesh[0].polygons[0].materials)); foreach (string s in pacs) { PAC p = new PAC(); p.Read(s); byte[] data; p.Files.TryGetValue("default.mta", out data); if (data != null) { MTA m = new MTA(); m.read(new FileData(data)); model.nud.applyMTA(m, 0); } } } if (!pmta.Equals("")) { try { model.mta = new MTA(); model.mta.Read(pmta); string mtaName = Path.Combine(Path.GetFileName(Path.GetDirectoryName(pmta)), Path.GetFileName(pmta)); Console.WriteLine($"MTA Name - {mtaName}"); addMaterialAnimation(mtaName, model.mta); } catch (EndOfStreamException) { model.mta = null; } } if (!pmoi.Equals("")) { model.moi = new MOI(pmoi); } if (model.nud != null) { model.nud.MergePoly(); } Runtime.ModelContainers.Add(model); meshList.refresh(); }