private void ExportExportableAnimation(object sender, EventArgs args) { if (FileTools.TryOpenSaveFileDialog(out string fileName, "Supported Files(*.smd, *.seanim, *.anim)|*.smd;*.seanim;*.anim")) { // need to get RSkeleton First for some types if (fileName.EndsWith(".smd") || fileName.EndsWith(".anim")) { Rendering.RSkeleton skeletonNode = null; if (FileTools.TryOpenFileDialog(out string skeletonFileName, "SKEL (*.nusktb)|*.nusktb")) { if (skeletonFileName != null) { SkelNode node = new SkelNode(skeletonFileName); node.Open(); skeletonNode = (Rendering.RSkeleton)node.GetRenderableNode(); } } if (skeletonNode == null) { MessageBox.Show("No Skeleton File Selected"); return; } if (fileName.EndsWith(".anim")) { bool ordinal = false; DialogResult dialogResult = MessageBox.Show("In most cases choose \"No\"", "Use ordinal bone order?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { ordinal = true; } IO_MayaANIM.ExportIOAnimationAsANIM(fileName, ((IExportableAnimationNode)((MenuItem)sender).Tag).GetIOAnimation(), skeletonNode, ordinal); } if (fileName.EndsWith(".smd")) { IO_SMD.ExportIOAnimationAsSMD(fileName, ((IExportableAnimationNode)((MenuItem)sender).Tag).GetIOAnimation(), skeletonNode); } } // other types like SEAnim go here if (fileName.EndsWith(".seanim")) { IO_SEANIM.ExportIOAnimation(fileName, ((IExportableAnimationNode)((MenuItem)sender).Tag).GetIOAnimation()); } } }
/// <summary> /// Loads a directory and all sub-directories into the filetree. /// </summary> /// <param name="folderPath"></param> private void LoadWorkspace(string folderPath) { var mainNode = new DirectoryNode(folderPath); mainNode.Open(); fileTree.Nodes.Add(mainNode); mainNode.Expand(); // Enable rendering of the model if we have directly selected a model file. // Nested ones won't render a model SkelNode skelNode = null; foreach (FileNode node in mainNode.Nodes) { if (node.Text?.EndsWith("numdlb") == true) { fileTree.SelectedNode = node as FileNode; } else if (skelNode == null && node is SkelNode) { skelNode = node as SkelNode; } } if (skelNode == null) { return; } foreach (FileNode node in mainNode.Nodes) { if (node is ScriptNode scriptNode) { scriptNode.SkelNode = skelNode; modelViewport.ScriptNode = scriptNode; //only do this once, there should only be one anyway break; } } ParamNodeContainer.SkelNode = skelNode; }
private static void AssignNodesAndSelectNumdlb(TreeView fileTree, ModelViewport modelViewport, DirectoryNode mainNode) { // Enable rendering of the model if we have directly selected a model file. // Nested ones won't render a model fileTree.Nodes.Add(mainNode); SkelNode skelNode = null; foreach (FileNode node in mainNode.Nodes) { if (node.Text.EndsWith("numdlb")) { fileTree.SelectedNode = node; modelViewport.HideExpressionMeshes(); } else if (skelNode == null && node is SkelNode) { skelNode = node as SkelNode; } } if (skelNode == null) { return; } foreach (FileNode node in mainNode.Nodes) { if (node is ScriptNode scriptNode) { scriptNode.SkelNode = skelNode; modelViewport.ScriptNode = scriptNode; //only do this once, there should only be one anyway break; } } ParamNodeContainer.SkelNode = skelNode; }