Update library and clean up some things
This commit is contained in:
parent
898003ddb2
commit
4e1c4a5266
@ -145,12 +145,14 @@ namespace FirstPlugin
|
||||
}
|
||||
private void SaveSwitch(MemoryStream mem)
|
||||
{
|
||||
var resFile = bfres.ResFileNode.resFile;
|
||||
|
||||
int CurMdl = 0;
|
||||
foreach (FMDL model in bfres.models)
|
||||
{
|
||||
bfres.resFile.Models[CurMdl].Shapes.Clear();
|
||||
bfres.resFile.Models[CurMdl].VertexBuffers.Clear();
|
||||
bfres.resFile.Models[CurMdl].Materials.Clear();
|
||||
resFile.Models[CurMdl].Shapes.Clear();
|
||||
resFile.Models[CurMdl].VertexBuffers.Clear();
|
||||
resFile.Models[CurMdl].Materials.Clear();
|
||||
|
||||
int i = 0;
|
||||
var duplicates = model.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c);
|
||||
@ -162,43 +164,45 @@ namespace FirstPlugin
|
||||
CheckMissingTextures(shape);
|
||||
BfresSwitch.SetShape(shape, shape.Shape);
|
||||
|
||||
bfres.resFile.Models[CurMdl].Shapes.Add(shape.Shape);
|
||||
bfres.resFile.Models[CurMdl].VertexBuffers.Add(shape.VertexBuffer);
|
||||
shape.Shape.VertexBufferIndex = (ushort)(bfres.resFile.Models[CurMdl].VertexBuffers.Count - 1);
|
||||
resFile.Models[CurMdl].Shapes.Add(shape.Shape);
|
||||
resFile.Models[CurMdl].VertexBuffers.Add(shape.VertexBuffer);
|
||||
shape.Shape.VertexBufferIndex = (ushort)(resFile.Models[CurMdl].VertexBuffers.Count - 1);
|
||||
|
||||
SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape);
|
||||
}
|
||||
foreach (FMAT mat in model.materials.Values)
|
||||
{
|
||||
BfresSwitch.SetMaterial(mat, mat.Material);
|
||||
bfres.resFile.Models[CurMdl].Materials.Add(mat.Material);
|
||||
resFile.Models[CurMdl].Materials.Add(mat.Material);
|
||||
}
|
||||
CurMdl++;
|
||||
}
|
||||
bfres.resFile.SkeletalAnims.Clear();
|
||||
resFile.SkeletalAnims.Clear();
|
||||
if (EditorRoot.Nodes.ContainsKey("FSKA"))
|
||||
{
|
||||
foreach (BfresSkeletonAnim ska in EditorRoot.Nodes["FSKA"].Nodes)
|
||||
{
|
||||
bfres.resFile.SkeletalAnims.Add(ska.SkeletalAnim);
|
||||
resFile.SkeletalAnims.Add(ska.SkeletalAnim);
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCheck();
|
||||
|
||||
BfresSwitch.WriteExternalFiles(bfres.resFile, EditorRoot);
|
||||
bfres.resFile.Save(mem);
|
||||
BfresSwitch.WriteExternalFiles(resFile, EditorRoot);
|
||||
resFile.Save(mem);
|
||||
}
|
||||
private void SaveWiiU(MemoryStream mem)
|
||||
{
|
||||
bfres.resFileU.Save(mem);
|
||||
var resFileU = bfres.ResFileNode.resFileU;
|
||||
|
||||
resFileU.Save(mem);
|
||||
|
||||
int CurMdl = 0;
|
||||
foreach (FMDL model in bfres.models)
|
||||
{
|
||||
bfres.resFileU.Models[CurMdl].Shapes.Clear();
|
||||
bfres.resFileU.Models[CurMdl].VertexBuffers.Clear();
|
||||
bfres.resFileU.Models[CurMdl].Materials.Clear();
|
||||
resFileU.Models[CurMdl].Shapes.Clear();
|
||||
resFileU.Models[CurMdl].VertexBuffers.Clear();
|
||||
resFileU.Models[CurMdl].Materials.Clear();
|
||||
|
||||
int i = 0;
|
||||
var duplicates = model.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c);
|
||||
@ -210,16 +214,16 @@ namespace FirstPlugin
|
||||
CheckMissingTextures(shape);
|
||||
BfresWiiU.SetShape(shape, shape.ShapeU);
|
||||
|
||||
bfres.resFileU.Models[CurMdl].Shapes.Add(shape.Text, shape.ShapeU);
|
||||
bfres.resFileU.Models[CurMdl].VertexBuffers.Add(shape.VertexBufferU);
|
||||
shape.ShapeU.VertexBufferIndex = (ushort)(bfres.resFileU.Models[CurMdl].VertexBuffers.Count - 1);
|
||||
resFileU.Models[CurMdl].Shapes.Add(shape.Text, shape.ShapeU);
|
||||
resFileU.Models[CurMdl].VertexBuffers.Add(shape.VertexBufferU);
|
||||
shape.ShapeU.VertexBufferIndex = (ushort)(resFileU.Models[CurMdl].VertexBuffers.Count - 1);
|
||||
|
||||
SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape);
|
||||
}
|
||||
foreach (FMAT mat in model.materials.Values)
|
||||
{
|
||||
BfresWiiU.SetMaterial(mat, mat.MaterialU);
|
||||
bfres.resFileU.Models[CurMdl].Materials.Add(mat.Text, mat.MaterialU);
|
||||
resFileU.Models[CurMdl].Materials.Add(mat.Text, mat.MaterialU);
|
||||
}
|
||||
CurMdl++;
|
||||
}
|
||||
|
@ -37,7 +37,16 @@ namespace Bfres.Structs
|
||||
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
foreach (var ext in Nodes)
|
||||
{
|
||||
if (ext is BinaryTextureContainer)
|
||||
{
|
||||
PluginRuntime.bntxContainers.Remove((BinaryTextureContainer)ext);
|
||||
}
|
||||
}
|
||||
|
||||
Nodes.Clear();
|
||||
Viewport.Instance.Refresh();
|
||||
}
|
||||
}
|
||||
public override void OnClick(TreeView treeView)
|
||||
|
@ -37,7 +37,7 @@ namespace Bfres.Structs
|
||||
foreach (FMAA fmaa in Nodes)
|
||||
{
|
||||
string FileName = folderPath + '\\' + fmaa.Text + ".bfmaa";
|
||||
((FMAA)fmaa).MaterialAnim.Export(FileName, fmaa.BFRESRender.resFile);
|
||||
((FMAA)fmaa).MaterialAnim.Export(FileName, fmaa.GetResFile());
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +62,10 @@ namespace Bfres.Structs
|
||||
public BFRESRender BFRESRender;
|
||||
public MaterialAnim MaterialAnim;
|
||||
|
||||
public ResFile GetResFile()
|
||||
{
|
||||
return ((ResourceFile)Parent.Parent).resFile;
|
||||
}
|
||||
public void Read(MaterialAnim anim)
|
||||
{
|
||||
MaterialAnim = anim;
|
||||
|
@ -65,13 +65,26 @@ namespace Bfres.Structs
|
||||
rename.Click += Rename;
|
||||
}
|
||||
|
||||
public BFRESRender BFRESRender;
|
||||
public bool Enabled = true;
|
||||
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
FormLoader.LoadMatEditor(this);
|
||||
}
|
||||
public ResFile GetResFile()
|
||||
{
|
||||
//ResourceFile -> FMDL -> Material Folder -> this
|
||||
return ((FMDL)Parent.Parent).GetResFile();
|
||||
}
|
||||
public ResU.ResFile GetResFileU()
|
||||
{
|
||||
return ((FMDL)Parent.Parent).GetResFileU();
|
||||
}
|
||||
|
||||
public void UpdateTextureMaps()
|
||||
{
|
||||
((ResourceFile)Parent.Parent.Parent.Parent).BFRESRender.UpdateSingleMaterialTextureMaps(this);
|
||||
}
|
||||
|
||||
public void SetActiveGame()
|
||||
{
|
||||
@ -115,7 +128,7 @@ namespace Bfres.Structs
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Material.Export(sfd.FileName, BFRESRender.resFile);
|
||||
Material.Export(sfd.FileName, GetResFile());
|
||||
}
|
||||
}
|
||||
private void Replace(object sender, EventArgs args)
|
||||
|
@ -60,10 +60,28 @@ namespace Bfres.Structs
|
||||
{
|
||||
public List<FSHP> shapes = new List<FSHP>();
|
||||
public Dictionary<string, FMAT> materials = new Dictionary<string, FMAT>();
|
||||
public BFRESRender BFRESRender;
|
||||
public Model Model;
|
||||
public ResU.Model ModelU;
|
||||
|
||||
public ResFile GetResFile()
|
||||
{
|
||||
//ResourceFile -> FMDL -> Material Folder -> this
|
||||
return ((ResourceFile)Parent.Parent).resFile;
|
||||
}
|
||||
public ResU.ResFile GetResFileU()
|
||||
{
|
||||
return ((ResourceFile)Parent.Parent).resFileU;
|
||||
}
|
||||
public void UpdateVertexData()
|
||||
{
|
||||
((ResourceFile)Parent.Parent).BFRESRender.UpdateVertexData();
|
||||
}
|
||||
public List<FMDL> GetModelList()
|
||||
{
|
||||
return ((ResourceFile)Parent.Parent).BFRESRender.models;
|
||||
}
|
||||
|
||||
|
||||
public FMDL()
|
||||
{
|
||||
ImageKey = "model";
|
||||
@ -105,7 +123,7 @@ namespace Bfres.Structs
|
||||
|
||||
shp.SaveVertexBuffer();
|
||||
}
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
private void RecalculateNormals(object sender, EventArgs args)
|
||||
@ -119,7 +137,7 @@ namespace Bfres.Structs
|
||||
|
||||
shp.SaveVertexBuffer();
|
||||
}
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
private void Rename(object sender, EventArgs args)
|
||||
@ -181,13 +199,13 @@ namespace Bfres.Structs
|
||||
shp.SaveVertexBuffer();
|
||||
}
|
||||
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
public void CopyMaterial(FMAT selectedMaterial)
|
||||
{
|
||||
CopyMaterialMenu menu = new CopyMaterialMenu();
|
||||
menu.LoadMaterials(selectedMaterial.Text, BFRESRender.models);
|
||||
menu.LoadMaterials(selectedMaterial.Text, GetModelList());
|
||||
if (menu.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
foreach (TreeNode mdl in menu.materialTreeView.Nodes)
|
||||
@ -281,7 +299,7 @@ namespace Bfres.Structs
|
||||
switch (ext)
|
||||
{
|
||||
case ".bfmdl":
|
||||
Model.Export(sfd.FileName, BFRESRender.resFile);
|
||||
Model.Export(sfd.FileName, GetResFile());
|
||||
break;
|
||||
case ".csv":
|
||||
CsvModel csv = new CsvModel();
|
||||
@ -360,7 +378,6 @@ namespace Bfres.Structs
|
||||
|
||||
FSHP shapeS = new FSHP();
|
||||
shapeS.Shape = shpS;
|
||||
shapeS.BFRESRender = BFRESRender;
|
||||
BfresSwitch.ReadShapesVertices(shapeS, shpS, vertexBuffer, this);
|
||||
shapes.Add(shapeS);
|
||||
Nodes["FshpFolder"].Nodes.Add(shapeS);
|
||||
@ -370,7 +387,7 @@ namespace Bfres.Structs
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
shapes.Clear();
|
||||
Model mdl = new Model();
|
||||
mdl.Import(FileName, BFRESRender.resFile);
|
||||
mdl.Import(FileName, GetResFile());
|
||||
mdl.Name = Text;
|
||||
shapes.Clear();
|
||||
Nodes["FshpFolder"].Nodes.Clear();
|
||||
@ -417,7 +434,6 @@ namespace Bfres.Structs
|
||||
shape.ApplyImportSettings(csvsettings, GetMaterial(shape.MaterialIndex));
|
||||
shape.SaveShape();
|
||||
shape.SaveVertexBuffer();
|
||||
shape.BFRESRender = BFRESRender;
|
||||
shape.BoneIndices = new List<ushort>();
|
||||
|
||||
Nodes["FshpFolder"].Nodes.Add(shape);
|
||||
@ -574,7 +590,6 @@ namespace Bfres.Structs
|
||||
shape.ApplyImportSettings(settings, GetMaterial(shape.MaterialIndex));
|
||||
shape.SaveShape();
|
||||
shape.SaveVertexBuffer();
|
||||
shape.BFRESRender = BFRESRender;
|
||||
shape.BoneIndices = new List<ushort>();
|
||||
|
||||
List<string> keyList = shapes.Select(o => o.Text).ToList();
|
||||
@ -587,7 +602,7 @@ namespace Bfres.Structs
|
||||
}
|
||||
break;
|
||||
}
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
}
|
||||
public FMAT GetMaterial(int index)
|
||||
{
|
||||
@ -611,7 +626,6 @@ namespace Bfres.Structs
|
||||
mat.Material = new Material();
|
||||
mat.Material.Import(FileName);
|
||||
mat.ReadMaterial(mat.Material);
|
||||
mat.BFRESRender = BFRESRender;
|
||||
mat.Text = mat.Material.Name;
|
||||
|
||||
materials.Add(mat.Text, mat);
|
||||
|
@ -40,17 +40,6 @@ namespace Bfres.Structs
|
||||
Nodes.Clear();
|
||||
}
|
||||
}
|
||||
public void LoadAnimations(ResFile resFile, BFRESRender BFRESRender)
|
||||
{
|
||||
foreach (var scn in resFile.SceneAnims)
|
||||
{
|
||||
FSCN sceneAnim = new FSCN();
|
||||
sceneAnim.Text = scn.Name;
|
||||
sceneAnim.BFRESRender = BFRESRender;
|
||||
sceneAnim.Read(scn);
|
||||
Nodes.Add(sceneAnim);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
@ -61,8 +50,6 @@ namespace Bfres.Structs
|
||||
public class FSCN : TreeNodeCustom
|
||||
{
|
||||
public SceneAnim SceneAnim;
|
||||
public BFRESRender BFRESRender;
|
||||
|
||||
public FSCN()
|
||||
{
|
||||
ImageKey = "skeletonAnimation";
|
||||
@ -77,6 +64,11 @@ namespace Bfres.Structs
|
||||
replace.Click += Replace;
|
||||
}
|
||||
|
||||
public ResFile GetResFile()
|
||||
{
|
||||
return ((ResourceFile)Parent.Parent).resFile;
|
||||
}
|
||||
|
||||
private void Export(object sender, EventArgs args)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
@ -86,7 +78,7 @@ namespace Bfres.Structs
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SceneAnim.Export(sfd.FileName, BFRESRender.resFile);
|
||||
SceneAnim.Export(sfd.FileName, GetResFile());
|
||||
}
|
||||
}
|
||||
private void Replace(object sender, EventArgs args)
|
||||
|
@ -41,7 +41,7 @@ namespace Bfres.Structs
|
||||
{
|
||||
Nodes.Clear();
|
||||
((FMDL)Parent).shapes.Clear();
|
||||
((FMDL)Parent).BFRESRender.UpdateVertexData();
|
||||
((FMDL)Parent).UpdateVertexData();
|
||||
}
|
||||
}
|
||||
private void ExportAll(object sender, EventArgs args)
|
||||
@ -134,8 +134,6 @@ namespace Bfres.Structs
|
||||
ContextMenu.MenuItems.Add(rename);
|
||||
rename.Click += Rename;
|
||||
}
|
||||
|
||||
public BFRESRender BFRESRender;
|
||||
public FMATEditor editor;
|
||||
public int ModelIndex; //For getting the model the shape is in
|
||||
|
||||
@ -144,6 +142,24 @@ namespace Bfres.Structs
|
||||
public ResU.VertexBuffer VertexBufferU;
|
||||
public ResU.Shape ShapeU;
|
||||
|
||||
public ResFile GetResFile()
|
||||
{
|
||||
//ResourceFile -> FMDL -> Material Folder -> this
|
||||
return ((FMDL)Parent.Parent).GetResFile();
|
||||
}
|
||||
public ResU.ResFile GetResFileU()
|
||||
{
|
||||
return ((FMDL)Parent.Parent).GetResFileU();
|
||||
}
|
||||
public void UpdateVertexData()
|
||||
{
|
||||
((FMDL)Parent.Parent).UpdateVertexData();
|
||||
}
|
||||
public List<FMDL> GetModelList()
|
||||
{
|
||||
return ((FMDL)Parent.Parent).GetModelList();
|
||||
}
|
||||
|
||||
public FMAT GetMaterial()
|
||||
{
|
||||
return ((FMDL)Parent.Parent).materials.Values.ElementAt(MaterialIndex);
|
||||
@ -162,7 +178,7 @@ namespace Bfres.Structs
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
SmoothNormals();
|
||||
SaveVertexBuffer();
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
private void RecalculateNormals(object sender, EventArgs args)
|
||||
@ -170,7 +186,7 @@ namespace Bfres.Structs
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
CalculateNormals();
|
||||
SaveVertexBuffer();
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
private void Rename(object sender, EventArgs args)
|
||||
@ -190,7 +206,7 @@ namespace Bfres.Structs
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
((FMDL)Parent.Parent).shapes.Remove(this);
|
||||
((FMDL)Parent.Parent).BFRESRender.UpdateVertexData();
|
||||
((FMDL)Parent.Parent).UpdateVertexData();
|
||||
Parent.Nodes.Remove(this);
|
||||
}
|
||||
}
|
||||
@ -320,7 +336,7 @@ namespace Bfres.Structs
|
||||
|
||||
CalculateTangentBitangent();
|
||||
SaveVertexBuffer();
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
public bool HasUV0()
|
||||
@ -345,7 +361,7 @@ namespace Bfres.Structs
|
||||
|
||||
FlipUvsVertical();
|
||||
SaveVertexBuffer();
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
}
|
||||
public void FlipUvsHorizontal(object sender, EventArgs args)
|
||||
{
|
||||
@ -357,7 +373,7 @@ namespace Bfres.Structs
|
||||
|
||||
FlipUvsHorizontal();
|
||||
SaveVertexBuffer();
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
}
|
||||
public void ExportMaterials(object sender, EventArgs args)
|
||||
{
|
||||
@ -368,7 +384,7 @@ namespace Bfres.Structs
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
GetMaterial().Material.Export(sfd.FileName, BFRESRender.resFile);
|
||||
GetMaterial().Material.Export(sfd.FileName, GetResFile());
|
||||
}
|
||||
}
|
||||
public void ReplaceMaterials(object sender, EventArgs args)
|
||||
@ -414,7 +430,7 @@ namespace Bfres.Structs
|
||||
}
|
||||
public void ExportBinaryObject(string FileName)
|
||||
{
|
||||
Shape.Export(FileName, BFRESRender.resFile);
|
||||
Shape.Export(FileName, GetResFile());
|
||||
}
|
||||
public void Replace(object sender, EventArgs args)
|
||||
{
|
||||
@ -438,7 +454,7 @@ namespace Bfres.Structs
|
||||
shp.Import(ofd.FileName, VertexBuffer);
|
||||
shp.Name = Text;
|
||||
shp.MaterialIndex = (ushort)MaterialIndex;
|
||||
BfresSwitch.ReadShapesVertices(this, shp, VertexBuffer, BFRESRender.models[ModelIndex]);
|
||||
BfresSwitch.ReadShapesVertices(this, shp, VertexBuffer, GetModelList()[ModelIndex]);
|
||||
break;
|
||||
default:
|
||||
AssimpData assimp = new AssimpData();
|
||||
@ -474,7 +490,7 @@ namespace Bfres.Structs
|
||||
}
|
||||
break;
|
||||
}
|
||||
BFRESRender.UpdateVertexData();
|
||||
UpdateVertexData();
|
||||
}
|
||||
}
|
||||
public void CreateIndexList(GenericObject ob, FMDL mdl = null)
|
||||
|
@ -60,7 +60,6 @@ namespace Bfres.Structs
|
||||
ZROT = 0x28,
|
||||
}
|
||||
public SkeletalAnim SkeletalAnim;
|
||||
public BFRESRender BFRESRender;
|
||||
|
||||
public BfresSkeletonAnim()
|
||||
{
|
||||
@ -90,6 +89,11 @@ namespace Bfres.Structs
|
||||
ContextMenu.MenuItems.Add(replace);
|
||||
replace.Click += Replace;
|
||||
}
|
||||
public ResFile GetResFile()
|
||||
{
|
||||
//ResourceFile -> FMDL -> Material Folder -> this
|
||||
return ((ResourceFile)Parent.Parent).resFile;
|
||||
}
|
||||
private void Export(object sender, EventArgs args)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
@ -99,7 +103,7 @@ namespace Bfres.Structs
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SkeletalAnim.Export(sfd.FileName, BFRESRender.resFile);
|
||||
SkeletalAnim.Export(sfd.FileName, GetResFile());
|
||||
}
|
||||
}
|
||||
private void Replace(object sender, EventArgs args)
|
||||
|
@ -43,7 +43,7 @@ namespace Bfres.Structs
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Skeleton.Export(sfd.FileName, BFRESRender.resFile);
|
||||
Skeleton.Export(sfd.FileName, ((FMDL)Parent).GetResFile());
|
||||
}
|
||||
}
|
||||
public void Replace(object sender, EventArgs args)
|
||||
@ -58,12 +58,10 @@ namespace Bfres.Structs
|
||||
Skeleton.Import(ofd.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClick(TreeView treeView)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public FSKL()
|
||||
{
|
||||
@ -107,6 +105,11 @@ namespace Bfres.Structs
|
||||
ContextMenu.MenuItems.Add(replace);
|
||||
replace.Click += Replace;
|
||||
}
|
||||
public ResFile GetResFile()
|
||||
{
|
||||
//ResourceFile -> FMDL -> Material Folder -> this
|
||||
return ((FMDL)Parent.Parent).GetResFile();
|
||||
}
|
||||
public void Export(object sender, EventArgs args)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
@ -116,7 +119,7 @@ namespace Bfres.Structs
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Bone.Export(sfd.FileName, BFRESRender.resFile);
|
||||
Bone.Export(sfd.FileName, GetResFile());
|
||||
}
|
||||
}
|
||||
public void Replace(object sender, EventArgs args)
|
||||
|
@ -31,6 +31,9 @@ namespace Bfres.Structs
|
||||
{
|
||||
public BFRESRender BFRESRender;
|
||||
|
||||
public ResFile resFile = null;
|
||||
public ResU.ResFile resFileU = null;
|
||||
|
||||
public TreeNode TextureFolder = new TreeNode("Textures");
|
||||
public ResourceFile(IFileFormat handler)
|
||||
{
|
||||
@ -116,44 +119,46 @@ namespace Bfres.Structs
|
||||
BFRESRender.UpdateVertexData();
|
||||
}
|
||||
}
|
||||
public void Load(ResU.ResFile resFile)
|
||||
public void Load(ResU.ResFile res)
|
||||
{
|
||||
Text = resFile.Name;
|
||||
resFileU = res;
|
||||
|
||||
if (resFile.Models.Count > 0)
|
||||
Text = resFileU.Name;
|
||||
|
||||
if (resFileU.Models.Count > 0)
|
||||
Nodes.Add(new FmdlFolder());
|
||||
if (resFile.Textures.Count > 0)
|
||||
AddFTEXTextures(resFile);
|
||||
if (resFile.SkeletalAnims.Count > 0)
|
||||
AddSkeletonAnims(resFile);
|
||||
if (resFile.ShaderParamAnims.Count > 0)
|
||||
if (resFileU.Textures.Count > 0)
|
||||
AddFTEXTextures(resFileU);
|
||||
if (resFileU.SkeletalAnims.Count > 0)
|
||||
AddSkeletonAnims(resFileU);
|
||||
if (resFileU.ShaderParamAnims.Count > 0)
|
||||
Nodes.Add(new FshuFolder());
|
||||
if (resFile.ColorAnims.Count > 0)
|
||||
if (resFileU.ColorAnims.Count > 0)
|
||||
Nodes.Add(new FshuColorFolder());
|
||||
if (resFile.TexSrtAnims.Count > 0)
|
||||
if (resFileU.TexSrtAnims.Count > 0)
|
||||
Nodes.Add(new TexSrtFolder());
|
||||
if (resFile.TexPatternAnims.Count > 0)
|
||||
if (resFileU.TexPatternAnims.Count > 0)
|
||||
Nodes.Add(new TexPatFolder());
|
||||
if (resFile.ShapeAnims.Count > 0)
|
||||
if (resFileU.ShapeAnims.Count > 0)
|
||||
Nodes.Add(new FshpaFolder());
|
||||
if (resFile.BoneVisibilityAnims.Count > 0)
|
||||
if (resFileU.BoneVisibilityAnims.Count > 0)
|
||||
Nodes.Add(new FbnvFolder());
|
||||
if (resFile.SceneAnims.Count > 0)
|
||||
if (resFileU.SceneAnims.Count > 0)
|
||||
Nodes.Add(new FscnFolder());
|
||||
if (resFile.ExternalFiles.Count > 0)
|
||||
if (resFileU.ExternalFiles.Count > 0)
|
||||
Nodes.Add(new EmbeddedFilesFolder());
|
||||
|
||||
foreach (var anim in resFile.ShaderParamAnims)
|
||||
foreach (var anim in resFileU.ShaderParamAnims)
|
||||
Nodes["FSHA"].Nodes.Add(anim.Key);
|
||||
foreach (var anim in resFile.ColorAnims)
|
||||
foreach (var anim in resFileU.ColorAnims)
|
||||
Nodes["FSHAColor"].Nodes.Add(anim.Key);
|
||||
foreach (var anim in resFile.TexSrtAnims)
|
||||
foreach (var anim in resFileU.TexSrtAnims)
|
||||
Nodes["TEXSRT"].Nodes.Add(anim.Key);
|
||||
foreach (var anim in resFile.TexPatternAnims)
|
||||
foreach (var anim in resFileU.TexPatternAnims)
|
||||
Nodes["TEXPAT"].Nodes.Add(anim.Key);
|
||||
|
||||
int ext = 0;
|
||||
foreach (var extfile in resFile.ExternalFiles)
|
||||
foreach (var extfile in resFileU.ExternalFiles)
|
||||
{
|
||||
string Name = extfile.Key;
|
||||
|
||||
@ -172,8 +177,10 @@ namespace Bfres.Structs
|
||||
ext++;
|
||||
}
|
||||
}
|
||||
public void Load(ResFile resFile)
|
||||
public void Load(ResFile res)
|
||||
{
|
||||
resFile = res;
|
||||
|
||||
Text = resFile.Name;
|
||||
UpdateTree(resFile);
|
||||
|
||||
@ -214,9 +221,9 @@ namespace Bfres.Structs
|
||||
private void NewTextureFile(object sender, EventArgs args)
|
||||
{
|
||||
string Name = "textures";
|
||||
for (int i = 0; i < BFRESRender.resFile.ExternalFiles.Count; i++)
|
||||
for (int i = 0; i < resFile.ExternalFiles.Count; i++)
|
||||
{
|
||||
if (BFRESRender.resFile.ExternalFileDict.GetKey(i) == Name)
|
||||
if (resFile.ExternalFileDict.GetKey(i) == Name)
|
||||
Name = Name + i;
|
||||
}
|
||||
if (!Nodes.ContainsKey("EXT"))
|
||||
@ -225,7 +232,7 @@ namespace Bfres.Structs
|
||||
}
|
||||
BNTX bntx = new BNTX();
|
||||
bntx.Data = new byte[0];
|
||||
BinaryTextureContainer bntxTreeNode = new BinaryTextureContainer(new byte[0], "textures", BFRESRender.resFile.Name);
|
||||
BinaryTextureContainer bntxTreeNode = new BinaryTextureContainer(new byte[0], "textures", resFile.Name);
|
||||
Nodes["EXT"].Nodes.Add(bntxTreeNode);
|
||||
|
||||
}
|
||||
@ -288,7 +295,6 @@ namespace Bfres.Structs
|
||||
foreach (ResU.SkeletalAnim ska in resFile.SkeletalAnims.Values)
|
||||
{
|
||||
BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name);
|
||||
skeletonAnim.BFRESRender = BFRESRender;
|
||||
skeletonAnim.Read(ska, resFile);
|
||||
fksaFolder.Nodes.Add(skeletonAnim);
|
||||
}
|
||||
@ -300,7 +306,6 @@ namespace Bfres.Structs
|
||||
foreach (SkeletalAnim ska in resFile.SkeletalAnims)
|
||||
{
|
||||
BfresSkeletonAnim skeletonAnim = new BfresSkeletonAnim(ska.Name);
|
||||
skeletonAnim.BFRESRender = BFRESRender;
|
||||
skeletonAnim.Read(ska, resFile);
|
||||
fksaFolder.Nodes.Add(skeletonAnim);
|
||||
}
|
||||
@ -318,7 +323,6 @@ namespace Bfres.Structs
|
||||
{
|
||||
FSCN sceneAnim = new FSCN();
|
||||
sceneAnim.Text = scn.Name;
|
||||
sceneAnim.BFRESRender = BFRESRender;
|
||||
sceneAnim.Read(scn);
|
||||
fscnFolder.Nodes.Add(sceneAnim);
|
||||
}
|
||||
|
@ -28,13 +28,11 @@ namespace FirstPlugin
|
||||
model.Nodes.Add(model.Skeleton.node);
|
||||
model.Skeleton.reset();
|
||||
model.Skeleton.update();
|
||||
model.BFRESRender = renderer;
|
||||
model.Skeleton.node.BFRESRender = renderer;
|
||||
model.Model = mdl;
|
||||
foreach (Material mat in mdl.Materials)
|
||||
{
|
||||
FMAT FMAT = new FMAT();
|
||||
FMAT.BFRESRender = renderer;
|
||||
FMAT.Text = mat.Name;
|
||||
FMAT.ReadMaterial(mat);
|
||||
model.Nodes[1].Nodes.Add(FMAT);
|
||||
@ -45,7 +43,6 @@ namespace FirstPlugin
|
||||
VertexBuffer vertexBuffer = mdl.VertexBuffers[shp.VertexBufferIndex];
|
||||
Material material = mdl.Materials[shp.MaterialIndex];
|
||||
FSHP mesh = new FSHP();
|
||||
mesh.BFRESRender = renderer;
|
||||
mesh.ModelIndex = CurMdl;
|
||||
ReadShapesVertices(mesh, shp, vertexBuffer, model);
|
||||
mesh.MaterialIndex = shp.MaterialIndex;
|
||||
@ -449,9 +446,6 @@ namespace FirstPlugin
|
||||
curve.CurveType = AnimCurveType.StepBool;
|
||||
curve.Keys = new float[keyGroup.Keys.Count, 1];
|
||||
}
|
||||
|
||||
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
@ -472,7 +466,6 @@ namespace FirstPlugin
|
||||
{
|
||||
BfresBone STBone = new BfresBone(RenderableSkeleton);
|
||||
SetBone(STBone, bone);
|
||||
STBone.BFRESRender = RenderableSkeleton.node.BFRESRender; //to update viewport on bone edits
|
||||
RenderableSkeleton.bones.Add(STBone);
|
||||
}
|
||||
RenderableSkeleton.update();
|
||||
|
@ -30,13 +30,11 @@ namespace FirstPlugin
|
||||
model.Nodes.Add(model.Skeleton.node);
|
||||
model.Skeleton.reset();
|
||||
model.Skeleton.update();
|
||||
model.BFRESRender = renderer;
|
||||
model.Skeleton.node.BFRESRender = renderer;
|
||||
model.ModelU = mdl;
|
||||
foreach (Material mat in mdl.Materials.Values)
|
||||
{
|
||||
FMAT FMAT = new FMAT();
|
||||
FMAT.BFRESRender = renderer;
|
||||
FMAT.Text = mat.Name;
|
||||
FMAT.ReadMaterial(mat);
|
||||
model.Nodes[1].Nodes.Add(FMAT);
|
||||
@ -47,7 +45,6 @@ namespace FirstPlugin
|
||||
VertexBuffer vertexBuffer = mdl.VertexBuffers[shp.VertexBufferIndex];
|
||||
Material material = mdl.Materials[shp.MaterialIndex];
|
||||
FSHP mesh = new FSHP();
|
||||
mesh.BFRESRender = renderer;
|
||||
mesh.ModelIndex = CurMdl;
|
||||
ReadShapesVertices(mesh, shp, vertexBuffer, model);
|
||||
mesh.MaterialIndex = shp.MaterialIndex;
|
||||
@ -619,7 +616,7 @@ namespace FirstPlugin
|
||||
TextureRef texref = new TextureRef();
|
||||
texref.Name = textu.Name;
|
||||
Texture texMapped = new Texture();
|
||||
m.BFRESRender.resFileU.Textures.TryGetValue(textu.Name, out texMapped);
|
||||
m.GetResFileU().Textures.TryGetValue(textu.Name, out texMapped);
|
||||
texref.Texture = texMapped;
|
||||
mat.TextureRefs.Add(texref);
|
||||
}
|
||||
|
@ -170,6 +170,7 @@ namespace FirstPlugin
|
||||
format = (int)tex.Format;
|
||||
int swizzle = (int)tex.Swizzle;
|
||||
int pitch = (int)tex.Pitch;
|
||||
|
||||
renderedTex.data = GTX.swizzleBC(tex.Data, renderedTex.width, renderedTex.height, format, (int)tex.TileMode, pitch, swizzle);
|
||||
}
|
||||
|
||||
@ -393,6 +394,7 @@ namespace FirstPlugin
|
||||
}
|
||||
set
|
||||
{
|
||||
mipmaps.Clear();
|
||||
List<byte[]> mips = new List<byte[]>();
|
||||
mips.Add(value);
|
||||
mipmaps.Add(mips);
|
||||
|
@ -28,9 +28,6 @@ namespace FirstPlugin
|
||||
int vbo_position;
|
||||
int ibo_elements;
|
||||
|
||||
public ResFile resFile = null;
|
||||
public ResU.ResFile resFileU = null;
|
||||
|
||||
public Shader shader = null;
|
||||
public List<FMDL> models = new List<FMDL>();
|
||||
|
||||
@ -51,18 +48,16 @@ namespace FirstPlugin
|
||||
GL.GenBuffers(1, out vbo_position);
|
||||
GL.GenBuffers(1, out ibo_elements);
|
||||
}
|
||||
public void LoadFile(ResU.ResFile r)
|
||||
public void LoadFile(ResU.ResFile resFileU)
|
||||
{
|
||||
resFileU = r;
|
||||
ResFileNode.Load(resFileU);
|
||||
|
||||
BfresWiiU.Read(this, resFileU, ResFileNode);
|
||||
UpdateVertexData();
|
||||
UpdateTextureMaps();
|
||||
}
|
||||
public void LoadFile(ResFile r)
|
||||
public void LoadFile(ResFile resFile)
|
||||
{
|
||||
resFile = r;
|
||||
ResFileNode.Load(resFile);
|
||||
|
||||
BfresSwitch.Read(this, resFile, ResFileNode);
|
||||
|
@ -19,8 +19,6 @@ namespace FirstPlugin
|
||||
{
|
||||
public FMAT material;
|
||||
|
||||
public BFRESRender bfresRender;
|
||||
|
||||
public ImageList textureImageList;
|
||||
public string SelectedMatParam = "";
|
||||
public ImageList il = new ImageList();
|
||||
@ -46,9 +44,8 @@ namespace FirstPlugin
|
||||
{
|
||||
|
||||
}
|
||||
public void LoadMaterial(FMAT mat, BFRESRender bfres)
|
||||
public void LoadMaterial(FMAT mat)
|
||||
{
|
||||
bfresRender = bfres;
|
||||
material = mat;
|
||||
textBoxMaterialName.Text = material.Text;
|
||||
|
||||
@ -320,7 +317,7 @@ namespace FirstPlugin
|
||||
{
|
||||
material.textures[index].Name = tex.GetSelectedTexture();
|
||||
InitializeTextureListView(material);
|
||||
bfresRender.UpdateSingleMaterialTextureMaps(material);
|
||||
material.UpdateTextureMaps();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ namespace FirstPlugin
|
||||
if (LODMeshCB.SelectedIndex != -1)
|
||||
{
|
||||
activeShape.DisplayLODIndex = LODMeshCB.SelectedIndex;
|
||||
activeShape.BFRESRender.UpdateVertexData();
|
||||
activeShape.UpdateVertexData();
|
||||
Viewport.Instance.UpdateViewport();
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace FirstPlugin
|
||||
FMATEditor editor = new FMATEditor();
|
||||
editor.Text = mat.Text;
|
||||
editor.Dock = DockStyle.Fill;
|
||||
editor.LoadMaterial(mat, mat.BFRESRender);
|
||||
editor.LoadMaterial(mat);
|
||||
LibraryGUI.Instance.LoadDockContent(editor, PluginRuntime.FSHPDockState);
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "Switch_Toolbox\Lib\DirectXTex\DirectXTex.vcxproj", "{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectXTexNet", "DirectXTexNet-master\DirectXTexNet\DirectXTexNet.csproj", "{98495BF2-DED3-4E08-B965-C12D471BC86F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -75,14 +73,6 @@ Global
|
||||
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Release|Any CPU.Build.0 = Release|Win32
|
||||
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Release|x64.ActiveCfg = Release|x64
|
||||
{755AB64B-16B4-4C90-AA3B-BFF448E5A21E}.Release|x64.Build.0 = Release|x64
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{98495BF2-DED3-4E08-B965-C12D471BC86F}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Binary file not shown.
BIN
Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb
Normal file
BIN
Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.pdb
Normal file
Binary file not shown.
5659
Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.xml
Normal file
5659
Switch_Toolbox/Lib/Syroot.NintenTools.NSW.Bfres.xml
Normal file
File diff suppressed because it is too large
Load Diff
@ -265,9 +265,9 @@ namespace Switch_Toolbox
|
||||
f.Dispose();
|
||||
f.Close();
|
||||
|
||||
//Check magic first regardless of extension
|
||||
foreach (IFileFormat format in SupportedFormats)
|
||||
{
|
||||
|
||||
if (format.Magic == Magic || format.Magic == Magic2 || format.Magic.Reverse() == Magic2)
|
||||
{
|
||||
format.CompressionType = CompType;
|
||||
@ -290,34 +290,35 @@ namespace Switch_Toolbox
|
||||
if (format.UseEditMenu)
|
||||
editToolStripMenuItem.Enabled = true;
|
||||
}
|
||||
else
|
||||
}
|
||||
//If magic fails, then check extensions
|
||||
foreach (IFileFormat format in SupportedFormats)
|
||||
{
|
||||
foreach (string ext in format.Extension)
|
||||
{
|
||||
foreach (string ext in format.Extension)
|
||||
if (ext.Remove(0, 1) == Path.GetExtension(FileName))
|
||||
{
|
||||
if (ext.Remove(0, 1) == Path.GetExtension(FileName))
|
||||
format.CompressionType = CompType;
|
||||
format.FileIsCompressed = Compressed;
|
||||
format.Data = data;
|
||||
format.FileName = Path.GetFileName(FileName);
|
||||
format.FilePath = FileName;
|
||||
format.Load();
|
||||
|
||||
if (format.EditorRoot != null)
|
||||
{
|
||||
format.CompressionType = CompType;
|
||||
format.FileIsCompressed = Compressed;
|
||||
format.Data = data;
|
||||
format.FileName = Path.GetFileName(FileName);
|
||||
format.FilePath = FileName;
|
||||
format.Load();
|
||||
|
||||
if (format.EditorRoot != null)
|
||||
{
|
||||
objectList.treeView1.Nodes.Add(format.EditorRoot);
|
||||
}
|
||||
|
||||
if (format.CanSave)
|
||||
{
|
||||
saveAsToolStripMenuItem.Enabled = true;
|
||||
saveToolStripMenuItem.Enabled = true;
|
||||
}
|
||||
if (format.UseEditMenu)
|
||||
editToolStripMenuItem.Enabled = true;
|
||||
objectList.treeView1.Nodes.Add(format.EditorRoot);
|
||||
}
|
||||
|
||||
if (format.CanSave)
|
||||
{
|
||||
saveAsToolStripMenuItem.Enabled = true;
|
||||
saveToolStripMenuItem.Enabled = true;
|
||||
}
|
||||
if (format.UseEditMenu)
|
||||
editToolStripMenuItem.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DisposeControls()
|
||||
@ -326,7 +327,9 @@ namespace Switch_Toolbox
|
||||
}
|
||||
private void RecentFile_click(object sender, EventArgs e)
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
OpenFile(sender.ToString());
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
@ -362,8 +365,12 @@ namespace Switch_Toolbox
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
foreach (string file in ofd.FileNames)
|
||||
OpenFile(file);
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,11 +382,15 @@ namespace Switch_Toolbox
|
||||
|
||||
private void dockPanel1_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
foreach (string filename in files)
|
||||
{
|
||||
OpenFile(filename);
|
||||
}
|
||||
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
private void dockPanel1_DragEnter(object sender, DragEventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user