private void UpdateViewportSettings(bool UpdateRuntimeValues = false) { if (IsStartup) { return; } Viewport viewport = LibraryGUI.GetActiveViewport(); if (viewport == null) { return; } if (UpdateRuntimeValues) //Update only if necessary since it can be slow { viewport.LoadViewportRuntimeValues(); } viewport.UpdateViewport(); }
public void LoadCostume(string fileName) { List <BFRES> bfresFiles = new List <BFRES>(); var FileFormat = STFileLoader.OpenFileFormat(fileName); if (FileFormat is SARC) { foreach (var file in ((SARC)FileFormat).Files) { string ext = System.IO.Path.GetExtension(file.FileName); if (ext == ".bfres") { bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(new System.IO.MemoryStream(file.FileData), file.FileName)); } } } if (FileFormat is BFRES) { bfresFiles.Add((BFRES)FileFormat); } if (editor == null) { editor = new ObjectEditor(); LibraryGUI.CreateMdiWindow(editor); } if (MainCostume == null && bfresFiles.Count > 0) { MainCostume = bfresFiles[0]; } foreach (var bfres in bfresFiles) { editor.AddNode(bfres); bfres.LoadEditors(null); DiableLoadCheck(); } }
public void CreateNew(object sender, EventArgs args) { BFLIM bflim = new BFLIM(); bflim.CanSave = true; bflim.IFileInfo = new IFileInfo(); bflim.header = new Header(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; ofd.Filter = FileFilters.GTX; if (ofd.ShowDialog() != DialogResult.OK) { return; } FTEX ftex = new FTEX(); ftex.ReplaceTexture(ofd.FileName, TEX_FORMAT.BC3_UNORM_SRGB, 1, 0, bflim.SupportedFormats, false, true, false); if (ftex.texture != null) { bflim.Text = ftex.texture.Name; bflim.image = new Image(); bflim.image.Swizzle = (byte)ftex.texture.Swizzle; bflim.image.BflimFormat = FormatsWiiU.FirstOrDefault(x => x.Value == ftex.Format).Key; bflim.image.Height = (ushort)ftex.texture.Height; bflim.image.Width = (ushort)ftex.texture.Width; bflim.Format = FormatsWiiU[bflim.image.BflimFormat]; bflim.Width = bflim.image.Width; bflim.Height = bflim.image.Height; bflim.ImageData = ftex.texture.Data; var form = new GenericEditorForm(false, bflim.OpenForm()); LibraryGUI.CreateMdiWindow(form); bflim.UpdateForm(); } }
public override void OnClick(TreeView treeview) { var font = ToFont(); var texbox = new RichTextBox() { Multiline = true, BorderStyle = BorderStyle.None, Dock = DockStyle.Fill }; texbox.BackColor = FormThemes.BaseTheme.FormBackColor; texbox.ForeColor = FormThemes.BaseTheme.FormForeColor; UserControl editor = new UserControl(); editor.Controls.Add(texbox); LibraryGUI.LoadEditor(editor); editor.Text = Text; editor.Dock = DockStyle.Fill; editor.Font = font; texbox.Text = "Preview Text!"; }
private void OpenFormDialog(IFileFormat fileFormat) { UserControl form = GetEditorForm(fileFormat); form.Text = (((IFileFormat)fileFormat).FileName); var parentForm = LibraryGUI.GetActiveForm(); GenericEditorForm editorForm = new GenericEditorForm(true, form); editorForm.FormClosing += (sender, e) => FormClosing(sender, e, fileFormat); if (editorForm.ShowDialog() == DialogResult.OK) { if (fileFormat.CanSave) { var mem = new System.IO.MemoryStream(); fileFormat.Save(mem); ArchiveFileInfo.FileData = mem.ToArray(); UpdateEditor(); } } }
public override void OnClick(TreeView treeView) { if (Runtime.UseOpenGL) { if (viewport == null) { viewport = new Viewport(ObjectEditor.GetDrawableContainers()); viewport.Dock = DockStyle.Fill; } if (!DrawablesLoaded) { ObjectEditor.AddContainer(DrawableContainer); DrawablesLoaded = true; } viewport.ReloadDrawables(DrawableContainer); LibraryGUI.LoadEditor(viewport); viewport.Text = Text; } }
public void UpdateSingleMaterialTextureMaps(FMAT mat) { if (!Runtime.OpenTKInitialized) { return; } foreach (BNTX bntx in PluginRuntime.bntxContainers) { foreach (var t in mat.TextureMaps) { if (bntx.Textures.ContainsKey(t.Name)) { if (!bntx.Textures[t.Name].RenderableTex.GLInitialized) { bntx.Textures[t.Name].LoadOpenGLTexture(); } } } } LibraryGUI.UpdateViewport(); }
private void treeViewCustom1_AfterCheck(object sender, TreeViewEventArgs e) { UpdateViewport = false; if (e.Node is STGenericModel) { IsModelChecked = true; CheckChildNodes(e.Node, e.Node.Checked); IsModelChecked = false; } else if (e.Node is STGenericObject && !IsModelChecked) { UpdateViewport = true; } else if (e.Node is STBone && !IsModelChecked) { UpdateViewport = true; } if (UpdateViewport) { LibraryGUI.UpdateViewport(); } }
/// <summary> /// Saves the <see cref="IFileFormat"/> as a file from the given <param name="FileName"> /// </summary> /// <param name="IFileFormat">The format instance of the file being saved</param> /// <param name="FileName">The name of the file</param> /// <param name="Alignment">The Alignment used for compression. Used for Yaz0 compression type. </param> /// <param name="EnableDialog">Toggle for showing compression dialog</param> /// <returns></returns> public static void SaveFileFormat(IFileFormat FileFormat, string FileName, bool EnableDialog = true, string DetailsLog = "") { //These always get created on loading a file,however not on creating a new file if (FileFormat.IFileInfo == null) throw new System.NotImplementedException("Make sure to impliment a IFileInfo instance if a format is being created!"); Cursor.Current = Cursors.WaitCursor; FileFormat.FilePath = FileName; string compressionLog = ""; if (FileFormat.IFileInfo.FileIsCompressed || FileFormat.IFileInfo.InArchive || Path.GetExtension(FileName) == ".szs" || Path.GetExtension(FileName) == ".sbfres") { //Todo find more optmial way to handle memory with files in archives //Also make compression require streams var mem = new System.IO.MemoryStream(); FileFormat.Save(mem); mem = new System.IO.MemoryStream(mem.ToArray()); FileFormat.IFileInfo.DecompressedSize = (uint)mem.Length; var finalStream = CompressFileFormat( FileFormat.IFileInfo.FileCompression, mem, FileFormat.IFileInfo.FileIsCompressed, FileFormat.IFileInfo.Alignment, FileName, EnableDialog); compressionLog = finalStream.Item2; Stream compressionStream = finalStream.Item1; FileFormat.IFileInfo.CompressedSize = (uint)compressionStream.Length; compressionStream.ExportToFile(FileName); DetailsLog += "\n" + SatisfyFileTables(FileFormat, FileName, compressionStream, FileFormat.IFileInfo.DecompressedSize, FileFormat.IFileInfo.CompressedSize, FileFormat.IFileInfo.FileIsCompressed); compressionStream.Flush(); compressionStream.Close(); } else { //Check if a stream is active and the file is beinng saved to the same opened file if (FileFormat is ISaveOpenedFileStream && FileFormat.FilePath == FileName && File.Exists(FileName)) { string savedPath = Path.GetDirectoryName(FileName); string tempPath = Path.Combine(savedPath, "tempST.bin"); //Save a temporary file first to not disturb the opened file using (var fileStream = new FileStream(tempPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) { FileFormat.Save(fileStream); FileFormat.Unload(); //After saving is done remove the existing file File.Delete(FileName); //Now move and rename our temp file to the new file path File.Move(tempPath, FileName); FileFormat.Load(File.OpenRead(FileName)); var activeForm = LibraryGUI.GetActiveForm(); if (activeForm != null && activeForm is ObjectEditor) ((ObjectEditor)activeForm).ReloadArchiveFile(FileFormat); } } else { using (var fileStream = new FileStream(FileName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) { FileFormat.Save(fileStream); } } } if (compressionLog != string.Empty) MessageBox.Show($"File has been saved to {FileName}. Compressed time: {compressionLog}", "Save Notification"); else MessageBox.Show($"File has been saved to {FileName}", "Save Notification"); // STSaveLogDialog.Show($"File has been saved to {FileName}", "Save Notification", DetailsLog); Cursor.Current = Cursors.Default; }
public void LoadCostumes(string fileName) { editor = null; fileName = System.IO.Path.ChangeExtension(fileName, null); List <string> CostumeNames = new List <string>(); CostumeNames.Add($"{fileName}.szs"); CostumeNames.Add($"{fileName}Face.szs"); CostumeNames.Add($"{fileName}Eye.szs"); CostumeNames.Add($"{fileName}Head.szs"); CostumeNames.Add($"{fileName}HeadTexture.szs"); CostumeNames.Add($"{fileName}Under.szs"); CostumeNames.Add($"{fileName}HandL.szs"); CostumeNames.Add($"{fileName}HandR.szs"); CostumeNames.Add($"{fileName}HandTexture.szs"); CostumeNames.Add($"{fileName}BodyTexture.szs"); CostumeNames.Add($"{fileName}Shell.szs"); CostumeNames.Add($"{fileName}Tail.szs"); CostumeNames.Add($"{fileName}Hair.szs"); // CostumeNames.Add($"{fileName}Hakama.szs"); CostumeNames.Add($"{fileName}Skirt.szs"); // CostumeNames.Add($"{fileName}Poncho.szs"); CostumeNames.Add($"{fileName}Guitar.szs"); foreach (string path in CostumeNames) { Console.WriteLine("Path = " + path); if (System.IO.File.Exists(path)) { LoadCostume(path); } else { //Load default meshes unless it's these file names List <string> ExcludeFileList = new List <string>(new string[] { "MarioHack", "MarioDot", }); bool Exluded = ExcludeFileList.Any(path.Contains); if (Exluded == false) { string parent = System.IO.Directory.GetParent(path).FullName; if (path.Contains($"{fileName}Face")) { LoadCostume($"{parent}\\MarioFace.szs"); } else if (path.Contains($"{fileName}Eye")) { LoadCostume($"{parent}\\MarioEye.szs"); } else if (path.Contains($"{fileName}HeadTexture")) { LoadCostume($"{parent}\\MarioHeadTexture.szs"); } else if (path.Contains($"{fileName}Head")) { LoadCostume($"{parent}\\MarioHead.szs"); } else if (path.Contains($"{fileName}HandL")) { LoadCostume($"{parent}\\MarioHandL.szs"); } else if (path.Contains($"{fileName}HandR")) { LoadCostume($"{parent}\\MarioHandR.szs"); } else if (path.Contains($"{fileName}HandTexture")) { LoadCostume($"{parent}\\MarioHandTexture.szs"); } } } } BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor)); bfresEditor.DisplayAll = true; }
public void UpdateVertexData() { if (!Runtime.OpenTKInitialized) { return; } GenericRenderedObject.DisplayVertex[] Vertices; int[] Faces; int poffset = 0; int voffset = 0; List <GenericRenderedObject.DisplayVertex> Vs = new List <GenericRenderedObject.DisplayVertex>(); List <int> Ds = new List <int>(); foreach (GenericRenderedObject shape in Meshes) { List <GenericRenderedObject.DisplayVertex> pv = shape.CreateDisplayVertices(); Vs.AddRange(pv); int GroupOffset = 0; int groupIndex = 0; if (shape.PolygonGroups.Count > 0) { foreach (var group in shape.PolygonGroups) { group.Offset = poffset * 4; for (int i = 0; i < group.displayFaceSize; i++) { Ds.Add(shape.display[GroupOffset + i] + voffset); } poffset += group.displayFaceSize; GroupOffset += group.displayFaceSize; } voffset += pv.Count; } else if (shape.lodMeshes.Count > 0) { shape.Offset = poffset * 4; for (int i = 0; i < shape.lodMeshes[shape.DisplayLODIndex].displayFaceSize; i++) { Ds.Add(shape.display[i] + voffset); } poffset += shape.lodMeshes[shape.DisplayLODIndex].displayFaceSize; voffset += pv.Count; } } // Binds Vertices = Vs.ToArray(); Faces = Ds.ToArray(); // Bind only once! GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position); GL.BufferData <GenericRenderedObject.DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * GenericRenderedObject.DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements); GL.BufferData <int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw); LibraryGUI.UpdateViewport(); }
private void visibleChk_CheckedChanged(object sender, EventArgs e) { LibraryGUI.UpdateViewport(); }
public override void Delete() { ((BFRESGroupNode)Parent).RemoveChild(this); LibraryGUI.UpdateViewport(); //Update texture display }
public void OpenFile(string FileName, bool InActiveEditor = false) { if (File.Exists(FileName)) { SaveRecentFile(FileName); } object file = STFileLoader.OpenFileFormat(FileName); if (file == null) //File might not be supported so return { return; } Type objectType = file.GetType(); bool HasEditorActive = false; foreach (var inter in objectType.GetInterfaces()) { if (inter.IsGenericType && inter.GetGenericTypeDefinition() == typeof(IEditor <>)) { MethodInfo method = objectType.GetMethod("OpenForm"); MethodInfo methodFill = objectType.GetMethod("FillEditor"); var control = (UserControl)method.Invoke(file, new object[0]); methodFill.Invoke(file, new object[1] { control }); var form = new GenericEditorForm(false, control); TabDupeIndex = 0; form.Text = CheckTabDupes(((IFileFormat)file).FileName); form.MdiParent = this; form.Show(); HasEditorActive = true; } else if (inter.IsGenericType && inter.GetGenericTypeDefinition() == typeof(IEditorForm <>)) { MethodInfo method = objectType.GetMethod("OpenForm"); var form = (Form)method.Invoke(file, new object[0]); TabDupeIndex = 0; form.Text = CheckTabDupes(((IFileFormat)file).FileName); form.Show(); HasEditorActive = true; } } bool IsTreeNode = file is TreeNode; bool IsArchiveFile = file is IArchiveFile; if (!IsTreeNode && !IsArchiveFile || HasEditorActive) { SetFormatSettings(GetActiveIFileFormat()); return; } //ObjectEditor is for treenode or archive file types. Editors will be on the right side, treenodes on the left SetFormatSettings((IFileFormat)file); //Check for active object editors Form editor = (Form)LibraryGUI.GetActiveForm(); bool useActiveEditor = false; if (editor != null && editor is ObjectEditor) { //If any are active and we want it to be a new tab then create an instance of one if (InActiveEditor || ((ObjectEditor)editor).AddFilesToActiveEditor) { useActiveEditor = true; } } bool IsEditorActive = editor != null; if (!useActiveEditor || !IsEditorActive) { editor = new ObjectEditor(((IFileFormat)file)); editor.MdiParent = this; editor.Text = CheckTabDupes(((IFileFormat)file).FileName); editor.Show(); ((ObjectEditor)editor).SelectFirstNode(); if (file is TreeNodeFile) { ((TreeNodeFile)file).OnAfterAdded(); } } else { if (IsArchiveFile) { ((ObjectEditor)editor).AddIArchiveFile((IFileFormat)file); } else { AddObjectEditorFile(((TreeNode)file), (ObjectEditor)editor, false); } } SetFormatSettings(GetActiveIFileFormat()); }
public override void UpdateVertexData() { if (!Runtime.OpenTKInitialized) { return; } UpdateModelList(); Loaded = false; DisplayVertex[] Vertices; int[] Faces; int poffset = 0; int voffset = 0; List <DisplayVertex> Vs = new List <DisplayVertex>(); List <int> Ds = new List <int>(); int TotalShapeCount = models.Sum(b => b.shapes.Count); int value = 0; for (int m = 0; m < models.Count; m++) { //Reset min/max models[m].MaxPosition = new Vector3(0); models[m].MinPosition = new Vector3(0); for (int shp = 0; shp < models[m].shapes.Count; shp++) { //Update render pass aswell CheckRenderPass(models[m].shapes[shp].GetFMAT()); models[m].shapes[shp].Offset = poffset * 4; List <DisplayVertex> pv = models[m].shapes[shp].CreateDisplayVertices(models[m]); Vs.AddRange(pv); for (int i = 0; i < models[m].shapes[shp].lodMeshes[models[m].shapes[shp].DisplayLODIndex].displayFaceSize; i++) { Ds.Add(models[m].shapes[shp].display[i] + voffset); } poffset += models[m].shapes[shp].lodMeshes[models[m].shapes[shp].DisplayLODIndex].displayFaceSize; voffset += pv.Count; } } // Binds Vertices = Vs.ToArray(); Faces = Ds.ToArray(); // Bind only once! GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position); GL.BufferData <DisplayVertex>(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * DisplayVertex.Size), Vertices, BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements); GL.BufferData <int>(BufferTarget.ElementArrayBuffer, (IntPtr)(Faces.Length * sizeof(int)), Faces, BufferUsageHint.StaticDraw); LibraryGUI.UpdateViewport(); Loaded = true; }
private void OnPropertyEditorChanged() { imageEditor.UpdateMipDisplay(); LibraryGUI.UpdateViewport(); }
public void LoadEditors(TreeNode Wrapper, Action OnPropertyChanged) { BcresEditor bcresEditor = (BcresEditor)LibraryGUI.GetActiveContent(typeof(BcresEditor)); bool HasModels = RenderedBcres.Models.Count > 0; if (bcresEditor == null) { bcresEditor = new BcresEditor(HasModels); bcresEditor.Dock = DockStyle.Fill; LibraryGUI.LoadEditor(bcresEditor); } if (!DrawablesLoaded) { ObjectEditor.AddContainer(DrawableContainer); for (int m = 0; m < RenderedBcres.Models.Count; m++) { if (RenderedBcres.Models[m].Skeleton.Renderable != null) { DrawableContainer.Drawables.Add(RenderedBcres.Models[m].Skeleton.Renderable); } } DrawablesLoaded = true; } if (Runtime.UseOpenGL) { bcresEditor.LoadViewport(this, DrawableContainer); } if (Wrapper is BcresTextureMapWrapper) { BcresSamplerEditorSimple editor = (BcresSamplerEditorSimple)bcresEditor.GetActiveEditor(typeof(BcresSamplerEditorSimple)); if (editor == null) { editor = new BcresSamplerEditorSimple(); editor.Dock = DockStyle.Fill; bcresEditor.LoadEditor(editor); } editor.LoadTexture(((BcresTextureMapWrapper)Wrapper)); } else if (Wrapper is BCRES) { LoadPropertyGrid(((BCRES)Wrapper).BcresFile, bcresEditor, OnPropertyChanged); } else if (Wrapper is MTOBWrapper) { LoadPropertyGrid(((MTOBWrapper)Wrapper).Material, bcresEditor, OnPropertyChanged); } else if (Wrapper is CMDLWrapper) { LoadPropertyGrid(((CMDLWrapper)Wrapper).Model, bcresEditor, OnPropertyChanged); } else if (Wrapper is CRESBoneWrapper) { LoadPropertyGrid(((CRESBoneWrapper)Wrapper).Bone, bcresEditor, OnPropertyChanged); } else if (Wrapper is CRESSkeletonWrapper) { LoadPropertyGrid(((CRESSkeletonWrapper)Wrapper).Skeleton, bcresEditor, OnPropertyChanged); } }
public void CreateNew(object sender, EventArgs args) { bool isBigEndian = false; if (sender.ToString() == "KCL (Wii U)") { isBigEndian = true; } OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Supported Formats|*.obj"; if (ofd.ShowDialog() != DialogResult.OK) { return; } string path = Path.Combine(Runtime.ExecutableDir, "KclMaterialPresets"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } CollisionPresetData.LoadPresets(Directory.GetFiles("KclMaterialPresets")); var form = Runtime.MainForm; var thread = new Thread(() => { //Load runtime values to gui handler MaterialWindowSettings.GamePreset = Runtime.CollisionSettings.KCLGamePreset; MaterialWindowSettings.Platform = Runtime.CollisionSettings.KCLGamePreset; MaterialWindowSettings.UsePresetEditor = Runtime.CollisionSettings.KCLUsePresetEditor; var result = CollisionLoader.CreateCollisionFromObject(form, ofd.FileName); CollisionLoader.CloseConsole(form); if (result.KclFie == null) { return; } SaveMaterialWindowSettings(); form.Invoke((MethodInvoker) delegate { string name = Path.GetFileNameWithoutExtension(ofd.FileName); KCL kcl = new KCL(); kcl.KclFile = result.KclFie; if (result.AttributeFile is MaterialAttributeBymlFile) { kcl.AttributeByml = ((MaterialAttributeBymlFile)result.AttributeFile).BymlFile; } kcl.Text = name; kcl.IFileInfo = new IFileInfo(); kcl.FileName = name; kcl.Renderer = new KCLRendering(); kcl.ReloadData(); kcl.DrawableContainer = new DrawableContainer() { Name = kcl.FileName, Drawables = new List <AbstractGlDrawable>() { kcl.Renderer }, }; ObjectEditor editor = new ObjectEditor(kcl); editor.Text = name; LibraryGUI.CreateMdiWindow(editor); }); }); thread.Start(); }
public void ReplaceTexture(string FileName, TEX_FORMAT DefaultFormat = TEX_FORMAT.UNKNOWN, uint MipMapCount = 0, uint swizzlePattern = 0, TEX_FORMAT[] SupportedFormats = null, bool DisplayBc4AlphaSetting = false, bool IsSwizzleReadOnly = false, bool IsTileModeReadOnly = false, bool IsFormatReadOnly = false, bool flipTextureY = false) { string ext = System.IO.Path.GetExtension(FileName); ext = ext.ToLower(); if (ext == ".bftex") { texture.Import(FileName, ((BFRESGroupNode)Parent).GetResFileU()); texture.Name = Text; IsReplaced = true; Read(texture); if (IsEditorActive()) { UpdateEditor(); } return; } GTXImporterSettings setting = SetImporterSettings(FileName, DefaultFormat); setting.FlipY = flipTextureY; setting.MipSwizzle = Tex2Swizzle; setting.SwizzlePattern = swizzlePattern; GTXTextureImporter importer = new GTXTextureImporter(); importer.DisplayBC4Alpha = DisplayBc4AlphaSetting; importer.ReadOnlySwizzle = IsSwizzleReadOnly; importer.ReadOnlyTileMode = IsSwizzleReadOnly; importer.ReadOnlyFormat = IsFormatReadOnly; if (MipMapCount != 0) { setting.MipCount = MipMapCount; importer.OverrideMipCounter = true; } if (SupportedFormats != null) { importer.LoadSupportedFormats(SupportedFormats); } importer.LoadSetting(setting); if (ext == ".dds") { if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); var tex = FromGx2Surface(surface, setting.TexName); UpdateTex(tex); texture.Name = Text; IsReplaced = true; Read(texture); LoadOpenGLTexture(); LibraryGUI.UpdateViewport(); } } else { if (importer.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; UseBc4Alpha = setting.UseBc4Alpha; if (setting.GenerateMipmaps && !setting.IsFinishedCompressing) { setting.DataBlockOutput.Clear(); setting.DataBlockOutput.Add(setting.GenerateMips()); } if (setting.DataBlockOutput != null) { var surface = GTXSwizzle.CreateGx2Texture(setting.DataBlockOutput[0], setting); var tex = FromGx2Surface(surface, setting.TexName); UpdateTex(tex); texture.Name = Text; IsReplaced = true; Read(texture); LoadOpenGLTexture(); LibraryGUI.UpdateViewport(); } else { MessageBox.Show("Something went wrong???"); } } } if (IsEditorActive() && IsReplaced) { UpdateEditor(); } }
public void ReplaceMatchingFile( ) { OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = ReplaceFilter; if (ofd.ShowDialog() == DialogResult.OK) { string extension = System.IO.Path.GetExtension(ofd.FileName); if (extension == ".bfskl") { if (SkeletonU != null) { ResU.Skeleton SkeltonTemp = new ResU.Skeleton(); SkeltonTemp.Import(ofd.FileName, GetResFileU()); foreach (BfresBone bone in fskl.bones) { if (SkeltonTemp.Bones.ContainsKey(bone.Text)) { bone.CopyData(SkeltonTemp.Bones[bone.Text]); } } BfresWiiU.ReadSkeleton(this, SkeletonU, fskl); } else { Skeleton SkeltonTemp = new Skeleton(); SkeltonTemp.Import(ofd.FileName); foreach (BfresBone bone in fskl.bones) { if (SkeltonTemp.BoneDict.ContainsKey(bone.Text)) { int index = SkeltonTemp.BoneDict.GetIndex(bone.Text); bone.CopyData(SkeltonTemp.Bones[index]); } } BfresSwitch.ReadSkeleton(this, Skeleton, fskl); } } if (extension == ".csv") { using (var reader = new System.IO.StringReader(System.IO.File.ReadAllText(ofd.FileName))) { string value = reader.ReadLine(); if (value != "Bones Geometry") { return; } float X = 0; float Y = 0; float Z = 0; float W = 0; while (true) { string line = reader.ReadLine(); if (line != null) { foreach (BfresBone bone in fskl.bones) { if (bone.Text == line) { string name = line; string scaleStr = reader.ReadLine(); string rotationStr = reader.ReadLine(); string translationStr = reader.ReadLine(); string[] valuesS = scaleStr.Replace("\n", "").Replace("\r", "").Split(','); string[] valuesR = rotationStr.Replace("\n", "").Replace("\r", "").Split(','); string[] valuesT = translationStr.Replace("\n", "").Replace("\r", "").Split(','); Syroot.Maths.Vector3F translate; Syroot.Maths.Vector3F scale; Syroot.Maths.Vector4F rotate; float.TryParse(valuesT[0], out X); float.TryParse(valuesT[1], out Y); float.TryParse(valuesT[2], out Z); translate = new Syroot.Maths.Vector3F(X, Y, Z); float.TryParse(valuesR[0], out X); float.TryParse(valuesR[1], out Y); float.TryParse(valuesR[2], out Z); float.TryParse(valuesR[3], out W); rotate = new Syroot.Maths.Vector4F(X, Y, Z, W); float.TryParse(valuesS[0], out X); float.TryParse(valuesS[1], out Y); float.TryParse(valuesS[2], out Z); scale = new Syroot.Maths.Vector3F(X, Y, Z); if (bone.BoneU != null) { bone.BoneU.Position = translate; bone.BoneU.Scale = scale; bone.BoneU.Rotation = rotate; } else { bone.Bone.Position = translate; bone.Bone.Scale = scale; bone.Bone.Rotation = rotate; } } } } else { break; } } if (SkeletonU != null) { BfresWiiU.ReadSkeleton(this, SkeletonU, fskl); } else { BfresSwitch.ReadSkeleton(this, Skeleton, fskl); } LibraryGUI.UpdateViewport(); } } } }
private void OnAnimationSelected(TreeNode Node) { if (Node is Animation) { Viewport viewport = LibraryGUI.GetActiveViewport(); if (viewport == null) { return; } if (((Animation)Node).Bones.Count <= 0) { ((Animation)Node).OpenAnimationData(); } string AnimName = 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)Node); running.Tag = Node; Queue <TreeNode> NodeQueue = new Queue <TreeNode>(); foreach (TreeNode n in treeViewCustom1.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 == Node) { continue; } if (NodeName.Equals(AnimName)) { running.Children.Add(n); } } if (n is AnimationGroupNode) { foreach (TreeNode tn in n.Nodes) { NodeQueue.Enqueue(tn); } } } catch { } } if (LibraryGUI.GetAnimationPanel() != null) { LibraryGUI.GetAnimationPanel().CurrentAnimation = running; } } if (Node is IAnimationContainer) { Viewport viewport = LibraryGUI.GetActiveViewport(); if (viewport == null) { return; } var running = ((IAnimationContainer)Node).AnimationController; if (LibraryGUI.GetAnimationPanel() != null) { Console.WriteLine($"running {running.Name}"); LibraryGUI.GetAnimationPanel().CurrentSTAnimation = running; } } }
public void UpdateViewport() { LibraryGUI.UpdateViewport(); }