public float CalculateSortingDistance(Vector3 cameraPosition) { Vector3 meshCenter = new Vector3(boundingSphere[0], boundingSphere[1], boundingSphere[2]); 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); }
private void treeView1_KeyDown(object sender, KeyEventArgs e) { e.Handled = false; if (e.KeyCode == Keys.Delete) { e.Handled = true; if (treeView1.SelectedNode is NUD.Mesh) { NUD parent = ((NUD)treeView1.SelectedNode.Parent.Tag); parent.mesh.Remove((NUD.Mesh)treeView1.SelectedNode); parent.PreRender(); } else if (treeView1.SelectedNode.Tag is NUD) { NUD model = (NUD)treeView1.SelectedNode.Tag; ModelContainer m = null; foreach (ModelContainer modelContainer in Runtime.ModelContainers) { if (modelContainer.nud == model) { m = modelContainer; } } if (m != null) { Runtime.ModelContainers.Remove(m); } if (Runtime.TargetVBN == m.vbn) { Runtime.TargetVBN = null; } if (Runtime.TargetMTA == m.mta) { Runtime.TargetMTA = null; } if (Runtime.TargetNUD == m.nud) { Runtime.TargetNUD = null; } } refresh(); } }
public static void DrawDATCollisions(ModelContainer m) { float scale = m.dat_melee.stageScale; List <int> ledges = new List <int>(); foreach (DAT.COLL_DATA.Link link in m.dat_melee.collisions.links) { GL.Begin(PrimitiveType.Quads); GL.Color4(getLinkColor(link)); Vector2D vi = m.dat_melee.collisions.vertices[link.vertexIndices[0]]; GL.Vertex3(vi.x * scale, vi.y * scale, 5); GL.Vertex3(vi.x * scale, vi.y * scale, -5); vi = m.dat_melee.collisions.vertices[link.vertexIndices[1]]; GL.Vertex3(vi.x * scale, vi.y * scale, -5); GL.Vertex3(vi.x * scale, vi.y * scale, 5); GL.End(); if ((link.flags & 2) != 0) { ledges.Add(link.vertexIndices[0]); ledges.Add(link.vertexIndices[1]); } } GL.LineWidth(4); for (int i = 0; i < m.dat_melee.collisions.vertices.Count; i++) { Vector2D vi = m.dat_melee.collisions.vertices[i]; if (ledges.Contains(i)) { GL.Color3(Color.Purple); } else { GL.Color3(Color.Tomato); } GL.Begin(PrimitiveType.Lines); GL.Vertex3(vi.x * scale, vi.y * scale, 5); GL.Vertex3(vi.x * scale, vi.y * scale, -5); GL.End(); } }
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); } }
private void SetBfresSkeletonTarget(TreeNode Anim) { foreach (TreeNode node in ((ModelViewport)Parent).draw) { if (node is ModelContainer) { ModelContainer con = (ModelContainer)node; if (con.Bfres != null) { foreach (BFRES.FMDL_Model fmdl in con.Bfres.models) { if (BfresModelHasBones(Anim, fmdl)) { Runtime.TargetVBN = fmdl.skeleton; } } } } } }
private void openEditToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView1.SelectedNode is NUD) { NUD org = (NUD)treeView1.SelectedNode; foreach (TreeNode node in treeView1.Nodes) { if (node is ModelContainer) { ModelContainer con = (ModelContainer)node; if (con.NUD == org) { ModelViewport v = new ModelViewport(); v.draw.Add(con); MainForm.Instance.AddDockedControl(v); break; } } } } }
public void refresh() { // grab contcainer vertexListBox.Items.Clear(); ModelContainer con = vp.draw[0]; foreach (NUD.Mesh mesh in con.nud.mesh) { foreach (NUD.Polygon poly in mesh.Nodes) { for (int i = 0; i < poly.selectedVerts.Length; i++) { if (poly.selectedVerts[i] > 0) { vertexListBox.Items.Add(poly.vertices[i]); } } } } }
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); } }
private void SelectVertex(NUD.Vertex v) { ModelContainer con = vp.draw[0]; foreach (NUD.Mesh mesh in con.nud.mesh) { foreach (NUD.Polygon poly in mesh.Nodes) { for (int i = 0; i < poly.vertices.Count; i++) { if (poly.selectedVerts[i] < 0) { poly.selectedVerts[i] = 1; } if (poly.vertices[i] == v) { poly.selectedVerts[i] = -1; return; } } } } }
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); } }
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(); }
public static void DrawCollisions(Stopwatch timeSinceSelected) { Color color; GL.LineWidth(4); Matrix4 transform = Matrix4.Identity; foreach (Collision c in Runtime.TargetLVD.collisions) { bool colSelected = (Runtime.LVDSelection == c); float addX = 0, addY = 0, addZ = 0; if (c.useStartPos) { addX = c.startPos[0]; addY = c.startPos[1]; addZ = c.startPos[2]; } if (c.flag2) { //Flag2 == rigged collision ModelContainer riggedModel = null; Bone riggedBone = null; foreach (ModelContainer m in Runtime.ModelContainers) { if (m.name.Equals(c.subname)) { riggedModel = m; if (m.vbn != null) { foreach (Bone b in m.vbn.bones) { if (b.Equals(c.boneName)) { riggedBone = b; } } } } } if (riggedModel != null) { if (riggedBone == null && riggedModel.vbn != null && riggedModel.vbn.bones.Count > 0) { riggedBone = riggedModel.vbn.bones[0]; } if (riggedBone != null) { transform = riggedBone.invert * riggedBone.transform; } } } for (int i = 0; i < c.verts.Count - 1; i++) { Vector3 v1Pos = Vector3.Transform(new Vector3(c.verts[i].x + addX, c.verts[i].y + addY, addZ + 5), transform); Vector3 v1Neg = Vector3.Transform(new Vector3(c.verts[i].x + addX, c.verts[i].y + addY, addZ - 5), transform); Vector3 v1Zero = Vector3.Transform(new Vector3(c.verts[i].x + addX, c.verts[i].y + addY, addZ), transform); Vector3 v2Pos = Vector3.Transform(new Vector3(c.verts[i + 1].x + addX, c.verts[i + 1].y + addY, addZ + 5), transform); Vector3 v2Neg = Vector3.Transform(new Vector3(c.verts[i + 1].x + addX, c.verts[i + 1].y + addY, addZ - 5), transform); Vector3 v2Zero = Vector3.Transform(new Vector3(c.verts[i + 1].x + addX, c.verts[i + 1].y + addY, addZ), transform); GL.Begin(PrimitiveType.Quads); if (c.normals.Count > i) { if (Runtime.renderCollisionNormals) { Vector3 v = Vector3.Add(Vector3.Divide(Vector3.Subtract(v1Zero, v2Zero), 2), v2Zero); GL.End(); GL.Begin(PrimitiveType.Lines); GL.Color3(Color.Blue); GL.Vertex3(v); GL.Vertex3(v.X + (c.normals[i].x * 5), v.Y + (c.normals[i].y * 5), v.Z); GL.End(); GL.Begin(PrimitiveType.Quads); } if (c.flag4) { color = Color.FromArgb(128, Color.Yellow); } else if (c.materials[i].getFlag(4) && Math.Abs(c.normals[i].x) > Math.Abs(c.normals[i].y)) { color = Color.FromArgb(128, Color.Purple); } else if (Math.Abs(c.normals[i].x) > Math.Abs(c.normals[i].y)) { color = Color.FromArgb(128, Color.Lime); } else if (c.normals[i].y < 0) { color = Color.FromArgb(128, Color.Red); } else { color = Color.FromArgb(128, Color.Cyan); } if ((colSelected || Runtime.LVDSelection == c.normals[i]) && ((int)((timeSinceSelected.ElapsedMilliseconds % 1000) / 500) == 0)) { color = ColorTools.invertColor(color); } GL.Color4(color); } else { GL.Color4(Color.FromArgb(128, Color.Gray)); } GL.Vertex3(v1Pos); GL.Vertex3(v1Neg); GL.Vertex3(v2Neg); GL.Vertex3(v2Pos); GL.End(); GL.Begin(PrimitiveType.Lines); if (c.materials.Count > i) { if (c.materials[i].getFlag(6) || (i > 0 && c.materials[i - 1].getFlag(7))) { color = Color.Purple; } else { color = Color.Orange; } if ((colSelected || Runtime.LVDSelection == c.verts[i]) && ((int)((timeSinceSelected.ElapsedMilliseconds % 1000) / 500) == 0)) { color = ColorTools.invertColor(color); } GL.Color4(color); } else { GL.Color4(Color.Gray); } GL.Vertex3(v1Pos); GL.Vertex3(v1Neg); if (i == c.verts.Count - 2) { if (c.materials.Count > i) { if (c.materials[i].getFlag(7)) { color = Color.Purple; } else { color = Color.Orange; } if (Runtime.LVDSelection == c.verts[i + 1] && ((int)((timeSinceSelected.ElapsedMilliseconds % 1000) / 500) == 0)) { color = ColorTools.invertColor(color); } GL.Color4(color); } else { GL.Color4(Color.Gray); } GL.Vertex3(v2Pos); GL.Vertex3(v2Neg); } GL.End(); } for (int i = 0; i < c.cliffs.Count; i++) { Vector3 pos = c.cliffs[i].useStartPos ? c.cliffs[i].startPos : new Vector3(c.cliffs[i].pos.x, c.cliffs[i].pos.y, 0); GL.Color3(Color.White); GL.Begin(PrimitiveType.Lines); GL.Vertex3(pos[0], pos[1], pos[2] + 10); GL.Vertex3(pos[0], pos[1], pos[2] - 10); GL.End(); GL.LineWidth(2); GL.Color3(Color.Blue); GL.Begin(PrimitiveType.Lines); GL.Vertex3(pos); GL.Vertex3(pos[0] + (c.cliffs[i].angle.x * 10), pos[1] + (c.cliffs[i].angle.y * 10), pos[2]); GL.End(); GL.LineWidth(4); } } }
private void animationTrackBar_ValueChanged(object sender, EventArgs e) { if (animationTrackBar.Value > totalFrame.Value) { animationTrackBar.Value = 0; } if (animationTrackBar.Value < 0) { animationTrackBar.Value = (int)totalFrame.Value; } currentFrame.Value = animationTrackBar.Value; int frameNum = animationTrackBar.Value; if (MaterialAnimation != null) { foreach (TreeNode node in MeshList.treeView1.Nodes) { if (!(node is ModelContainer)) { continue; } ModelContainer m = (ModelContainer)node; m.NUD.applyMTA(MaterialAnimation, frameNum); } } if (Animation == null) { return; } // Process script first in case we have to speed up the animation if (ACMDScript != null) { ACMDScript.processToFrame(frameNum); } float animFrameNum = frameNum; if (ACMDScript != null && Runtime.useFrameDuration) { animFrameNum = ACMDScript.animationFrame;// - 1; } foreach (TreeNode node in MeshList.treeView1.Nodes) { if (!(node is ModelContainer)) { continue; } ModelContainer m = (ModelContainer)node; Animation.SetFrame(animFrameNum); if (m.VBN != null) { Animation.NextFrame(m.VBN); } // Deliberately do not ever use ACMD/animFrame to modify these other types of model if (m.dat_melee != null) { Animation.SetFrame(frameNum); Animation.NextFrame(m.dat_melee.bones); } if (m.BCH != null) { foreach (BCH_Model mod in m.BCH.Models.Nodes) { if (mod.skeleton != null) { Animation.SetFrame(animFrameNum); Animation.NextFrame(mod.skeleton); } } } } //Frame = (int)animFrameNum; }
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); } } } } }
private void checkSelect() { if (CurrentMode == Mode.Selection) { Vector2 m = GetMouseOnViewport(); if (!m.Equals(new Vector2(sx1, sy1))) { // select group of vertices float minx = Math.Min(sx1, m.X); float miny = Math.Min(sy1, m.Y); float width = Math.Abs(sx1 - m.X); float height = Math.Abs(sy1 - m.Y); foreach (TreeNode node in draw) { if (!(node is ModelContainer)) { continue; } ModelContainer con = (ModelContainer)node; foreach (NUD.Mesh mesh in con.NUD.Nodes) { foreach (NUD.Polygon poly in mesh.Nodes) { //if (!poly.IsSelected && !mesh.IsSelected) continue; int i = 0; foreach (NUD.Vertex v in poly.vertices) { if (!OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ControlLeft)) { poly.selectedVerts[i] = 0; } Vector3 n = getScreenPoint(v.pos); if (n.X >= minx && n.Y >= miny && n.X <= minx + width && n.Y <= miny + height) { poly.selectedVerts[i] = 1; } i++; } } } } } else { // single vertex // Selects the closest vertex Ray r = RenderTools.createRay(Camera.getMVPMatrix(), GetMouseOnViewport()); Vector3 close = Vector3.Zero; foreach (TreeNode node in draw) { if (!(node is ModelContainer)) { continue; } ModelContainer con = (ModelContainer)node; NUD.Polygon Close = null; int index = 0; double mindis = 999; foreach (NUD.Mesh mesh in con.NUD.Nodes) { foreach (NUD.Polygon poly in mesh.Nodes) { //if (!poly.IsSelected && !mesh.IsSelected) continue; int i = 0; foreach (NUD.Vertex v in poly.vertices) { //if (!poly.IsSelected) continue; if (!OpenTK.Input.Keyboard.GetState().IsKeyDown(OpenTK.Input.Key.ControlLeft)) { poly.selectedVerts[i] = 0; } if (r.TrySphereHit(v.pos, 0.2f, out close)) { double dis = r.Distance(close); if (dis < mindis) { mindis = dis; Close = poly; index = i; } } i++; } } } if (Close != null) { Close.selectedVerts[index] = 1; } } } VertexTool.vertexListBox.BeginUpdate(); VertexTool.vertexListBox.Items.Clear(); foreach (TreeNode node in draw) { if (!(node is ModelContainer)) { continue; } ModelContainer con = (ModelContainer)node; foreach (NUD.Mesh mesh in con.NUD.Nodes) { foreach (NUD.Polygon poly in mesh.Nodes) { int i = 0; foreach (NUD.Vertex v in poly.vertices) { if (poly.selectedVerts[i++] == 1) { VertexTool.vertexListBox.Items.Add(v); } } } } } VertexTool.vertexListBox.EndUpdate(); CurrentMode = Mode.Normal; } }
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++; } }
///<summary> ///Open a file based on the filename ///</summary> /// <param name="filename"> Filename of file to open</param> public void openFile(string filename) { if (!filename.EndsWith(".mta") && !filename.EndsWith(".dat") && !filename.EndsWith(".smd")) { openAnimation(filename); } if (filename.EndsWith(".vbn")) { Runtime.TargetVBN = new VBN(filename); if (Directory.Exists("Skapon\\")) { NUD nud = Skapon.Create(Runtime.TargetVBN); ModelContainer con = new ModelContainer(); con.vbn = Runtime.TargetVBN; con.nud = nud; nud.PreRender(); Runtime.ModelContainers.Add(con); } } if (filename.EndsWith(".sb")) { SB sb = new SB(); sb.Read(filename); SwagEditor swagEditor = new SwagEditor(sb) { ShowHint = DockState.DockRight }; AddDockedControl(swagEditor); SwagEditors.Add(swagEditor); } if (filename.EndsWith(".dat")) { if (filename.EndsWith("AJ.dat")) { MessageBox.Show("This is animation; load with Animation -> Import"); return; } DAT dat = new DAT(); dat.Read(new FileData(filename)); ModelContainer c = new ModelContainer(); Runtime.ModelContainers.Add(c); c.dat_melee = dat; dat.PreRender(); HashMatch(); Runtime.TargetVBN = dat.bones; DAT_TreeView p = new DAT_TreeView() { ShowHint = DockState.DockLeft }; p.setDAT(dat); AddDockedControl(p); //Runtime.TargetVBN = dat.bones; meshList.refresh(); } if (filename.EndsWith(".nut")) { Runtime.TextureContainers.Add(new NUT(filename)); NUTEditor ev = new NUTEditor(); ev.Show(); } if (filename.EndsWith(".lvd")) { Runtime.TargetLVD = new LVD(filename); LVD test = Runtime.TargetLVD; lvdList.fillList(); } if (filename.EndsWith(".mta")) { Runtime.TargetMTA = new MTA(); Runtime.TargetMTA.Read(filename); viewports[0].loadMTA(Runtime.TargetMTA); MTAEditor temp = new MTAEditor(Runtime.TargetMTA) { ShowHint = DockState.DockLeft }; temp.Text = Path.GetFileName(filename); AddDockedControl(temp); mtaEditors.Add(temp); } if (filename.EndsWith(".mtable")) { //project.openACMD(filename); Runtime.Moveset = new MovesetManager(filename); } if (filename.EndsWith("path.bin")) { Runtime.TargetPath = new PathBin(filename); } else if (filename.EndsWith(".bin")) { //Note to whoever is readin this: //Eventually we need to look at the magic here (and also make all .bins look at magic) //Runtime.TargetCMR0 = new CMR0(); //Runtime.TargetCMR0.read(new FileData(filename)); PARAMEditor p = new PARAMEditor(filename) { ShowHint = DockState.Document }; p.Text = Path.GetFileName(filename); AddDockedControl(p); paramEditors.Add(p); } if (filename.EndsWith(".mdl0")) { MDL0Bones mdl0 = new MDL0Bones(); Runtime.TargetVBN = mdl0.GetVBN(new FileData(filename)); } if (filename.EndsWith(".smd")) { Runtime.TargetVBN = new VBN(); SMD.read(filename, new SkelAnimation(), Runtime.TargetVBN); } if (filename.ToLower().EndsWith(".dae")) { DAEImportSettings m = new DAEImportSettings(); m.ShowDialog(); if (m.exitStatus == DAEImportSettings.Opened) { if (Runtime.ModelContainers.Count < 1) { Runtime.ModelContainers.Add(new ModelContainer()); } Collada.DAEtoNUD(filename, Runtime.ModelContainers[0]); // apply settings m.Apply(Runtime.ModelContainers[0].nud); Runtime.ModelContainers[0].nud.MergePoly(); meshList.refresh(); } } if (filename.EndsWith(".mbn")) { MBN m = new MBN(); m.Read(filename); ModelContainer con = new ModelContainer(); BCH b = new BCH(); con.bch = b; b.mbn = m; b.Read("C:\\s\\Smash\\extract\\data\\fighter\\lucas\\Ness3DS - h00\\normal.bch"); Runtime.ModelContainers.Add(con); } /*if (filename.EndsWith(".bch")) * { * ModelContainer con = new ModelContainer(); * BCH b = new BCH(); * b.Read(filename); * con.bch = b; * Runtime.ModelContainers.Add(con); * }*/ if (filename.EndsWith(".nud")) { openNud(filename); } if (filename.EndsWith(".moi")) { MOI moi = new MOI(filename); AddDockedControl(new MOIEditor(moi) { ShowHint = DockState.DockRight }); } if (filename.EndsWith(".wrkspc")) { Workspace = new WorkspaceManager(project); Workspace.OpenWorkspace(filename); } if (Runtime.TargetVBN != null) { ModelContainer m = new ModelContainer(); m.vbn = Runtime.TargetVBN; Runtime.ModelContainers.Add(m); if (filename.EndsWith(".smd")) { m.nud = SMD.toNUD(filename); meshList.refresh(); } leftPanel.treeRefresh(); } else { foreach (ModelContainer m in Runtime.ModelContainers) { if (m.vbn != null) { Runtime.TargetVBN = Runtime.ModelContainers[0].vbn; break; } } } // Don't want to mess up the project tree if we // just set it up already if (!filename.EndsWith(".wrkspc")) { project.fillTree(); } }
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");*/ }
public void Read(string filename, BFRES bfres, AnimationGroupNode ThisAnimation, ModelContainer modelContainer) { Console.WriteLine("Reading Material Animations ..."); ResFile b = new ResFile(filename); ThisAnimation.Text = "Material Animations"; TreeNode dummy = new TreeNode() { Text = "Animation Set" }; int i = 0; foreach (MaterialAnim vis in b.MaterialAnims) { modelContainer.BFRES_MTA = new BFRES_MTA(vis); ThisAnimation.Nodes.Add(modelContainer.BFRES_MTA); } }