private void SetTextureAnimation(FMAT material, Material matAnim) { if (matAnim.Samplers.Count == 0) { return; } //Loop through sampler list for texture anims //These store a list of indices (step curve) to grab a texture name list //Then we'll update the active texture foreach (SamplerKeyGroup samplerAnim in matAnim.Samplers) { foreach (MatTexture texture in material.TextureMaps) { if (texture.SamplerName == samplerAnim.Text) { texture.textureState = STGenericMatTexture.TextureState.Animated; texture.animatedTexName = samplerAnim.GetActiveTextureNameByFrame(Frame); } } } }
public void CopyMaterial(FMAT selectedMaterial) { CopyMaterialMenu menu = new CopyMaterialMenu(); menu.LoadMaterials(selectedMaterial.Text, GetModelList()); if (menu.ShowDialog() == DialogResult.OK) { foreach (TreeNode mdl in menu.materialTreeView.Nodes) { foreach (TreeNode n in mdl.Nodes) { if (n.Checked) { if (materials.ContainsKey(n.Text)) { SetCopiedMaterialData(menu, selectedMaterial, materials[n.Text]); } } } } Viewport.Instance.UpdateViewport(); } }
private void SetTextureAnimation(FMAT material, Material matAnim) { if (matAnim.Samplers.Count == 0) { return; } //Loop through sampler list for texture anims //These store a list of indices (step curve) to grab a texture name list //Then we'll update the active texture foreach (Material.Sampler samplerAnim in matAnim.Samplers) { foreach (MatTexture texture in material.TextureMaps) { if (texture.SamplerName == samplerAnim.Text) { texture.textureState = STGenericMatTexture.TextureState.Animated; uint index = (uint)samplerAnim.group.GetValue(Frame); texture.animatedTexName = Textures[(int)index]; } } } }
private void SetShaderParamAnimation(FMAT material, Material matAnim) { if (matAnim.Params.Count == 0) { return; } //Loop through param list for shader param anims //These store a list of values with offsets to the value //Then we'll update the active texture foreach (FSHU.BfresParamAnim paramAnim in matAnim.Params) { if (material.matparam.ContainsKey(paramAnim.Text)) { //First we get the active param that we want to alter BfresShaderParam prm = material.matparam[paramAnim.Text]; BfresShaderParam animatedprm = new BfresShaderParam(); if (!material.animatedMatParams.ContainsKey(prm.Name)) { material.animatedMatParams.Add(prm.Name, animatedprm); } animatedprm.Name = prm.Name; animatedprm.ValueUint = prm.ValueUint; animatedprm.ValueBool = prm.ValueBool; animatedprm.ValueFloat = prm.ValueFloat; animatedprm.ValueSrt2D = prm.ValueSrt2D; animatedprm.ValueSrt3D = prm.ValueSrt3D; animatedprm.ValueTexSrt = prm.ValueTexSrt; animatedprm.ValueTexSrtEx = prm.ValueTexSrtEx; foreach (var group in paramAnim.Values) { //The offset determines the value starting from 0. int index = 0; if (prm.ValueFloat != null) { if (group.AnimDataOffset != 0) { index = (int)group.AnimDataOffset / sizeof(float); } animatedprm.ValueFloat[index] = group.GetValue(Frame); } if (prm.ValueInt != null) { } if (prm.ValueUint != null) { } if (prm.ValueBool != null) { } if (prm.Type == ShaderParamType.Srt3D) { if (group.AnimDataOffset == 0) { prm.ValueSrt3D.Scaling.X = group.GetValue(Frame); } if (group.AnimDataOffset == 4) { prm.ValueSrt3D.Scaling.Y = group.GetValue(Frame); } if (group.AnimDataOffset == 8) { prm.ValueSrt3D.Scaling.Z = group.GetValue(Frame); } if (group.AnimDataOffset == 12) { prm.ValueSrt3D.Rotation.X = group.GetValue(Frame); } if (group.AnimDataOffset == 16) { prm.ValueSrt3D.Rotation.Y = group.GetValue(Frame); } if (group.AnimDataOffset == 20) { prm.ValueSrt3D.Rotation.Z = group.GetValue(Frame); } if (group.AnimDataOffset == 24) { prm.ValueSrt3D.Translation.X = group.GetValue(Frame); } if (group.AnimDataOffset == 28) { prm.ValueSrt3D.Translation.Y = group.GetValue(Frame); } if (group.AnimDataOffset == 32) { prm.ValueSrt3D.Translation.Z = group.GetValue(Frame); } } if (prm.Type == ShaderParamType.Srt2D) { if (group.AnimDataOffset == 0) { prm.ValueSrt2D.Scaling.X = group.GetValue(Frame); } if (group.AnimDataOffset == 4) { prm.ValueSrt2D.Scaling.Y = group.GetValue(Frame); } if (group.AnimDataOffset == 8) { prm.ValueSrt2D.Rotation = group.GetValue(Frame); } if (group.AnimDataOffset == 12) { prm.ValueSrt2D.Translation.X = group.GetValue(Frame); } if (group.AnimDataOffset == 16) { prm.ValueSrt2D.Translation.X = group.GetValue(Frame); } } if (prm.Type == ShaderParamType.TexSrt) { if (group.AnimDataOffset == 0) { prm.ValueTexSrt.Mode = (TexSrtMode)(uint)group.GetValue(Frame); } if (group.AnimDataOffset == 4) { prm.ValueTexSrt.Scaling.X = group.GetValue(Frame); } if (group.AnimDataOffset == 8) { prm.ValueTexSrt.Scaling.Y = group.GetValue(Frame); } if (group.AnimDataOffset == 12) { prm.ValueTexSrt.Rotation = group.GetValue(Frame); } if (group.AnimDataOffset == 16) { prm.ValueTexSrt.Translation.X = group.GetValue(Frame); } if (group.AnimDataOffset == 20) { prm.ValueTexSrt.Translation.Y = group.GetValue(Frame); } } if (prm.Type == ShaderParamType.TexSrtEx) { if (group.AnimDataOffset == 0) { prm.ValueTexSrtEx.Mode = (TexSrtMode)(uint)group.GetValue(Frame); } if (group.AnimDataOffset == 4) { prm.ValueTexSrtEx.Scaling.X = group.GetValue(Frame); } if (group.AnimDataOffset == 8) { prm.ValueTexSrtEx.Scaling.Y = group.GetValue(Frame); } if (group.AnimDataOffset == 12) { prm.ValueTexSrtEx.Rotation = group.GetValue(Frame); } if (group.AnimDataOffset == 16) { prm.ValueTexSrtEx.Translation.X = group.GetValue(Frame); } if (group.AnimDataOffset == 20) { prm.ValueTexSrtEx.Translation.Y = group.GetValue(Frame); } if (group.AnimDataOffset == 24) { prm.ValueTexSrtEx.MatrixPointer = (uint)group.GetValue(Frame); } } } } } }
private void SetMaterialVisualAnimation(FMAT material, Material matAnim) { }
private void EditMaterial(FMAT material, Material matAnim) { SetShaderParamAnimation(material, matAnim); }
//Function addes shapes, vertices and meshes public void AddOjects(string FileName, bool Replace = true) { bool IsWiiU = (GetResFileU() != null); 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(); } 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); Cursor.Current = Cursors.Default; break; case ".bfmdl": Cursor.Current = Cursors.WaitCursor; if (Replace) { shapes.Clear(); Nodes["FshpFolder"].Nodes.Clear(); } Model mdl = new Model(); mdl.Import(FileName, GetResFile()); mdl.Name = Text; shapes.Clear(); foreach (Shape shp in mdl.Shapes) { FSHP shape = new FSHP(); shape.Shape = shp; BfresSwitch.ReadShapesVertices(shape, shp, mdl.VertexBuffers[shp.VertexBufferIndex], this); shapes.Add(shape); Nodes["FshpFolder"].Nodes.Add(shape); } Cursor.Current = Cursors.Default; break; case ".csv": CsvModel csvModel = new CsvModel(); csvModel.LoadFile(FileName, true); if (csvModel.objects.Count == 0) { MessageBox.Show("No models found!"); return; } BfresModelImportSettings csvsettings = new BfresModelImportSettings(); csvsettings.DisableMaterialEdits(); 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(); shape.VertexBufferIndex = shapes.Count; shape.vertices = obj.vertices; shape.MaterialIndex = 0; shape.vertexAttributes = csvsettings.CreateNewAttributes(); shape.boneIndx = 0; shape.Text = obj.ObjectName; shape.lodMeshes = obj.lodMeshes; shape.CreateNewBoundingBoxes(); shape.CreateBoneList(obj, this); shape.CreateIndexList(obj, this); shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount(); shape.ApplyImportSettings(csvsettings, GetMaterial(shape.MaterialIndex)); shape.SaveShape(IsWiiU); shape.SaveVertexBuffer(IsWiiU); shape.BoneIndices = new List <ushort>(); Nodes["FshpFolder"].Nodes.Add(shape); shapes.Add(shape); } Cursor.Current = Cursors.Default; } 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) { if (Replace) { shapes.Clear(); Nodes["FshpFolder"].Nodes.Clear(); } Cursor.Current = Cursors.WaitCursor; if (Replace) { materials.Clear(); Nodes["FmatFolder"].Nodes.Clear(); MatStartIndex = 0; } foreach (STGenericMaterial mat in assimp.materials) { FMAT fmat = new FMAT(); if (settings.ExternalMaterialPath != string.Empty) { if (GetResFileU() != null) { fmat.MaterialU = new ResU.Material(); fmat.MaterialU.Import(settings.ExternalMaterialPath, GetResFileU()); 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) { foreach (var node in Parent.Parent.Nodes["EXT"].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"); } } } 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); materials.Add(fmat.Text, fmat); Nodes["FmatFolder"].Nodes.Add(fmat); if (GetResFileU() != null) { fmat.MaterialU.Name = Text; fmat.SetMaterial(fmat.MaterialU); } else { fmat.Material.Name = Text; fmat.SetMaterial(fmat.Material); } } foreach (STGenericObject obj in assimp.objects) { FSHP shape = new FSHP(); shape.VertexBufferIndex = shapes.Count; shape.vertices = obj.vertices; shape.VertexSkinCount = obj.MaxSkinInfluenceCount; shape.vertexAttributes = settings.CreateNewAttributes(); shape.boneIndx = obj.BoneIndex; shape.MaterialIndex = obj.MaterialIndex + MatStartIndex; 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.SaveShape(IsWiiU); shape.SaveVertexBuffer(IsWiiU); shape.BoneIndices = new List <ushort>(); List <string> keyList = shapes.Select(o => o.Text).ToList(); shape.Text = Utils.RenameDuplicateString(keyList, shape.Text); Nodes["FshpFolder"].Nodes.Add(shape); shapes.Add(shape); } Console.WriteLine("Finshed Importing Model"); Cursor.Current = Cursors.Default; } break; } UpdateVertexData(); }
public void ApplyImportSettings(BfresModelImportSettings settings, FMAT mat) { if (settings.FlipUVsVertical) { foreach (Vertex v in vertices) { v.uv0 = new Vector2(v.uv0.X, 1 - v.uv0.Y); } } if (settings.RecalculateNormals) { CalculateNormals(); } if (settings.Rotate90DegreesY) { TransformPosition(Vector3.Zero, new Vector3(90, 0, 0), new Vector3(1)); } if (settings.Rotate90DegreesNegativeY) { TransformPosition(Vector3.Zero, new Vector3(-90, 0, 0), new Vector3(1)); } if (settings.EnableTangents) { try { CalculateTangentBitangent(); } catch { MessageBox.Show($"Failed to generate tangents for mesh {Text}"); } } if (settings.SetDefaultParamData) { foreach (var param in mat.matparam.Values) { switch (param.Name) { case "const_color0": case "const_color1": case "const_color2": case "const_color3": case "base_color_mul_color": case "uniform0_mul_color": case "uniform1_mul_color": case "uniform2_mul_color": case "uniform3_mul_color": case "uniform4_mul_color": case "proc_texture_2d_mul_color": case "proc_texture_3d_mul_color": case "displacement1_color": case "ripple_emission_color": case "hack_color": case "stain_color": case "displacement_color": param.ValueFloat = new float[] { 1, 1, 1, 1 }; break; case "gsys_bake_st0": param.ValueFloat = new float[] { 1, 1, 0, 0 }; break; case "gsys_bake_st1": param.ValueFloat = new float[] { 1, 1, 0, 0 }; break; } } } }
public void SetMaterial(FMAT material) { ((FMDL)Parent.Parent).materials[material.Text] = material; }
public void ApplyImportSettings(BfresModelImportSettings settings, FMAT mat) { // VertexSkinCount = settings.SkinCountLimit; if (settings.FlipUVsVertical) { foreach (Vertex v in vertices) { v.uv0 = new Vector2(v.uv0.X, 1 - v.uv0.Y); } } if (settings.RecalculateNormals) { CalculateNormals(); } if (settings.Rotate90DegreesY) { TransformPosition(Vector3.Zero, new Vector3(90, 0, 0), new Vector3(1)); } if (settings.Rotate90DegreesNegativeY) { TransformPosition(Vector3.Zero, new Vector3(-90, 0, 0), new Vector3(1)); } if (settings.EnableTangents) { try { bool UseUVLayer2 = false; //for BOTW if it uses UV layer 2 for normal maps use second UV map if (Parent != null && GetMaterial().shaderassign.options.ContainsKey("uking_texture2_texcoord")) { float value = float.Parse(GetMaterial().shaderassign.options["uking_texture2_texcoord"]); UseUVLayer2 = (value == 1); } CalculateTangentBitangent(UseUVLayer2); } catch (Exception ex) { STErrorDialog.Show($"Failed to generate tangents for mesh {Text}", "Tangent Calculation", ex.ToString()); } } if (settings.SetDefaultParamData) { foreach (var param in mat.matparam.Values) { switch (param.Name) { case "const_color0": case "const_color1": case "const_color2": case "const_color3": case "base_color_mul_color": case "uniform0_mul_color": case "uniform1_mul_color": case "uniform2_mul_color": case "uniform3_mul_color": case "uniform4_mul_color": case "proc_texture_2d_mul_color": case "proc_texture_3d_mul_color": case "displacement1_color": case "ripple_emission_color": case "hack_color": case "stain_color": case "displacement_color": param.ValueFloat = new float[] { 1, 1, 1, 1 }; break; case "gsys_bake_st0": case "gsys_bake_st1": param.ValueFloat = new float[] { 1, 1, 0, 0 }; break; } } } }
//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(); } }