private void AddSkeletonAnims(ResU.ResFile resFile) { FskaFolder FSKA = new FskaFolder(); FSKA.LoadAnimations(resFile, BFRESRender); Nodes.Add(FSKA); }
public static void WriteSkeletalAnimations(XmlWriter writer, ResU.ResFile res) { for (int i = 0; i < res.SkeletalAnims.Count; i++) { WriteSkeletalAnimation(writer, res.SkeletalAnims[i]); } }
public void LoadFile(ResU.ResFile resFileU) { ResFileNode.Load(resFileU); BfresWiiU.Read(this, resFileU, ResFileNode); UpdateVertexData(); UpdateTextureMaps(); }
public static ResNX.ResFile BFRESConvertWiiUToSwitch(ResU.ResFile resFileU) { ResNX.ResFile resFile = new ResNX.ResFile(); foreach (var model in resFileU.Models) { } return(resFile); }
private void AddSkeletonAnims(ResU.ResFile resFile) { FskaFolder fksaFolder = new FskaFolder(); Nodes.Add(fksaFolder); foreach (ResU.SkeletalAnim ska in resFile.SkeletalAnims.Values) { BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name); skeletonAnim.Read(ska, resFile); fksaFolder.Nodes.Add(skeletonAnim); } }
public void Replace(string FileName, ResFile resFileNX, ResU.ResFile resFileU) { if (resFileNX != null) { SceneAnim.Import(FileName); SceneAnim.Name = Text; } else { SceneAnimU.Import(FileName, resFileU); SceneAnimU.Name = Text; } }
public void Replace(string FileName, ResFile resFileNX, ResU.ResFile resFileU) { if (resFileNX != null) { VisibilityAnim.Import(FileName); VisibilityAnim.Name = Text; } else { VisibilityAnimU.Import(FileName, resFileU); VisibilityAnimU.Name = Text; } }
private void AddFTEXTextures(ResU.ResFile resFile) { FTEXContainer ftexContainer = new FTEXContainer(); foreach (ResU.Texture tex in resFile.Textures.Values) { string TextureName = tex.Name; FTEX texture = new FTEX(); texture.Read(tex); ftexContainer.Nodes.Add(texture); ftexContainer.Textures.Add(texture.Text, texture); } PluginRuntime.ftexContainers.Add(ftexContainer); Nodes.Add(ftexContainer); }
private void AddFTEXTextures(ResU.ResFile resFile) { MessageBox.Show("Note! Textures are disabled atm."); return; FTEXContainer ftexContainer = new FTEXContainer(); Nodes.Add(ftexContainer); foreach (ResU.Texture tex in resFile.Textures.Values) { string TextureName = tex.Name; FTEX texture = new FTEX(); texture.Read(tex); ftexContainer.Nodes.Add(texture); ftexContainer.Textures.Add(texture.Text, texture); } PluginRuntime.ftexContainers.Add(ftexContainer); }
static void Main(string[] args) { if (args.Length == 0) { FilePath = (AssetDir + "Npc_Gerudo_Queen.bfres"); OutputDir = "../../../../../MedianDumps/"; } else { FilePath = args[0]; OutputDir = args[1]; } FileName = Path.GetFileNameWithoutExtension(FilePath); ResU.ResFile res; // Decompress sbfres with Yaz0 if (FilePath.EndsWith(".sbfres")) { res = new ResU.ResFile(new System.IO.MemoryStream(EveryFileExplorer.YAZ0.Decompress(FilePath))); } else { res = new ResU.ResFile(FilePath); } // Check if it is a WiiU file or not using (FileReader reader = new FileReader(FilePath, true)) { reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian; reader.Position = 4; Program.AssertAndLog(Program.ErrorType.eNonWiiUFile, reader.ReadInt32() != 0x20202020, "This is not a WiiU file."); //if( reader.ReadInt32() != 0x20202020 ) // IsWiiU = true; reader.Position = 0; } // Begin main writing WriteResToXML(res); }
public void Replace(string FileName, ResFile resFileNX, ResU.ResFile resFileU) { string ext = Utils.GetExtension(FileName); if (ext == ".bfska") { if (GetResFileU() != null) { SkeletalAnimU.Import(FileName, GetResFileU()); SkeletalAnimU.Name = Text; LoadAnim(SkeletalAnimU); } else { SkeletalAnim.Import(FileName); SkeletalAnim.Name = Text; LoadAnim(SkeletalAnim); } } else if (ext == ".seanim") { FromSeanim(FileName); } }
public static void WriteResToXML(ResU.ResFile res) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = " "; settings.NewLineOnAttributes = false; settings.OmitXmlDeclaration = true; settings.Encoding = new UTF8Encoding(false); // The false means, do not emit the BOM. if (!Directory.Exists(Program.OutputDir)) { Directory.CreateDirectory(Program.OutputDir); } XmlWriter writer = XmlWriter.Create(Program.OutputDir + FileName + ".xml", settings); writer.WriteStartDocument(); writer.WriteStartElement("BFRES"); if (res.Models.Count > 0) { for (int ii = 0; ii < res.Models.Count; ii++) { FMDL fMDL = new FMDL(); fMDL.WriteFMDLData(writer, res.Models[ii]); } } if (res.Textures.Count > 0) { writer.WriteStartElement("FTEXes"); for (int ii = 0; ii < res.Textures.Count; ii++) { JPTexture jpTexture = new JPTexture(); jpTexture.Read(res.Textures[ii]); if (jpTexture.isTex2) { for (int i = 1; i < jpTexture.MipCount; i++) { if (!Directory.Exists(OutputDir + "Mips/")) { Directory.CreateDirectory(OutputDir + "Mips/"); } jpTexture.SaveBitMap(OutputDir + "Mips/" + jpTexture.Name + i + ".tga", false, false, 0, i); } } else { if (!Directory.Exists(OutputDir + "Textures/")) { Directory.CreateDirectory(OutputDir + "Textures/"); } jpTexture.SaveBitMap(OutputDir + "Textures/" + jpTexture.Name + ".tga"); } FTEX.WriteFTEXData(writer, res.Textures[ii]); } writer.WriteEndElement(); } if (res.SkeletalAnims.Count > 0) { writer.WriteStartElement("FSKA"); FSKA.WriteSkeletalAnimations(writer, res); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); }
public void Replace(string FileName, ResFile resFileNX, ResU.ResFile resFileU) { string ext = Utils.GetExtension(FileName); if (ext == ".bfska") { bool IsSwitch = BfresUtilies.IsSubSectionSwitch(FileName); if (resFileU != null) { //If it's a switch animation try to conver it to wii u if (IsSwitch) { var ska = new SkeletalAnim(); ska.Import(FileName); SkeletalAnimU = BfresPlatformConverter.FSKAConvertSwitchToWiiU(ska); SkeletalAnimU.Name = Text; LoadAnim(SkeletalAnimU); } else { SkeletalAnimU.Import(FileName, resFileU); SkeletalAnimU.Name = Text; LoadAnim(SkeletalAnimU); } } else { if (IsSwitch) { SkeletalAnim.Import(FileName); SkeletalAnim.Name = Text; LoadAnim(SkeletalAnim); } else { //Create a new wii u skeletal anim and try to convert it instead var ska = new ResU.SkeletalAnim(); ska.Import(FileName, new ResU.ResFile()); SkeletalAnim = BfresPlatformConverter.FSKAConvertWiiUToSwitch(ska); SkeletalAnim.Name = Text; LoadAnim(SkeletalAnim); } } } else if (ext == ".anim") { FromAnim(FileName); } else if (ext == ".seanim") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { var ska = FromGeneric(SEANIM.Read(FileName, skeleton)); ska.Loop = this.CanLoop; UpdateAnimation(ska); } else { STErrorDialog.Show("No matching skeleton bones found to assign!", "Skeleton Importer", ""); } } else if (ext == ".smd") { STSkeleton skeleton = GetActiveSkeleton(); if (skeleton != null) { var ska = FromGeneric(SMD.Read(FileName, skeleton)); ska.Loop = this.CanLoop; UpdateAnimation(ska); } else { STErrorDialog.Show("No matching skeleton bones found to assign!", "Skeleton Importer", ""); } } else if (ext == ".chr0") { FromChr0(FileName, resFileU != null); } else if (ext == ".dae") { // FromAssimp(FileName, resFileU != null); } else if (ext == ".fbx") { // FromAssimp(FileName, resFileU != null); } }
//Function addes shapes, vertices and meshes public void AddOjects(string FileName, ResFile resFileNX, ResU.ResFile resFileU, bool Replace = true) { int totalSkinCountLimiter = 0; bool IsWiiU = (resFileU != null); if (shapes.Count > 0) { totalSkinCountLimiter = shapes[0].VertexSkinCount; } int MatStartIndex = materials.Count; string ext = System.IO.Path.GetExtension(FileName); ext = ext.ToLower(); switch (ext) { case ".bfobj": Cursor.Current = Cursors.WaitCursor; if (Replace) { shapes.Clear(); Nodes["FshpFolder"].Nodes.Clear(); } if (IsWiiU) { var shpS = new ResU.Shape(); var vertexBufferU = new ResU.VertexBuffer(); shpS.Import(FileName, vertexBufferU, resFileU); FSHP shapeS = new FSHP(); shapeS.ShapeU = shpS; BfresWiiU.ReadShapesVertices(shapeS, shpS, vertexBufferU, this); shapes.Add(shapeS); Nodes["FshpFolder"].Nodes.Add(shapeS); } else { Shape shpS = new Shape(); VertexBuffer vertexBuffer = new VertexBuffer(); shpS.Import(FileName, vertexBuffer); FSHP shapeS = new FSHP(); shapeS.Shape = shpS; BfresSwitch.ReadShapesVertices(shapeS, shpS, vertexBuffer, this); shapes.Add(shapeS); Nodes["FshpFolder"].Nodes.Add(shapeS); } IsEdited = true; Cursor.Current = Cursors.Default; break; case ".bfmdl": Cursor.Current = Cursors.WaitCursor; if (Replace) { shapes.Clear(); Nodes["FshpFolder"].Nodes.Clear(); materials.Clear(); Nodes["FmatFolder"].Nodes.Clear(); } if (IsWiiU) { var mdlU = new ResU.Model(); mdlU.Import(FileName, resFileU); mdlU.Name = Text; BfresWiiU.ReadModel(this, mdlU); } else { Model mdl = new Model(); mdl.Import(FileName, resFileNX); mdl.Name = Text; Console.WriteLine(mdl.ShapeCount); Console.WriteLine(mdl.MaterialCount); Console.WriteLine(mdl.VertexBufferCount); Console.WriteLine(mdl.Skeleton.Bones.Count); BfresSwitch.ReadModel(this, mdl); } IsEdited = true; Cursor.Current = Cursors.Default; break; case ".csv": CsvModel csvModel = new CsvModel(); csvModel.LoadFile(new System.IO.FileStream(FileName, System.IO.FileMode.Open), true); if (csvModel.objects.Count == 0) { MessageBox.Show("No models found!"); return; } BfresModelImportSettings csvsettings = new BfresModelImportSettings(); csvsettings.DisableMaterialEdits(); csvsettings.SkinCountLimit = totalSkinCountLimiter; csvsettings.SetModelAttributes(csvModel.objects[0]); if (csvsettings.ShowDialog() == DialogResult.OK) { if (Replace) { shapes.Clear(); Nodes["FshpFolder"].Nodes.Clear(); } Cursor.Current = Cursors.WaitCursor; foreach (STGenericObject obj in csvModel.objects) { FSHP shape = new FSHP(); Nodes["FshpFolder"].Nodes.Add(shape); shapes.Add(shape); shape.VertexBufferIndex = shapes.Count; shape.vertices = obj.vertices; shape.MaterialIndex = 0; shape.vertexAttributes = csvsettings.CreateNewAttributes(); shape.BoneIndex = 0; shape.Text = obj.ObjectName; shape.lodMeshes = obj.lodMeshes; shape.CreateNewBoundingBoxes(); shape.CreateBoneList(obj, this); shape.CreateIndexList(obj, this); //Todo find better way. Currently uses import settings now shape.ApplyImportSettings(csvsettings, GetMaterial(shape.MaterialIndex)); shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount(); shape.BoneIndices = shape.GetIndices(Skeleton); shape.SaveShape(IsWiiU); shape.SaveVertexBuffer(); if (IsWiiU) { shape.ShapeU.SubMeshBoundingIndices = new List <ushort>(); shape.ShapeU.SubMeshBoundingIndices.Add(0); shape.ShapeU.SubMeshBoundingNodes = new List <ResU.BoundingNode>(); shape.ShapeU.SubMeshBoundingNodes.Add(new ResU.BoundingNode() { LeftChildIndex = 0, NextSibling = 0, SubMeshIndex = 0, RightChildIndex = 0, Unknown = 0, SubMeshCount = 1, }); } if (IsWiiU) { BfresWiiU.ReadShapesVertices(shape, shape.ShapeU, shape.VertexBufferU, this); } else { BfresSwitch.ReadShapesVertices(shape, shape.Shape, shape.VertexBuffer, this); } } Cursor.Current = Cursors.Default; } IsEdited = true; break; default: AssimpData assimp = new AssimpData(); assimp.LoadFile(FileName); if (assimp.objects.Count == 0) { MessageBox.Show("No models found!"); return; } BfresModelImportSettings settings = new BfresModelImportSettings(); settings.SetModelAttributes(assimp.objects[0]); if (settings.ShowDialog() == DialogResult.OK) { bool UseMats = settings.ExternalMaterialPath != string.Empty; if (Replace) { shapes.Clear(); Nodes["FshpFolder"].Nodes.Clear(); } Cursor.Current = Cursors.WaitCursor; if (Replace && UseMats) { materials.Clear(); Nodes["FmatFolder"].Nodes.Clear(); MatStartIndex = 0; } if (UseMats) { foreach (STGenericMaterial mat in assimp.materials) { FMAT fmat = new FMAT(); if (IsWiiU) { fmat.MaterialU = new ResU.Material(); fmat.MaterialU.Import(settings.ExternalMaterialPath, resFileU); BfresWiiU.ReadMaterial(fmat, fmat.MaterialU); } else { fmat.Material = new Material(); fmat.Material.Import(settings.ExternalMaterialPath); fmat.ReadMaterial(fmat.Material); } fmat.Text = mat.Text; //Setup placeholder textures //Note we can't add/remove samplers so we must fill these slots foreach (var t in fmat.TextureMaps) { t.wrapModeS = 0; t.wrapModeT = 0; switch (t.Type) { case STGenericMatTexture.TextureType.Diffuse: t.Name = "Basic_Alb"; break; case STGenericMatTexture.TextureType.Emission: t.Name = "Basic_Emm"; break; case STGenericMatTexture.TextureType.Normal: t.Name = "Basic_Nrm"; break; case STGenericMatTexture.TextureType.Specular: t.Name = "Basic_Spm"; break; case STGenericMatTexture.TextureType.SphereMap: t.Name = "Basic_Sphere"; break; case STGenericMatTexture.TextureType.Metalness: t.Name = "Basic_Mtl"; break; case STGenericMatTexture.TextureType.Roughness: t.Name = "Basic_Rgh"; break; case STGenericMatTexture.TextureType.MRA: t.Name = "Basic_MRA"; break; case STGenericMatTexture.TextureType.Shadow: t.Name = "Basic_Bake_st0"; break; case STGenericMatTexture.TextureType.Light: t.Name = "Basic_Bake_st1"; break; } } if (PluginRuntime.bntxContainers.Count > 0 && Parent != null) { foreach (var node in Parent.Parent.Nodes) { if (node is BNTX) { var bntx = (BNTX)node; bntx.ImportBasicTextures("Basic_Alb"); bntx.ImportBasicTextures("Basic_Nrm"); bntx.ImportBasicTextures("Basic_Spm"); bntx.ImportBasicTextures("Basic_Sphere"); bntx.ImportBasicTextures("Basic_Mtl"); bntx.ImportBasicTextures("Basic_Rgh"); bntx.ImportBasicTextures("Basic_MRA"); bntx.ImportBasicTextures("Basic_Bake_st0"); bntx.ImportBasicTextures("Basic_Bake_st1"); bntx.ImportBasicTextures("Basic_Emm"); } } } if (PluginRuntime.ftexContainers.Count > 0 && Parent != null) { foreach (var node in Parent.Parent.Nodes) { if (node is BFRESGroupNode) { if (((BFRESGroupNode)node).Type == BRESGroupType.Textures) { var ftexCont = (BFRESGroupNode)node; ftexCont.ImportBasicTextures("Basic_Alb"); ftexCont.ImportBasicTextures("Basic_Nrm"); ftexCont.ImportBasicTextures("Basic_Spm"); ftexCont.ImportBasicTextures("Basic_Sphere"); ftexCont.ImportBasicTextures("Basic_Mtl"); ftexCont.ImportBasicTextures("Basic_Rgh"); ftexCont.ImportBasicTextures("Basic_MRA"); ftexCont.ImportBasicTextures("Basic_Bake_st0"); ftexCont.ImportBasicTextures("Basic_Bake_st1"); ftexCont.ImportBasicTextures("Basic_Emm"); } } } } foreach (var tex in mat.TextureMaps) { foreach (var t in fmat.TextureMaps) { if (t.Type == tex.Type) { t.Name = tex.Name; t.wrapModeS = tex.wrapModeS; t.wrapModeT = tex.wrapModeT; t.wrapModeW = tex.wrapModeW; t.Type = tex.Type; } } } List <string> keyList = new List <string>(materials.Keys); fmat.Text = Utils.RenameDuplicateString(keyList, fmat.Text); if (IsWiiU) { fmat.MaterialU.Name = Text; fmat.SetMaterial(fmat.MaterialU, resFileU); } else { fmat.Material.Name = Text; fmat.SetMaterial(fmat.Material); } materials.Add(fmat.Text, fmat); Nodes["FmatFolder"].Nodes.Add(fmat); } } if (settings.ImportBones) { if (assimp.skeleton.bones.Count > 0) { Skeleton.bones.Clear(); Skeleton.node.Nodes.Clear(); if (IsWiiU) { BfresWiiU.SaveSkeleton(Skeleton, assimp.skeleton.bones); } else { BfresSwitch.SaveSkeleton(Skeleton, assimp.skeleton.bones); } } } if (materials.Count <= 0) { //Force material creation if there is none present FMAT fmat = new FMAT(); fmat.Text = "NewMaterial"; materials.Add(fmat.Text, fmat); Nodes["FmatFolder"].Nodes.Add(fmat); if (IsWiiU) { fmat.MaterialU = new ResU.Material(); fmat.MaterialU.Name = "NewMaterial"; BfresWiiU.ReadMaterial(fmat, fmat.MaterialU); } else { fmat.Material = new Material(); fmat.Material.Name = "NewMaterial"; fmat.ReadMaterial(fmat.Material); } } foreach (STGenericObject obj in assimp.objects) { FSHP shape = new FSHP(); Nodes["FshpFolder"].Nodes.Add(shape); shapes.Add(shape); shape.VertexBufferIndex = shapes.Count; shape.vertices = obj.vertices; shape.vertexAttributes = settings.CreateNewAttributes(); shape.BoneIndex = obj.BoneIndex; STConsole.WriteLine(Text + " " + obj.MaterialIndex); if (UseMats) { shape.MaterialIndex = obj.MaterialIndex + MatStartIndex; } else { shape.MaterialIndex = 0; } if (shape.MaterialIndex >= materials.Count) { shape.MaterialIndex = 0; } shape.Text = obj.ObjectName; shape.lodMeshes = obj.lodMeshes; shape.CreateNewBoundingBoxes(); shape.CreateBoneList(obj, this); shape.CreateIndexList(obj, this); shape.ApplyImportSettings(settings, GetMaterial(shape.MaterialIndex)); shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount(); shape.BoneIndices = shape.GetIndices(Skeleton); shape.SaveShape(IsWiiU); shape.SaveVertexBuffer(); if (IsWiiU) { shape.ShapeU.SubMeshBoundingIndices = new List <ushort>(); shape.ShapeU.SubMeshBoundingIndices.Add(0); shape.ShapeU.SubMeshBoundingNodes = new List <ResU.BoundingNode>(); shape.ShapeU.SubMeshBoundingNodes.Add(new ResU.BoundingNode() { LeftChildIndex = 0, NextSibling = 0, SubMeshIndex = 0, RightChildIndex = 0, Unknown = 0, SubMeshCount = 1, }); } List <string> keyList = shapes.Select(o => o.Text).ToList(); shape.Text = Utils.RenameDuplicateString(keyList, shape.Text); if (IsWiiU) { BfresWiiU.ReadShapesVertices(shape, shape.ShapeU, shape.VertexBufferU, this); } else { BfresSwitch.ReadShapesVertices(shape, shape.Shape, shape.VertexBuffer, this); } } IsEdited = true; Cursor.Current = Cursors.Default; } break; } if (IsEdited) { UpdateVertexData(); } }
public void Read(ResU.SkeletalAnim ska, ResU.ResFile b) { }
public static ResU.ResFile BFRESConvertSwitchToWiiU(ResNX.ResFile resFileNX) { ResU.ResFile resFile = new ResU.ResFile(); return(resFile); }
public void LoadFile(ResU.ResFile resFileU) { ResFileNode.Load(resFileU); }
public void Replace(string FileName, ResFile resFileNX, ResU.ResFile resFileU) { AddOjects(FileName, resFileNX, resFileU); }
public void Import(string[] FileNames, ResNX.ResFile resFileNX, ResU.ResFile resFileU) { if (Type == BRESGroupType.Textures) { ImportTexture(FileNames); return; } foreach (string FileName in FileNames) { string ResourceName = Path.GetFileNameWithoutExtension(FileName); string ResourceNameExt = Path.GetFileName(FileName); string extension = Path.GetExtension(FileName); switch (Type) { case BRESGroupType.Models: FMDL fmdl = NewModel(false); fmdl.Text = ResourceName; fmdl.Replace(FileName, resFileNX, resFileU); fmdl.UpdateVertexData(); AddNode(fmdl); break; case BRESGroupType.SkeletalAnim: FSKA fska = new FSKA(); fska.Text = ResourceName; if (IsWiiU) { fska.SkeletalAnimU = new ResU.SkeletalAnim(); } else { fska.SkeletalAnim = new ResNX.SkeletalAnim(); } fska.Replace(FileName, resFileNX, resFileU); Nodes.Add(fska); break; case BRESGroupType.ShaderParamAnim: if (IsWiiU) { FSHU fshu = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.ShaderParam); fshu.Text = ResourceName; fshu.Replace(FileName, resFileU); Nodes.Add(fshu); } else { FMAA fmaaPrm = new FMAA(new ResNX.MaterialAnim()); fmaaPrm.Text = ResourceName; fmaaPrm.Replace(FileName); Nodes.Add(fmaaPrm); } break; case BRESGroupType.ColorAnim: if (IsWiiU) { FSHU fclh = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.Color); fclh.Text = ResourceName; fclh.Replace(FileName, resFileU); Nodes.Add(fclh); } else { FMAA fmaaClr = new FMAA(new ResNX.MaterialAnim()); fmaaClr.Text = ResourceName; fmaaClr.Replace(FileName); Nodes.Add(fmaaClr); } break; case BRESGroupType.TexSrtAnim: if (IsWiiU) { FSHU fsth = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.TextureSrt); fsth.Text = ResourceName; fsth.Replace(FileName, resFileU); Nodes.Add(fsth); } else { FMAA fmaaSrt = new FMAA(new ResNX.MaterialAnim()); fmaaSrt.Text = ResourceName; fmaaSrt.Replace(FileName); Nodes.Add(fmaaSrt); } break; case BRESGroupType.TexPatAnim: if (IsWiiU) { FTXP ftxp = new FTXP(new ResU.TexPatternAnim()); ftxp.Text = ResourceName; ftxp.Replace(FileName, resFileU); Nodes.Add(ftxp); } else { FMAA fmaaTxp = new FMAA(new ResNX.MaterialAnim()); fmaaTxp.Text = ResourceName; fmaaTxp.Replace(FileName); Nodes.Add(fmaaTxp); } break; case BRESGroupType.BoneVisAnim: FVIS fbnv = new FVIS(); fbnv.Text = ResourceName; if (IsWiiU) { fbnv.VisibilityAnimU = new ResU.VisibilityAnim() { Type = ResU.VisibilityAnimType.Bone } } ; else { fbnv.VisibilityAnim = new ResNX.VisibilityAnim(); } fbnv.Replace(FileName, resFileNX, resFileU); Nodes.Add(fbnv); break; case BRESGroupType.MatVisAnim: if (IsWiiU) { FVIS fmtv = new FVIS(new ResU.VisibilityAnim() { Type = ResU.VisibilityAnimType.Material }); fmtv.Text = ResourceName; fmtv.Replace(FileName, resFileNX, resFileU); Nodes.Add(fmtv); } else { FMAA fmaaVis = new FMAA(new ResNX.MaterialAnim()); fmaaVis.Text = ResourceName; fmaaVis.Replace(FileName); Nodes.Add(fmaaVis); } break; case BRESGroupType.ShapeAnim: FSHA fsha = new FSHA(); fsha.Text = ResourceName; if (IsWiiU) { fsha.ShapeAnimU = new ResU.ShapeAnim(); } else { fsha.ShapeAnim = new ResNX.ShapeAnim(); } fsha.Replace(FileName, resFileNX, resFileU); Nodes.Add(fsha); break; case BRESGroupType.SceneAnim: FSCN fscn = new FSCN(); fscn.Text = ResourceName; if (IsWiiU) { fscn.SceneAnimU = new ResU.SceneAnim(); } else { fscn.SceneAnim = new ResNX.SceneAnim(); } fscn.Replace(FileName, resFileNX, resFileU); Nodes.Add(fscn); break; case BRESGroupType.Embedded: ExternalFileData ext = new ExternalFileData(ResourceNameExt, File.ReadAllBytes(FileName)); ext.Replace(FileName); Nodes.Add(ext); break; case BRESGroupType.MaterialAnim: FMAA fmaa = new FMAA(new ResNX.MaterialAnim()); fmaa.Replace(FileName); Nodes.Add(fmaa); break; } } }
private void AddSceneAnims(ResU.ResFile resFile) { FscnFolder FSCN = new FscnFolder(); Nodes.Add(FSCN); }
public void Load(ResU.ResFile res) { resFileU = res; Text = resFileU.Name; if (resFileU.Models.Count > 0) { Nodes.Add(new FmdlFolder()); } if (resFileU.Textures.Count > 0) { AddFTEXTextures(resFileU); } if (resFileU.SkeletalAnims.Count > 0) { AddSkeletonAnims(resFileU); } if (resFileU.ShaderParamAnims.Count > 0) { Nodes.Add(new FshuFolder()); } if (resFileU.ColorAnims.Count > 0) { Nodes.Add(new FshuColorFolder()); } if (resFileU.TexSrtAnims.Count > 0) { Nodes.Add(new TexSrtFolder()); } if (resFileU.TexPatternAnims.Count > 0) { Nodes.Add(new TexPatFolder()); } if (resFileU.ShapeAnims.Count > 0) { Nodes.Add(new FshpaFolder()); } if (resFileU.BoneVisibilityAnims.Count > 0) { Nodes.Add(new FbnvFolder()); } if (resFileU.SceneAnims.Count > 0) { Nodes.Add(new FscnFolder()); } if (resFileU.ExternalFiles.Count > 0) { Nodes.Add(new EmbeddedFilesFolder()); } foreach (var anim in resFileU.ShaderParamAnims) { Nodes["FSHA"].Nodes.Add(anim.Key); } foreach (var anim in resFileU.ColorAnims) { Nodes["FSHAColor"].Nodes.Add(anim.Key); } foreach (var anim in resFileU.TexSrtAnims) { Nodes["TEXSRT"].Nodes.Add(anim.Key); } foreach (var anim in resFileU.TexPatternAnims) { Nodes["TEXPAT"].Nodes.Add(anim.Key); } int ext = 0; foreach (var extfile in resFileU.ExternalFiles) { string Name = extfile.Key; FileReader f = new FileReader(extfile.Value.Data); string Magic = f.ReadMagic(0, 4); if (Magic == "FSHA") { Nodes["EXT"].Nodes.Add(new BfshaFileData(extfile.Value.Data, Name)); } else { Nodes["EXT"].Nodes.Add(new ExternalFileData(extfile.Value.Data, Name)); } f.Dispose(); f.Close(); ext++; } }
public void Import(string[] FileNames, ResNX.ResFile resFileNX, ResU.ResFile resFileU) { if (Type == BRESGroupType.Textures) { ImportTexture(FileNames); return; } foreach (string FileName in FileNames) { string ResourceName = Path.GetFileNameWithoutExtension(FileName); string extension = Path.GetExtension(FileName); switch (Type) { case BRESGroupType.Models: FMDL fmdl = new FMDL(); fmdl.Text = ResourceName; if (IsWiiU) { fmdl.ModelU = new ResU.Model(); fmdl.ModelU = new ResU.Model(); fmdl.ModelU.Name = ResourceName; var skeleton = new ResU.Skeleton(); //Create skeleton with empty bone skeleton.Bones.Add("Root", new ResU.Bone() { Name = "Root" }); fmdl.ModelU.Skeleton = skeleton; BfresWiiU.ReadModel(fmdl, fmdl.ModelU); ((BFRES)Parent).AddSkeletonDrawable(fmdl.Skeleton); } else { fmdl.Model = new ResNX.Model(); fmdl.Model.Name = ResourceName; //Create skeleton with empty bone var skeleton = new ResNX.Skeleton(); skeleton.Bones.Add(new ResNX.Bone() { Name = "Root" }); fmdl.Model.Skeleton = skeleton; BfresSwitch.ReadModel(fmdl, fmdl.Model); ((BFRES)Parent).AddSkeletonDrawable(fmdl.Skeleton); } fmdl.Replace(FileName, resFileNX, resFileU); Nodes.Add(fmdl); fmdl.UpdateVertexData(); break; case BRESGroupType.SkeletalAnim: FSKA fska = new FSKA(); fska.Text = ResourceName; if (IsWiiU) { fska.SkeletalAnimU = new ResU.SkeletalAnim(); } else { fska.SkeletalAnim = new ResNX.SkeletalAnim(); } fska.Replace(FileName, resFileNX, resFileU); Nodes.Add(fska); break; case BRESGroupType.ShaderParamAnim: FSHU fshu = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.ShaderParam); fshu.Text = ResourceName; fshu.Replace(FileName, resFileU); Nodes.Add(fshu); break; case BRESGroupType.ColorAnim: FSHU fclh = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.Color); fclh.Text = ResourceName; fclh.Replace(FileName, resFileU); Nodes.Add(fclh); break; case BRESGroupType.TexSrtAnim: FSHU fsth = new FSHU(new ResU.ShaderParamAnim(), MaterialAnimation.AnimationType.TextureSrt); fsth.Text = ResourceName; fsth.Replace(FileName, resFileU); Nodes.Add(fsth); break; case BRESGroupType.TexPatAnim: FTXP ftxp = new FTXP(new ResU.TexPatternAnim()); ftxp.Text = ResourceName; ftxp.Replace(FileName, resFileU); Nodes.Add(ftxp); break; case BRESGroupType.BoneVisAnim: FVIS fbnv = new FVIS(); fbnv.Text = ResourceName; if (IsWiiU) { fbnv.VisibilityAnimU = new ResU.VisibilityAnim() { Type = ResU.VisibilityAnimType.Bone } } ; else { fbnv.VisibilityAnim = new ResNX.VisibilityAnim(); } fbnv.Replace(FileName, resFileNX, resFileU); Nodes.Add(fbnv); break; case BRESGroupType.MatVisAnim: FVIS fmtv = new FVIS(new ResU.VisibilityAnim() { Type = ResU.VisibilityAnimType.Material }); fmtv.Text = ResourceName; fmtv.Replace(FileName, resFileNX, resFileU); Nodes.Add(fmtv); break; case BRESGroupType.ShapeAnim: FSHA fsha = new FSHA(); fsha.Text = ResourceName; if (IsWiiU) { fsha.ShapeAnimU = new ResU.ShapeAnim(); } else { fsha.ShapeAnim = new ResNX.ShapeAnim(); } fsha.Replace(FileName, resFileNX, resFileU); Nodes.Add(fsha); break; case BRESGroupType.SceneAnim: FSCN fscn = new FSCN(); fscn.Text = ResourceName; if (IsWiiU) { fscn.SceneAnimU = new ResU.SceneAnim(); } else { fscn.SceneAnim = new ResNX.SceneAnim(); } fscn.Replace(FileName, resFileNX, resFileU); Nodes.Add(fscn); break; case BRESGroupType.Embedded: ExternalFileData ext = new ExternalFileData(ResourceName, File.ReadAllBytes(FileName)); ext.Replace(FileName); Nodes.Add(ext); break; case BRESGroupType.MaterialAnim: FMAA fmaa = new FMAA(new ResNX.MaterialAnim(), MaterialAnimation.AnimationType.ShaderParam); fmaa.Replace(FileName); Nodes.Add(fmaa); break; } } }
private void ReplaceYaml(string FileName, ResFile ResFile) { var serializer = new Serializer(); var obj = serializer.Deserialize(new FileStream(FileName, FileMode.Open)); }