public float CalculateSortingDistance(Vector3 cameraPosition) { Vector3 meshCenter = new Vector3(boundingSphere[0], boundingSphere[1], boundingSphere[2]); // TODO: How does this work? if (useNsc && singlebind != -1) { // Use the bone position as the bounding box center ModelContainer modelContainer = (ModelContainer)Parent.Parent; if (modelContainer.VBN != null) { meshCenter = modelContainer.VBN.bones[singlebind].pos; } } Vector3 distanceVector = new Vector3(cameraPosition - meshCenter); return(distanceVector.Length + boundingSphere[3] + sortBias); }
public void Read(ResFile b, AnimationGroupNode ThisAnimation, ModelContainer modelContainer) { Console.WriteLine("Reading Material Animations ..."); TreeNode MaterialAnimation = new TreeNode() { Text = "Material Animations" }; ThisAnimation.Nodes.Add(MaterialAnimation); foreach (MaterialAnim vis in b.MaterialAnims) { modelContainer.BFRES_MTA = new BFRES.MTA(); PerMatAnim perAnim = new PerMatAnim(modelContainer.BFRES_MTA, vis); MaterialAnimation.Nodes.Add(modelContainer.BFRES_MTA); } }
public void Read(ResFile b, AnimationGroupNode ThisAnimation, ModelContainer modelContainer) { Console.WriteLine("Reading Shape Animations ..."); TreeNode ShapeAnimation = new TreeNode() { Text = "Shape Animations" }; ThisAnimation.Nodes.Add(ShapeAnimation); int i = 0; foreach (ShapeAnim fsha in b.ShapeAnims) { modelContainer.BFRES_MTA = new BFRES.MTA(); PerShapeAnim perAnim = new PerShapeAnim(modelContainer.BFRES_MTA, fsha); ShapeAnimation.Nodes.Add(modelContainer.BFRES_MTA); } }
public void Read(ResFile b, AnimationGroupNode ThisAnimation, ModelContainer modelContainer) { TreeNode TexAnimation = new TreeNode() { Text = "Textue Pattern Animations" }; ThisAnimation.Nodes.Add(TexAnimation); TreeNode dummy = new TreeNode() { Text = "Animation Set" }; foreach (TexPatternAnim tex in b.TexPatternAnims.Values) { modelContainer.BFRES_MTA = new MTA(); BFRES_FVTX FVTX = new BFRES_FVTX(modelContainer.BFRES_MTA, tex, b); TexAnimation.Nodes.Add(modelContainer.BFRES_MTA); } }
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.tType = 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");*/ }
public void Read(Syroot.NintenTools.NSW.Bfres.ResFile b, AnimationGroupNode ThisAnimation, ModelContainer modelContainer) { TreeNode BoneVISAnimation = new TreeNode() { Text = "Bone Visual Animations" }; ThisAnimation.Nodes.Add(BoneVISAnimation); int i = 0; foreach (Syroot.NintenTools.NSW.Bfres.VisibilityAnim vis in b.BoneVisibilityAnims) { modelContainer.BFRES_MTA = new BFRES.MTA(); ReadVIS(modelContainer.BFRES_MTA, vis); BoneVISAnimation.Nodes.Add(modelContainer.BFRES_MTA); i++; } }
private void SelectItem(object sender, TreeNodeMouseClickEventArgs e) { //Runtime.TargetMTA.Clear(); //Runtime.TargetAnim = null; if (e.Node is Animation) { //Runtime.TargetAnimString = e.Node.Text; string animName = e.Node.Text; animName = Regex.Match(animName, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString(); if (animName.Length > 3) { animName = animName.Substring(3); } Animation running = new Animation(animName); running.ReplaceMe((Animation)e.Node); running.Tag = e.Node; List <MTA> display = new List <MTA>(); List <MTA> def = new List <MTA>(); Queue <TreeNode> nodeQueue = new Queue <TreeNode>(); foreach (TreeNode n in treeView1.Nodes) { nodeQueue.Enqueue(n); } while (nodeQueue.Count > 0) { try { TreeNode n = nodeQueue.Dequeue(); string nodeName = Regex.Match(n.Text, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString(); if (nodeName.Length <= 3) { Console.WriteLine(nodeName); } else { nodeName = nodeName.Substring(3); } if (n is Animation) { if (n == e.Node) { continue; } if (matchAnim.Checked && nodeName.Equals(animName)) { running.children.Add(n); } } if (n is MTA) { if (n == e.Node) { continue; } if (nodeName.Contains(animName.Replace(".omo", "."))) { running.children.Add(n); } if (n.Text.Contains("display")) { display.Add((MTA)n); } if (n.Text.Contains("default.mta")) { def.Add((MTA)n); } } if (n is AnimationGroupNode) { foreach (TreeNode tn in n.Nodes) { nodeQueue.Enqueue(tn); } } } catch { } } ((ModelViewport)Parent).CurrentAnimation = running; //reset mtas foreach (TreeNode node in ((ModelViewport)Parent).draw) { if (node is ModelContainer) { ModelContainer con = (ModelContainer)node; if (con.NUD != null) { con.NUD.ClearMta(); con.NUD.ApplyMta(con.MTA, 0); foreach (MTA d in display) { con.NUD.ApplyMta(d, 0); } foreach (MTA d in def) { con.NUD.ApplyMta(d, 0); } /*foreach (KeyValuePair<string, MTA> v in Runtime.MaterialAnimations) * { * if (v.Key.Contains("display")) * { * con.NUD.applyMTA(v.Value, 0); * break; * } * }*/ } } } /*Runtime.TargetMTA.Clear(); * foreach (KeyValuePair<string, MTA> v in Runtime.MaterialAnimations) * { * if (v.Key.Contains(e.Node.Text.Replace(".omo", ""))) * { * Runtime.TargetMTA.Add(v.Value); * } * }*/ //MainForm.Instance.viewports[0].loadMTA(Runtime.MaterialAnimations[e.Node.Text]); //Console.WriteLine("Selected Anim " + e.Node.Text); } if (e.Node is MTA) { //MainForm.Instance.viewports[0].loadMTA((MTA)e.Node); //Runtime.TargetMTA = ; //Runtime.TargetMTAString = e.Node.Text; ((ModelViewport)Parent).CurrentMaterialAnimation = (MTA)e.Node; Queue <TreeNode> nodeQueue = new Queue <TreeNode>(); foreach (TreeNode n in treeView1.Nodes) { nodeQueue.Enqueue(n); } List <MTA> display = new List <MTA>(); while (nodeQueue.Count > 0) { TreeNode n = nodeQueue.Dequeue(); if (n is Animation || n is MTA) { if (n == e.Node) { continue; } if ((n.Text.Contains("default.mta") || n.Text.Contains("display")) && n is MTA) { display.Add((MTA)n); } } if (n is AnimationGroupNode) { foreach (TreeNode tn in n.Nodes) { nodeQueue.Enqueue(tn); } } } foreach (TreeNode node in ((ModelViewport)Parent).draw) { if (node is ModelContainer) { ModelContainer con = (ModelContainer)node; if (con.NUD != null && con.MTA != null) { con.NUD.ApplyMta(con.MTA, 0); foreach (MTA d in display) { con.NUD.ApplyMta(d, 0); } /*foreach (KeyValuePair<string, MTA> v in Runtime.MaterialAnimations) * { * if (v.Key.Contains("display")) * { * con.NUD.applyMTA(v.Value, 0); * break; * } * }*/ } } } } if (e.Node is BFRES.MTA) //For BFRES { ((ModelViewport)Parent).CurrentBfresMaterialAnimation = (BFRES.MTA)e.Node; Queue <TreeNode> nodeQueue = new Queue <TreeNode>(); foreach (TreeNode n in treeView1.Nodes) { nodeQueue.Enqueue(n); } while (nodeQueue.Count > 0) { TreeNode n = nodeQueue.Dequeue(); if (n is AnimationGroupNode) { foreach (TreeNode tn in n.Nodes) { nodeQueue.Enqueue(tn); } } } foreach (TreeNode node in ((ModelViewport)Parent).draw) { if (node is ModelContainer) { ModelContainer con = (ModelContainer)node; if (con.Bfres != null && con.BFRES_MTA != null) { con.Bfres.ApplyMta(con.BFRES_MTA, 0); } } } } }