1
0
mirror of synced 2024-11-27 17:00:50 +01:00

Thanos the old tool.

This commit is contained in:
KillzXGaming 2019-03-23 12:52:50 -04:00
parent 02daf5bb8c
commit 00875d5aec
750 changed files with 0 additions and 760416 deletions

5
.gitignore vendored
View File

@ -1,5 +0,0 @@
.vs/Switch_Toolbox/v15/Server/sqlite3/db.lock
*.resources
Debug/
Release/

View File

@ -1,2 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto

View File

@ -1,330 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/

View File

@ -1,48 +0,0 @@
using GL_Core.Public_Interfaces;
using OpenTK;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GL_Core.Cameras
{
public class InspectCamera : AbstractCamera
{
public InspectCamera()
{
}
public override bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom)
{
if (e.Button == MouseButtons.Right)
{
rot += deltaX * 0.01f;
lookup += deltaY * 0.01f;
return true;
}
else if (e.Button == MouseButtons.Left)
{
deltaX *= Math.Min(0.1f, args.pickingDepth * args.factorX);
deltaY *= Math.Min(0.1f, args.pickingDepth * args.factorY);
camTarget += Vector3.UnitX * (float)Math.Cos(rot) * deltaX;
camTarget -= Vector3.UnitX * (float)Math.Sin(rot) * (float)Math.Sin(lookup) * deltaY;
camTarget -= Vector3.UnitY * (float)Math.Cos(lookup) * deltaY;
camTarget += Vector3.UnitZ * (float)Math.Sin(rot) * deltaX;
camTarget += Vector3.UnitZ * (float)Math.Cos(rot) * (float)Math.Sin(lookup) * deltaY;
return true;
}
return false;
}
public override bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom)
{
zoom *= 1f - e.Delta * 0.001f;
return true;
}
}
}

View File

@ -1,64 +0,0 @@
using GL_Core.Public_Interfaces;
using OpenTK;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GL_Core.Cameras
{
public class WalkaroundCamera : AbstractCamera
{
public WalkaroundCamera()
{
}
public override bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom)
{
if (e.Button == MouseButtons.Right)
{
rot += deltaX * 0.002f;
lookup += deltaY * 0.002f;
return true;
}
else if (e.Button == MouseButtons.Left)
{
//code from Whitehole
deltaX *= Math.Min(0.1f, args.pickingDepth* args.factorX);
deltaY *= Math.Min(0.1f, args.pickingDepth* args.factorY);
camTarget += Vector3.UnitX * deltaX * (float)Math.Cos(rot);
camTarget -= Vector3.UnitX * deltaY * (float)Math.Sin(rot) * (float)Math.Sin(lookup);
camTarget -= Vector3.UnitY * deltaY * (float)Math.Cos(lookup);
camTarget += Vector3.UnitZ * deltaX * (float)Math.Sin(rot);
camTarget += Vector3.UnitZ * deltaY * (float)Math.Cos(rot) * (float)Math.Sin(lookup);
return true;
}
return false;
}
public override bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom)
{
float delta = (float)(e.Delta * Math.Min(0.01f, args.pickingDepth / 500f));
camTarget -= Vector3.UnitX * (float)Math.Sin(rot) * (float)Math.Cos(lookup) * delta;
camTarget += Vector3.UnitY * (float)Math.Sin(lookup) * delta;
camTarget += Vector3.UnitZ * (float)Math.Cos(rot) * (float)Math.Cos(lookup) * delta;
float factoffX = (float)(-xoff * delta) * args.factorX;
float factoffY = (float)(-yoff * delta) * args.factorY;
camTarget += Vector3.UnitX * (float)Math.Cos(rot) * factoffX;
camTarget -= Vector3.UnitX * (float)Math.Sin(rot) * (float)Math.Sin(lookup) * factoffY;
camTarget -= Vector3.UnitY * (float)Math.Cos(lookup) * factoffY;
camTarget += Vector3.UnitZ * (float)Math.Sin(rot) * factoffX;
camTarget += Vector3.UnitZ * (float)Math.Cos(rot) * (float)Math.Sin(lookup) * factoffY;
return true;
}
}
}

View File

@ -1,37 +0,0 @@
namespace GL_Core
{
partial class GL_ControlLegacy
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -1,338 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using GL_Core.Interfaces;
using GL_Core.Public_Interfaces;
using GL_Core.Cameras;
namespace GL_Core
{
public partial class GL_ControlLegacy : GLControl
{
public GL_ControlLegacy():base(OpenTK.Graphics.GraphicsMode.Default,1,1, OpenTK.Graphics.GraphicsContextFlags.Default)
{
InitializeComponent();
}
private Point lastMouseLoc;
private Point dragStartLoc;
private float lastDepth = 1000f;
private AbstractCamera activeCamera;
float rot = 0;
float lookup = 0;
float zoom = -10f;
Vector3 camTarget;
float zfar = 1000f;
float znear = 0.01f;
float fov = MathHelper.PiOver4;
uint[] pickingFrameBuffer = new uint[9];
int pickingIndex;
float pickingModelDepth = 0f;
private float pickingDepth = 0f;
public Matrix4 mtxMdl, mtxCam, mtxProj;
private float factorX, factorY;
bool stereoscopy;
int viewPortX(int x) => stereoscopy ? x % (Width / 2) : x;
int viewPortDX(int dx) => stereoscopy ? dx * 2 : dx;
int viewPortXOff(int x) => stereoscopy ? (x - Width / 4)*2 : x - Width / 2;
int viewPortWidth() => stereoscopy ? Width / 2 : Width;
public bool Stereoscopy
{
get => stereoscopy;
set
{
stereoscopy = value;
OnResize(null);
Refresh();
}
}
AbstractGlDrawable mainDrawable;
public AbstractGlDrawable MainDrawable
{
get => mainDrawable;
set
{
if (value == null) return;
mainDrawable = value;
MakeCurrent();
mainDrawable.Prepare(this);
Refresh();
}
}
public AbstractCamera ActiveCamera
{
get => activeCamera;
set
{
if (value == null) return;
activeCamera = value;
MakeCurrent();
Refresh();
}
}
public Color nextPickingColor()
{
return Color.FromArgb(pickingIndex++);
}
public void UpdateModelMatrix(Matrix4 matrix)
{
mtxMdl = matrix;
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref mtxMdl);
}
public void ApplyModelTransform(Matrix4 matrix)
{
mtxMdl *= matrix;
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref mtxMdl);
}
public void ResetModelMatrix()
{
mtxMdl = Matrix4.Identity;
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref mtxMdl);
}
protected override void OnLoad(EventArgs e)
{
if (DesignMode) return;
activeCamera = new WalkaroundCamera();
GL.Enable(EnableCap.DepthTest);
}
protected override void OnResize(EventArgs e)
{
if (DesignMode || this.Context == null) return;
MakeCurrent();
float aspect_ratio;
if (stereoscopy)
aspect_ratio = Width / 2 / (float)Height;
else
aspect_ratio = Width / (float)Height;
mtxProj = Matrix4.CreatePerspectiveFieldOfView(fov, aspect_ratio, znear, zfar);
//using the calculation from whitehole
factorX = (2f * (float)Math.Tan(fov * 0.5f) * aspect_ratio) / Width;
factorY = (2f * (float)Math.Tan(fov * 0.5f)) / Height;
}
protected override void OnPaint(PaintEventArgs e)
{
if (mainDrawable == null || DesignMode)
{
e.Graphics.Clear(this.BackColor);
e.Graphics.DrawString("Legacy Gl" + (stereoscopy ? " stereoscopy" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f);
return;
}
GL.ClearColor(0.125f, 0.125f, 0.125f, 1.0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
if (stereoscopy)
{
#region left eye
GL.Viewport(0, 0, Width / 2, Height);
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot + 0.02f) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
GL.MatrixMode(MatrixMode.Projection);
Matrix4 computedMatrix = mtxCam * mtxProj;
GL.LoadMatrix(ref computedMatrix);
mainDrawable.Draw(this);
#endregion
#region right eye
GL.Viewport(Width / 2, 0, Width / 2, Height);
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot - 0.02f) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
computedMatrix = mtxCam * mtxProj;
GL.LoadMatrix(ref computedMatrix);
mainDrawable.Draw(this);
#endregion
}
else
{
GL.Viewport(0, 0, Width, Height);
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot - 0.02f) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
GL.MatrixMode(MatrixMode.Projection);
Matrix4 computedMatrix = mtxCam * mtxProj;
GL.LoadMatrix(ref computedMatrix);
mainDrawable.Draw(this);
}
SwapBuffers();
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (mainDrawable == null) return;
lastMouseLoc = e.Location;
lastDepth = pickingDepth;
dragStartLoc = e.Location;
if (mainDrawable.MouseDown(e) ||
activeCamera.MouseDown(e, ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (mainDrawable == null) return;
float deltaX = viewPortDX(e.Location.X - lastMouseLoc.X);
float deltaY = e.Location.Y - lastMouseLoc.Y;
bool shouldredraw = false;
shouldredraw = shouldredraw || activeCamera.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom);
lastMouseLoc = e.Location;
#region picking
MakeCurrent();
GL.ClearColor(0f, 0f, 0f, 0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
if (stereoscopy)
GL.Viewport(0, 0, Width / 2, Height);
else
GL.Viewport(0, 0, Width, Height);
int pickingMouseX = stereoscopy ? (lastMouseLoc.X % (Width / 2)) : lastMouseLoc.X;
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot - (stereoscopy ? 0.02f : 0f)) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
GL.MatrixMode(MatrixMode.Projection);
Matrix4 computedMatrix = mtxCam * mtxProj;
GL.LoadMatrix(ref computedMatrix);
pickingIndex = 1;
mainDrawable.DrawPicking(this);
GL.Flush();
GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingModelDepth);
pickingModelDepth = -(zfar * znear / (pickingModelDepth * (zfar - znear) - zfar));
GL.Flush();
GL.ReadPixels(pickingMouseX - 1, Height - lastMouseLoc.Y + 1, 3, 3, PixelFormat.Bgra, PixelType.UnsignedByte, pickingFrameBuffer);
// depth math from http://www.opengl.org/resources/faq/technical/depthbuffer.htm
GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingDepth);
pickingDepth = -(zfar * znear / (pickingDepth * (zfar - znear) - zfar));
shouldredraw = shouldredraw || mainDrawable.Picked(pickingFrameBuffer[4]);
#endregion
shouldredraw = shouldredraw || mainDrawable.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), rot, lookup);
if (shouldredraw)
Refresh();
}
protected override void OnMouseWheel(MouseEventArgs e)
{
if (mainDrawable == null) return;
int x = viewPortX(e.X);
if (mainDrawable.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX,factorY, lastDepth), rot, lookup) ||
activeCamera.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
protected override void OnMouseUp(MouseEventArgs e)
{
if (mainDrawable == null) return;
bool shouldredraw = false;
if ((Math.Abs(e.X - dragStartLoc.X) < 3) && (Math.Abs(e.Y - dragStartLoc.Y) < 3))
{
shouldredraw = shouldredraw || mainDrawable.MouseClick(e) ||
activeCamera.MouseClick(e, ref camTarget, ref rot, ref lookup, ref zoom);
}
shouldredraw = shouldredraw || mainDrawable.MouseUp(e, dragStartLoc) ||
activeCamera.MouseUp(e, dragStartLoc, ref camTarget, ref rot, ref lookup, ref zoom);
if (shouldredraw)
Refresh();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (mainDrawable == null) return;
if (mainDrawable.KeyDown(e) ||
activeCamera.KeyDown(e, ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
protected override void OnKeyUp(KeyEventArgs e)
{
if (mainDrawable == null) return;
if (mainDrawable.KeyUp(e) ||
activeCamera.KeyUp(e, ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
}
}

View File

@ -1,37 +0,0 @@
namespace GL_Core
{
partial class GL_ControlModern
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
#endregion
}
}

View File

@ -1,352 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using GL_Core.Interfaces;
using GL_Core.Public_Interfaces;
using GL_Core.Cameras;
namespace GL_Core
{
public partial class GL_ControlModern : GLControl
{
public GL_ControlModern()
{
InitializeComponent();
}
private Point lastMouseLoc;
private Point dragStartLoc;
private float lastDepth = 1000f;
private ShaderProgram shader;
private AbstractCamera activeCamera;
float rot = 0;
float lookup = 0;
float zoom = -10f;
Vector3 camTarget;
public float zfar = 1000f;
public float znear = 0.01f;
public float PolyCount = 0;
public float VertCount = 0;
float fov = MathHelper.PiOver4;
uint[] pickingFrameBuffer = new uint[9];
int pickingIndex;
float pickingModelDepth = 0f;
private float pickingDepth = 0f;
public Matrix4 mtxMdl, mtxCam, mtxProj;
private float factorX, factorY;
bool stereoscopy;
bool displayPolyCount;
int viewPortX(int x) => stereoscopy ? x % (Width / 2) : x;
int viewPortDX(int dx) => stereoscopy ? dx * 2 : dx;
int viewPortXOff(int x) => stereoscopy ? (x - Width / 4) * 2 : x - Width / 2;
int viewPortWidth() => stereoscopy ? Width / 2 : Width;
public bool DisplayPolyCount
{
get => displayPolyCount;
set
{
displayPolyCount = value;
OnResize(null);
Refresh();
}
}
public bool Stereoscopy
{
get => stereoscopy;
set
{
stereoscopy = value;
OnResize(null);
Refresh();
}
}
public ShaderProgram CurrentShader
{
get => shader;
set
{
if (value == null) return;
shader = value;
shader.Setup(mtxMdl, mtxCam, mtxProj);
}
}
AbstractGlDrawable mainDrawable;
public List<AbstractGlDrawable> abstractGlDrawables = new List<AbstractGlDrawable>();
public AbstractGlDrawable MainDrawable
{
get => mainDrawable;
set
{
this.Visible = true;
if (value == null) return;
mainDrawable = value;
MakeCurrent();
mainDrawable.Prepare(this);
Refresh();
}
}
public AbstractCamera ActiveCamera
{
get => activeCamera;
set
{
if (value == null || this.Context == null) return;
activeCamera = value;
MakeCurrent();
Refresh();
}
}
public Color nextPickingColor()
{
return Color.FromArgb(pickingIndex++);
}
public void UpdateModelMatrix(Matrix4 matrix)
{
shader.UpdateModelMatrix(mtxMdl = matrix);
}
public void ApplyModelTransform(Matrix4 matrix)
{
shader.UpdateModelMatrix(mtxMdl *= matrix);
}
public void ResetModelMatrix()
{
shader.UpdateModelMatrix(mtxMdl = Matrix4.Identity);
}
protected override void OnLoad(EventArgs e)
{
if (DesignMode) return;
activeCamera = new InspectCamera();
GL.Enable(EnableCap.DepthTest);
}
protected override void OnResize(EventArgs e)
{
if (DesignMode || this.Context == null) return;
MakeCurrent();
float aspect_ratio;
if (stereoscopy)
aspect_ratio = Width/2 / (float)Height;
else
aspect_ratio = Width / (float)Height;
mtxProj = Matrix4.CreatePerspectiveFieldOfView(fov, aspect_ratio, znear, zfar);
//using the calculation from whitehole
factorX = (2f * (float)Math.Tan(fov * 0.5f) * aspect_ratio) / Width;
factorY = (2f * (float)Math.Tan(fov * 0.5f)) / Height;
}
protected override void OnPaint(PaintEventArgs e)
{
if (mainDrawable == null || DesignMode)
{
e.Graphics.Clear(this.BackColor);
e.Graphics.DrawString("Modern Gl" + (stereoscopy ? " stereoscopy" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f);
return;
}
// e.Graphics.DrawString((displayPolyCount ? $"poly count {PolyCount} vert count {VertCount}" : ""), SystemFonts.DefaultFont, SystemBrushes.ControlLight, 10f, 10f);
MakeCurrent();
GL.ClearColor(0.125f, 0.125f, 0.125f, 1.0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
if (stereoscopy)
{
#region left eye
GL.Viewport(0, 0, Width / 2, Height);
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot + 0.02f) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
mainDrawable.Draw(this);
#endregion
#region right eye
GL.Viewport(Width / 2, 0, Width / 2, Height);
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot - 0.02f) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
mainDrawable.Draw(this);
#endregion
}
else
{
GL.Viewport(0, 0, Width, Height);
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
mainDrawable.Draw(this);
}
SwapBuffers();
}
protected override void OnMouseDown(MouseEventArgs e)
{
if (mainDrawable == null) return;
lastMouseLoc = e.Location;
lastDepth = pickingDepth;
dragStartLoc = e.Location;
if (mainDrawable.MouseDown(e) ||
activeCamera.MouseDown(e, ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (mainDrawable == null) return;
float deltaX = viewPortDX(e.Location.X - lastMouseLoc.X);
float deltaY = (e.Location.Y - lastMouseLoc.Y);
bool shouldredraw = false;
shouldredraw = shouldredraw || activeCamera.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom);
lastMouseLoc = e.Location;
#region picking
MakeCurrent();
GL.ClearColor(0f, 0f, 0f, 0f);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
if (stereoscopy)
GL.Viewport(0, 0, Width / 2, Height);
else
GL.Viewport(0, 0, Width, Height);
int pickingMouseX = stereoscopy ? (lastMouseLoc.X % (Width / 2)) : lastMouseLoc.X;
mtxMdl = Matrix4.Identity;
mtxCam =
Matrix4.CreateTranslation(camTarget) *
Matrix4.CreateRotationY(rot - (stereoscopy?0.02f:0f)) *
Matrix4.CreateRotationX(lookup) *
Matrix4.CreateTranslation(0, 0, zoom);
pickingIndex = 1;
mainDrawable.DrawPicking(this);
GL.Flush();
GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingModelDepth);
pickingModelDepth = -(zfar * znear / (pickingModelDepth * (zfar - znear) - zfar));
GL.Flush();
GL.ReadPixels(pickingMouseX - 1, Height - lastMouseLoc.Y + 1, 3, 3, PixelFormat.Bgra, PixelType.UnsignedByte, pickingFrameBuffer);
// depth math from http://www.opengl.org/resources/faq/technical/depthbuffer.htm
GL.ReadPixels(pickingMouseX, Height - lastMouseLoc.Y, 1, 1, PixelFormat.DepthComponent, PixelType.Float, ref pickingDepth);
pickingDepth = -(zfar * znear / (pickingDepth * (zfar - znear) - zfar));
shouldredraw = shouldredraw || mainDrawable.Picked(pickingFrameBuffer[4]);
#endregion
shouldredraw = shouldredraw || mainDrawable.MouseMove(e, lastMouseLoc, deltaX, deltaY, new ExtraArgs(factorX, factorY, lastDepth), rot, lookup);
if (shouldredraw)
Refresh();
}
protected override void OnMouseWheel(MouseEventArgs e)
{
if (mainDrawable == null) return;
int x = viewPortX(e.X);
if (mainDrawable.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX, factorY, lastDepth), rot, lookup) ||
activeCamera.MouseWheel(e, viewPortXOff(x), e.Y - Height / 2, new ExtraArgs(factorX, factorY, lastDepth), ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
protected override void OnMouseUp(MouseEventArgs e)
{
if (mainDrawable == null) return;
bool shouldredraw = false;
if ((Math.Abs(e.X - dragStartLoc.X) < 3) && (Math.Abs(e.Y - dragStartLoc.Y) < 3))
{
shouldredraw = shouldredraw || mainDrawable.MouseClick(e) ||
activeCamera.MouseClick(e, ref camTarget, ref rot, ref lookup, ref zoom);
}
shouldredraw = shouldredraw || mainDrawable.MouseUp(e,dragStartLoc) ||
activeCamera.MouseUp(e, dragStartLoc, ref camTarget, ref rot, ref lookup, ref zoom);
if (shouldredraw)
Refresh();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (mainDrawable == null) return;
if (mainDrawable.KeyDown(e) ||
activeCamera.KeyDown(e, ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
protected override void OnKeyUp(KeyEventArgs e)
{
if (mainDrawable == null) return;
if (mainDrawable.KeyUp(e) ||
activeCamera.KeyUp(e, ref camTarget, ref rot, ref lookup, ref zoom))
Refresh();
}
}
}

View File

@ -1,77 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{29647BA5-2859-46F0-A99E-C3A387A9447A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GL_Core</RootNamespace>
<AssemblyName>GL_Core</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK">
<HintPath>..\..\Switch_Toolbox\Lib\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl">
<HintPath>..\..\Switch_Toolbox\Lib\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cameras\Inspect.cs" />
<Compile Include="Cameras\Walkaround.cs" />
<Compile Include="GL_ControlLegacy.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GL_ControlLegacy.Designer.cs">
<DependentUpon>GL_ControlLegacy.cs</DependentUpon>
</Compile>
<Compile Include="GL_ControlModern.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="GL_ControlModern.Designer.cs">
<DependentUpon>GL_ControlModern.cs</DependentUpon>
</Compile>
<Compile Include="Public Interfaces\AbstractCamera.cs" />
<Compile Include="Public Interfaces\AbstractGlDrawable.cs" />
<Compile Include="OldGlEmulator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShaderClass.cs" />
</ItemGroup>
<ItemGroup>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,52 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK.Graphics.OpenGL;
namespace GL_Core
{
public class OldGlEmulator : IDisposable
{
List<float> dataList = new List<float>();
float current_r = 255f;
float current_g = 255f;
float current_b = 255f;
float current_a = 255f;
public OldGlEmulator()
{
}
public void Vertex3(float x, float y, float z)
{
dataList.Add(x); dataList.Add(y); dataList.Add(z);
dataList.Add(current_r); dataList.Add(current_g); dataList.Add(current_b); dataList.Add(current_a);
}
public void Color3(float r, float g, float b)
{
current_r = r;
current_g = g;
current_b = b;
}
public void WriteToBuffer(int buffer) {
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
float[] arrayData = dataList.ToArray();
GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * arrayData.Length, arrayData, BufferUsageHint.StaticDraw);
GL.EnableVertexAttribArray(0);
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 7, 0);
GL.EnableVertexAttribArray(1);
GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 3);
}
public void Dispose()
{
}
}
}

View File

@ -1,25 +0,0 @@
<configuration>
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
<!-- XQuartz compatibility (X11 on Mac) -->
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
</configuration>

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GL_Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GL_Core")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("29647ba5-2859-46f0-a99e-c3a387a9447a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,36 +0,0 @@
using OpenTK;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GL_Core.Public_Interfaces
{
public abstract class AbstractCamera
{
public virtual bool MouseDown(MouseEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
public virtual bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
public virtual bool MouseUp(MouseEventArgs e, Point dragStartMousePos, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
public virtual bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
public virtual bool MouseClick(MouseEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
public virtual bool KeyDown(KeyEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
public virtual bool KeyUp(KeyEventArgs e, ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
public virtual bool TimeStep(ref Vector3 camTarget, ref float rot, ref float lookup, ref float zoom) { return false; }
}
public struct ExtraArgs{
public float factorX, factorY, pickingDepth;
public ExtraArgs(float factorX, float factorY, float pickingDepth)
{
this.factorX = factorX;
this.factorY = factorY;
this.pickingDepth = pickingDepth;
}
}
}

View File

@ -1,34 +0,0 @@
using GL_Core.Public_Interfaces;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GL_Core.Interfaces
{
public abstract class AbstractGlDrawable
{
public abstract void Prepare(GL_ControlModern control);
public abstract void Prepare(GL_ControlLegacy control);
public abstract void Draw(GL_ControlModern control);
public abstract void Draw(GL_ControlLegacy control);
public virtual void DrawPicking(GL_ControlModern control) { }
public virtual void DrawPicking(GL_ControlLegacy control) { }
public virtual bool Picked(uint index) { return false; }//handling for Picking
public virtual uint GetPickableSpan() => 0;//tells how many pickable subobjects are in this object
public virtual bool MouseDown(MouseEventArgs e) { return false; }
public virtual bool MouseMove(MouseEventArgs e, Point lastMouseLoc, float deltaX, float deltaY, ExtraArgs args, float rot, float lookup) { return false; }
public virtual bool MouseUp(MouseEventArgs e, Point dragStartMousePos) { return false; }
public virtual bool MouseWheel(MouseEventArgs e, float xoff, float yoff, ExtraArgs args, float rot, float lookup) { return false; }
public virtual bool MouseClick(MouseEventArgs e) { return false; }
public virtual bool KeyDown(KeyEventArgs e) { return false; }
public virtual bool KeyUp(KeyEventArgs e) { return false; }
public virtual bool TimeStep() { return false; }
}
}

View File

@ -1,138 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK;
using OpenTK.Graphics.OpenGL;
namespace GL_Core
{
public class ShaderProgram
{
private int fragSh, vertSh, program, mtxMdlLoc, mtxCamLoc;
private Matrix4 modelMatrix;
private Matrix4 computedCamMtx;
public ShaderProgram(FragmentShader frag, VertexShader vert)
{
fragSh = frag.shader;
vertSh = vert.shader;
program = GL.CreateProgram();
GL.AttachShader(program, vertSh);
GL.AttachShader(program, fragSh);
GL.LinkProgram(program);
Console.WriteLine("fragment:");
Console.WriteLine(GL.GetShaderInfoLog(fragSh));
Console.WriteLine("vertex:");
Console.WriteLine(GL.GetShaderInfoLog(fragSh));
mtxMdlLoc = GL.GetUniformLocation(program, "mtxMdl");
mtxCamLoc = GL.GetUniformLocation(program, "mtxCam");
}
public void AttachShader(ShaderGL shader)
{
GL.AttachShader(program, shader.shader);
}
public void DetachShader(ShaderGL shader)
{
GL.DetachShader(program, shader.shader);
}
public void LinkShaders()
{
GL.LinkProgram(program);
}
public void SetFragmentShader(FragmentShader shader)
{
GL.DetachShader(program, fragSh);
GL.AttachShader(program, shader.shader);
fragSh = shader.shader;
GL.LinkProgram(program);
}
public void SetVertexShader(VertexShader shader)
{
GL.DetachShader(program, vertSh);
GL.AttachShader(program, shader.shader);
vertSh = shader.shader;
GL.LinkProgram(program);
mtxMdlLoc = GL.GetUniformLocation(program, "mtxMdl");
mtxCamLoc = GL.GetUniformLocation(program, "mtxCam");
GL.UniformMatrix4(mtxMdlLoc, false, ref modelMatrix);
GL.UniformMatrix4(mtxCamLoc, false, ref computedCamMtx);
}
public void Setup(Matrix4 mtxMdl, Matrix4 mtxCam, Matrix4 mtxProj)
{
GL.UseProgram(program);
modelMatrix = mtxMdl;
GL.UniformMatrix4(mtxMdlLoc, false, ref modelMatrix);
computedCamMtx = mtxCam * mtxProj;
GL.UniformMatrix4(mtxCamLoc, false, ref computedCamMtx);
}
public void UpdateModelMatrix(Matrix4 matrix)
{
modelMatrix = matrix;
GL.UniformMatrix4(mtxMdlLoc, false, ref matrix);
}
public void Activate()
{
GL.UseProgram(program);
}
public int this[string name]{
get => GL.GetUniformLocation(program, name);
}
}
public class ShaderGL
{
public ShaderGL(string src, ShaderType type)
{
shader = GL.CreateShader(type);
GL.ShaderSource(shader, src);
GL.CompileShader(shader);
this.type = type;
}
public ShaderType type;
public int shader;
}
public class FragmentShader : ShaderGL
{
public FragmentShader(string src)
:base(src, ShaderType.FragmentShader)
{
}
}
public class GeomeryShader : ShaderGL
{
public GeomeryShader(string src)
: base(src, ShaderType.GeometryShader)
{
}
}
public class VertexShader : ShaderGL
{
public VertexShader(string src)
: base(src, ShaderType.VertexShader)
{
}
}
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="OpenTK" version="3.0.1" targetFramework="net461" />
<package id="OpenTK.GLControl" version="3.0.1" targetFramework="net461" />
</packages>

View File

@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2035
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GL_Core", "GL_Core\GL_Core.csproj", "{29647BA5-2859-46F0-A99E-C3A387A9447A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Testing", "Testing\Testing.csproj", "{47680B79-3772-4339-8808-A97F84450CCE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{29647BA5-2859-46F0-A99E-C3A387A9447A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29647BA5-2859-46F0-A99E-C3A387A9447A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29647BA5-2859-46F0-A99E-C3A387A9447A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29647BA5-2859-46F0-A99E-C3A387A9447A}.Release|Any CPU.Build.0 = Release|Any CPU
{47680B79-3772-4339-8808-A97F84450CCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47680B79-3772-4339-8808-A97F84450CCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47680B79-3772-4339-8808-A97F84450CCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47680B79-3772-4339-8808-A97F84450CCE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F399969A-9DEC-48B3-A7FA-4DBC9341DAA6}
EndGlobalSection
EndGlobal

View File

@ -1 +0,0 @@
# GL_EditorFramework

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

View File

@ -1,431 +0,0 @@
using GL_Core;
using GL_Core.Interfaces;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Testing
{
public class MarioTposeTest : AbstractGlDrawable
{
int testVao;
int marioTestVao;
ShaderProgram defaultShaderProgram;
FragmentShader defaultFrag;
VertexShader defaultVert, pickingVert;
ShaderProgram testShaderProgram;
uint pickedIndex = 0;
uint selectedIndex = 0;
public MarioTposeTest()
{
}
public override void Draw(GL_ControlModern control)
{
control.CurrentShader = testShaderProgram;
control.ResetModelMatrix();
GL.BindVertexArray(testVao);
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
GL.BindVertexArray(marioTestVao);
control.CurrentShader = defaultShaderProgram;
defaultShaderProgram.SetVertexShader(defaultVert);
control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0));
for (int i = 0; i < 5; i++)
{
if (i + 1 == selectedIndex)
GL.Uniform4(defaultShaderProgram["highlightColor"], 1f, 1f, 0.2f, 0.5f);
else if (i + 1 == pickedIndex)
GL.Uniform4(defaultShaderProgram["highlightColor"], 1f, 1f, 0.5f, 0.2f);
else
GL.Uniform4(defaultShaderProgram["highlightColor"], 0f, 0f, 0f, 0f);
GL.DrawArrays(PrimitiveType.Quads, 0, 11 * 4);
control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0));
}
}
public override void Draw(GL_ControlLegacy control)
{
control.ResetModelMatrix();
GL.Begin(PrimitiveType.Quads);
GL.Color3(1f, 0f, 0f);
GL.Vertex3(-10f, -0.25f, 5f);
GL.Color3(0f, 1f, 0f);
GL.Vertex3(10f, -0.25f, 5f);
GL.Color3(1f, 1f, 0f);
GL.Vertex3(10f, -0.25f, -5f);
GL.Color3(0f, 0f, 1f);
GL.Vertex3(-10f, -0.25f, -5f);
GL.End();
control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0));
for (int i = 0; i < 5; i++)
{
GL.Begin(PrimitiveType.Quads);
if(i+1==pickedIndex)
GL.Color3(0f, 1f, 0f);
else
GL.Color3(1f, 0f, 0f);
GL.Vertex3(-0.5f, 2f, 0f);
GL.Vertex3(0.5f, 2f, 0f);
GL.Vertex3(0.5f, 1.25f, 0f);
GL.Vertex3(-0.5f, 1.25f, 0f);
GL.Vertex3(-1.5f, 2.5f, 0f);
GL.Vertex3(1.5f, 2.5f, 0f);
GL.Vertex3(1.5f, 2f, 0f);
GL.Vertex3(-1.5f, 2f, 0f);
//trowsers
if (i + 1 == selectedIndex)
GL.Color3(1f, 1f, 1f);
else
GL.Color3(0, 0.2f, 1f);
GL.Vertex3(-0.5f, 1.25f, 0f);
GL.Vertex3(0.5f, 1.25f, 0f);
GL.Vertex3(0.5f, 0.75f, 0f);
GL.Vertex3(-0.5f, 0.75f, 0f);
GL.Vertex3(-0.5f, 0.75f, 0f);
GL.Vertex3(-0.125f, 0.75f, 0f);
GL.Vertex3(-0.125f, -0.25f, 0f);
GL.Vertex3(-0.5f, -0.25f, 0f);
GL.Vertex3(0.125f, 0.75f, 0f);
GL.Vertex3(0.5f, 0.75f, 0f);
GL.Vertex3(0.5f, -0.25f, 0f);
GL.Vertex3(0.125f, -0.25f, 0f);
//stripes
GL.Vertex3(-0.375f, 2.5f, -0.02f);
GL.Vertex3(-0.125f, 2.5f, -0.02f);
GL.Vertex3(-0.125f, 1.25f, -0.02f);
GL.Vertex3(-0.375f, 1.25f, -0.02f);
GL.Vertex3(0.125f, 2.5f, -0.02f);
GL.Vertex3(0.375f, 2.5f, -0.02f);
GL.Vertex3(0.375f, 1.25f, -0.02f);
GL.Vertex3(0.125f, 1.25f, -0.02f);
GL.Vertex3(-0.375f, 2.5f, 0.02f);
GL.Vertex3(-0.125f, 2.5f, 0.02f);
GL.Vertex3(-0.125f, 1.25f, 0.02f);
GL.Vertex3(-0.375f, 1.25f, 0.02f);
GL.Vertex3(0.125f, 2.5f, 0.02f);
GL.Vertex3(0.375f, 2.5f, 0.02f);
GL.Vertex3(0.375f, 1.25f, 0.02f);
GL.Vertex3(0.125f, 1.25f, 0.02f);
//knobs
GL.Color3(1f, 1f, 0f);
GL.Vertex3(-0.375f, 2.25f, 0.04f);
GL.Vertex3(-0.125f, 2.25f, 0.04f);
GL.Vertex3(-0.125f, 2f, 0.04f);
GL.Vertex3(-0.375f, 2f, 0.04f);
GL.Vertex3(0.125f, 2.25f, 0.04f);
GL.Vertex3(0.375f, 2.25f, 0.04f);
GL.Vertex3(0.375f, 2f, 0.04f);
GL.Vertex3(0.125f, 2f, 0.04f);
GL.End();
control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0));
}
}
public override void Prepare(GL_ControlModern control)
{
defaultFrag = new FragmentShader(
@"#version 330
in vec4 fragColor;
void main(){
gl_FragColor = fragColor;
}");
defaultVert = new VertexShader(
@"#version 330
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 color;
uniform mat4 mtxMdl;
uniform mat4 mtxCam;
uniform vec4 highlightColor;
out vec4 fragColor;
void main(){
gl_Position = mtxCam*mtxMdl*position;
fragColor = color+highlightColor.xyz*highlightColor.w;
}");
pickingVert = new VertexShader(
@"#version 330
layout(location = 0) in vec4 position;
uniform vec4 color;
uniform mat4 mtxMdl;
uniform mat4 mtxCam;
out vec4 fragColor;
void main(){
gl_Position = mtxCam*mtxMdl*position;
fragColor = color;
}");
defaultShaderProgram = new ShaderProgram(
defaultFrag,defaultVert
);
testShaderProgram = new ShaderProgram(
new FragmentShader(
@"#version 330
in vec4 vertPosition;
in vec4 fragColor;
void main(){
float v = round(abs(mod(vertPosition.x,2.0)-1.0)+
abs(mod(vertPosition.z,2.0)-1.0));
gl_FragColor = fragColor*v;
}"),
new VertexShader(
@"#version 330
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 color;
uniform mat4 mtxMdl;
uniform mat4 mtxCam;
out vec4 vertPosition;
out vec4 fragColor;
void main(){
gl_Position = mtxMdl*mtxCam*position;
vertPosition = position;
fragColor = color;
}"));
control.CurrentShader = defaultShaderProgram;
int buffer;
GL.BindVertexArray(testVao = GL.GenVertexArray());
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer = GL.GenBuffer());
float[] data = new float[] {
-10f, -0.25f, 5f, 1f, 0f, 0f, 1f,
10f, -0.25f, 5f, 0f, 1f, 0f, 1f,
10f, -0.25f, -5f, 1f, 1f, 0f, 1f,
-10f, -0.25f, -5f, 0f, 0f, 1f, 1f,
};
GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * data.Length, data, BufferUsageHint.StaticDraw);
GL.EnableVertexAttribArray(0);
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeof(float) * 7, 0);
GL.EnableVertexAttribArray(1);
GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, sizeof(float) * 7, sizeof(float) * 3);
GL.BindVertexArray(marioTestVao = GL.GenVertexArray());
using (OldGlEmulator GL = new OldGlEmulator())
{
//body
GL.Color3(1f, 0f, 0f);
GL.Vertex3(-0.5f, 2f, 0f);
GL.Vertex3(0.5f, 2f, 0f);
GL.Vertex3(0.5f, 1.25f, 0f);
GL.Vertex3(-0.5f, 1.25f, 0f);
GL.Vertex3(-1.5f, 2.5f, 0f);
GL.Vertex3(1.5f, 2.5f, 0f);
GL.Vertex3(1.5f, 2f, 0f);
GL.Vertex3(-1.5f, 2f, 0f);
//trowsers
GL.Color3(0, 0.2f, 1f);
GL.Vertex3(-0.5f, 1.25f, 0f);
GL.Vertex3(0.5f, 1.25f, 0f);
GL.Vertex3(0.5f, 0.75f, 0f);
GL.Vertex3(-0.5f, 0.75f, 0f);
GL.Vertex3(-0.5f, 0.75f, 0f);
GL.Vertex3(-0.125f, 0.75f, 0f);
GL.Vertex3(-0.125f, -0.25f, 0f);
GL.Vertex3(-0.5f, -0.25f, 0f);
GL.Vertex3(0.125f, 0.75f, 0f);
GL.Vertex3(0.5f, 0.75f, 0f);
GL.Vertex3(0.5f, -0.25f, 0f);
GL.Vertex3(0.125f, -0.25f, 0f);
//stripes
GL.Vertex3(-0.375f, 2.5f, -0.02f);
GL.Vertex3(-0.125f, 2.5f, -0.02f);
GL.Vertex3(-0.125f, 1.25f, -0.02f);
GL.Vertex3(-0.375f, 1.25f, -0.02f);
GL.Vertex3(0.125f, 2.5f, -0.02f);
GL.Vertex3(0.375f, 2.5f, -0.02f);
GL.Vertex3(0.375f, 1.25f, -0.02f);
GL.Vertex3(0.125f, 1.25f, -0.02f);
GL.Vertex3(-0.375f, 2.5f, 0.02f);
GL.Vertex3(-0.125f, 2.5f, 0.02f);
GL.Vertex3(-0.125f, 1.25f, 0.02f);
GL.Vertex3(-0.375f, 1.25f, 0.02f);
GL.Vertex3(0.125f, 2.5f, 0.02f);
GL.Vertex3(0.375f, 2.5f, 0.02f);
GL.Vertex3(0.375f, 1.25f, 0.02f);
GL.Vertex3(0.125f, 1.25f, 0.02f);
//knobs
GL.Color3(1f, 1f, 0f);
GL.Vertex3(-0.375f, 2.25f, 0.04f);
GL.Vertex3(-0.125f, 2.25f, 0.04f);
GL.Vertex3(-0.125f, 2f, 0.04f);
GL.Vertex3(-0.375f, 2f, 0.04f);
GL.Vertex3(0.125f, 2.25f, 0.04f);
GL.Vertex3(0.375f, 2.25f, 0.04f);
GL.Vertex3(0.375f, 2f, 0.04f);
GL.Vertex3(0.125f, 2f, 0.04f);
GL.WriteToBuffer(buffer = OpenTK.Graphics.OpenGL.GL.GenBuffer());
}
}
public override void Prepare(GL_ControlLegacy control)
{
}
public override bool MouseClick(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
selectedIndex = pickedIndex;
return true;
}
return false;
}
public override void DrawPicking(GL_ControlModern control)
{
defaultShaderProgram.SetVertexShader(pickingVert);
control.ResetModelMatrix();
GL.Uniform4(defaultShaderProgram["color"], 0f, 0f, 0f, 0f);
GL.BindVertexArray(testVao);
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
GL.BindVertexArray(marioTestVao);
control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0));
for (int i = 0; i < 5; i++)
{
GL.Uniform4(defaultShaderProgram["color"], control.nextPickingColor());
GL.DrawArrays(PrimitiveType.Quads, 0, 11 * 4);
control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0));
}
}
public override void DrawPicking(GL_ControlLegacy control)
{
control.ResetModelMatrix();
GL.Begin(PrimitiveType.Quads);
GL.Color4(0,0,0,0);
GL.Vertex3(-10f, -0.25f, 5f);
GL.Vertex3(10f, -0.25f, 5f);
GL.Vertex3(10f, -0.25f, -5f);
GL.Vertex3(-10f, -0.25f, -5f);
GL.End();
control.ApplyModelTransform(Matrix4.CreateTranslation(-8, 0, 0));
for (int i = 0; i < 5; i++)
{
GL.Begin(PrimitiveType.Quads);
GL.Color4(control.nextPickingColor());
GL.Vertex3(-0.5f, 2f, 0f);
GL.Vertex3(0.5f, 2f, 0f);
GL.Vertex3(0.5f, 1.25f, 0f);
GL.Vertex3(-0.5f, 1.25f, 0f);
GL.Vertex3(-1.5f, 2.5f, 0f);
GL.Vertex3(1.5f, 2.5f, 0f);
GL.Vertex3(1.5f, 2f, 0f);
GL.Vertex3(-1.5f, 2f, 0f);
//trowsers
GL.Vertex3(-0.5f, 1.25f, 0f);
GL.Vertex3(0.5f, 1.25f, 0f);
GL.Vertex3(0.5f, 0.75f, 0f);
GL.Vertex3(-0.5f, 0.75f, 0f);
GL.Vertex3(-0.5f, 0.75f, 0f);
GL.Vertex3(-0.125f, 0.75f, 0f);
GL.Vertex3(-0.125f, -0.25f, 0f);
GL.Vertex3(-0.5f, -0.25f, 0f);
GL.Vertex3(0.125f, 0.75f, 0f);
GL.Vertex3(0.5f, 0.75f, 0f);
GL.Vertex3(0.5f, -0.25f, 0f);
GL.Vertex3(0.125f, -0.25f, 0f);
//stripes
GL.Vertex3(-0.375f, 2.5f, -0.02f);
GL.Vertex3(-0.125f, 2.5f, -0.02f);
GL.Vertex3(-0.125f, 1.25f, -0.02f);
GL.Vertex3(-0.375f, 1.25f, -0.02f);
GL.Vertex3(0.125f, 2.5f, -0.02f);
GL.Vertex3(0.375f, 2.5f, -0.02f);
GL.Vertex3(0.375f, 1.25f, -0.02f);
GL.Vertex3(0.125f, 1.25f, -0.02f);
GL.Vertex3(-0.375f, 2.5f, 0.02f);
GL.Vertex3(-0.125f, 2.5f, 0.02f);
GL.Vertex3(-0.125f, 1.25f, 0.02f);
GL.Vertex3(-0.375f, 1.25f, 0.02f);
GL.Vertex3(0.125f, 2.5f, 0.02f);
GL.Vertex3(0.375f, 2.5f, 0.02f);
GL.Vertex3(0.375f, 1.25f, 0.02f);
GL.Vertex3(0.125f, 1.25f, 0.02f);
//knobs
GL.Vertex3(-0.375f, 2.25f, 0.04f);
GL.Vertex3(-0.125f, 2.25f, 0.04f);
GL.Vertex3(-0.125f, 2f, 0.04f);
GL.Vertex3(-0.375f, 2f, 0.04f);
GL.Vertex3(0.125f, 2.25f, 0.04f);
GL.Vertex3(0.375f, 2.25f, 0.04f);
GL.Vertex3(0.375f, 2f, 0.04f);
GL.Vertex3(0.125f, 2f, 0.04f);
GL.End();
control.ApplyModelTransform(Matrix4.CreateTranslation(4, 0, 0));
}
}
public override bool Picked(uint index)
{
pickedIndex = index;
Console.WriteLine(index);
return true;
}
public override uint GetPickableSpan(){
return 5;
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Testing
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TestingForm());
}
}
}

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GL_EditorFramework")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GL_EditorFramework")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("47680b79-3772-4339-8808-a97f84450cce")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,71 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Testing.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GL_EditorFramework.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,30 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Testing.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -1,81 +0,0 @@
namespace Testing
{
partial class TestingForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.gL_ControlModern1 = new GL_Core.GL_ControlModern();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// gL_ControlModern1
//
this.gL_ControlModern1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gL_ControlModern1.BackColor = System.Drawing.Color.Black;
this.gL_ControlModern1.Location = new System.Drawing.Point(0, 35);
this.gL_ControlModern1.MainDrawable = null;
this.gL_ControlModern1.Name = "gL_ControlModern1";
this.gL_ControlModern1.Size = new System.Drawing.Size(800, 467);
this.gL_ControlModern1.Stereoscopy = false;
this.gL_ControlModern1.TabIndex = 0;
this.gL_ControlModern1.VSync = false;
this.gL_ControlModern1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.gL_ControlModern1_MouseClick);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(12, 12);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(85, 17);
this.checkBox1.TabIndex = 1;
this.checkBox1.Text = "Stereoscopy";
this.checkBox1.UseVisualStyleBackColor = true;
this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
//
// TestingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 501);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.gL_ControlModern1);
this.Name = "TestingForm";
this.Text = "Test Window";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private GL_Core.GL_ControlModern gL_ControlModern1;
private System.Windows.Forms.CheckBox checkBox1;
}
}

View File

@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using GL_Core;
namespace Testing
{
public partial class TestingForm : Form
{
public TestingForm()
{
InitializeComponent();
}
private void gL_ControlModern1_MouseClick(object sender, MouseEventArgs e)
{
if(gL_ControlModern1.MainDrawable==null)
gL_ControlModern1.MainDrawable = new MarioTposeTest();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
gL_ControlModern1.Stereoscopy = checkBox1.Checked;
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,95 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{47680B79-3772-4339-8808-A97F84450CCE}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>GL_EditorFramework</RootNamespace>
<AssemblyName>GL_EditorFramework</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK">
<HintPath>..\packages\OpenTK.3.0.1\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl">
<HintPath>..\packages\OpenTK.GLControl.3.0.1\lib\net20\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MarioTposeTest.cs" />
<Compile Include="TestForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="TestForm.Designer.cs">
<DependentUpon>TestForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="TestForm.resx">
<DependentUpon>TestForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GL_Core\GL_Core.csproj">
<Project>{29647BA5-2859-46F0-A99E-C3A387A9447A}</Project>
<Name>GL_Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

127
README.md
View File

@ -1,127 +0,0 @@
# Switch-Toolbox
A tool to edit many formats of Nintendo Switch and some Wii U.
## Changelog
v0.8.5.1
- Basic .nutexb dds injection. Must be same width/height and format due to .arc size limitations atm!
v0.8.4 - v0.8.5
- Textures for Wii U deswizzle properly thanks to AboodXD.
- Zstb compressed files will be detected and decompressed automatically on open.
- Textures BC1-BC5 will show properly if DirectXTex is not working on older windows versions. Small work around atm.
- Improper transformations (like bad rotations) should be fixed now.
- Basic GTX file viewing
- Fixed BNTX texture alignment if there is only one texture present in the file.
- Many more bug fixes to enhance the user experience.
v0.8.3
- Support all nutexb formats from .arc.
- Fix brightness issues for nutexb srgb (using unorm for decoding atm).
v0.8.2 Changelog
- Fixed nutexb errors (incorrect sizes)
- Batch exporting nutexb works properly now. Will export with offset for unique name.
- DDS save properly to open in photoshop and other programs.
v0.8.1 Changelog
- Fixed error messages and freezes from nutexb.
v0.8 Changelog
- DDS compression reworked allowing png importing, and previewing of all DDS formats from [DirectXTex](https://github.com/Microsoft/DirectXTex).
- Exporting/importing of all animation types as binary.
- .Nutexb previewing/exporting. (and batch exporting)
- DAE/FBX rigging supported. Models will no longer show invisible.
- Improvements to BFRES library. Some games may work better now.
- Channel types are now set on import. May fix normal map issues.
- Archives use double click for opening files
- DDS cubemaps can be imported
- GFPAK repacking (untested)
- Animations for skeleton animations can be played (thanks to smash forge).
- Improvements to UI. May load quicker.
- Update bake map placeholder textures to look proper.
- Many improvements and big fixes!
v0.72 Changelog
- Fixed crashes from RGBA DDS.
- Added an option to disable viewport. (May be quicker, and for those who use old GL versions).
v0.71 Changelog
- Stability improvements.
- Add byml editor back in.
- Some bug fixes and exception issues
This tool currently features:
- BFRES
- Model importing (dae, fbx, obj, and csv)
- Material editing (Render info, texture mapping, parameters, etc)
- Material copying
- Animation and model sub section can be exported/imported.
- Can delete, add, replace individual objects from an fmdl.
- BNTX
- Can add/remove textures.
- Can import textures as DDS. (Thanks to AboodXD! png/jpeg, etc planned later)
- Can export as binary, dds, png, tga, etc.
- Can preview mipmap and surface(array) levels.
- NUTEXB
- Can export as binary, dds, png, tga, etc.
- Can preview.
- SARC
- Supported editing/saving data opened. (Automatically saves data opened in objectlist if supported)
- Supports padding (Thanks to Exelix and AboodXD)
- Can save sarcs in sarcs in sarcs.
- BARS
- Can extract and replace audio files.. (rebuilds the file)
- KCL
- Preview collision models.
- Replace/Export as obj (Thanks to Exelix)
- BFFNT
- Can extract font images and preview their image arrays (BNTX)
- GFPAK
- Can extract, edit, and rebuild (untested).
## Building
To build make sure you have Visual Studio installed (I use 2017, older versions may not work) and open the .sln. Then build the solution as release. It should compile properly on the latest.
In the event that the tool cannot compile, check references. All the libraries are stored in Switch-Toolbox/Lib folder.
## This tool is in BETA and not final! Code also needs some major clean up!
## Credits
- Smash Forge Devs (SMG, Ploaj, jam1garner, smb123w64gb, etc) for some code ported over. Specifically animation stuff, GTX c# implementation, and some rendering.
- Assimp devs for their massive asset library!
- Wexos (helped figure out a few things, ie format list to assign each attribute)
- JuPaHe64 for the base 3D renderer.
- Every File Explorer devs (Gericom) for Yaz0 stuff
- Exelix for Byaml, Sarc and KCL library
- Syroot for helpful IO extensions and libraries
- GDK Chan for some DDS decode methods
- AboodXD for some foundation stuff with exelix's SARC library, GTX and BNTX texture swizzling and documentation
- MelonSpeedruns for logo.
Resources
- [Treeview Icons by icons8](https://icons8.com/)
- Smash Forge (Currently placeholders)
Libraries
- [Exelix (Sarc, kcl, and byml libraries)](https://github.com/exelix11/EditorCore/tree/master/FileFormatPlugins)
- [ZstdNet (Compression)](https://github.com/skbkontur/ZstdNet)
- [Be.HexEditor by Bernhard Elbl](https://sourceforge.net/projects/hexbox/)
- GL EditorFramwork by jupahe64
- [WeifenLuo for docking suite](http://dockpanelsuite.com/)
- [SF Graphics by SMG (Experimental](https://github.com/ScanMountGoat/SFGraphics) (currently just a placeholder for shader workflow and some useful things)
- [Audio & MIDI library](https://github.com/naudio/NAudio)
- [VGAudio](https://github.com/Thealexbarney/VGAudio)
- [Assimp](https://bitbucket.org/Starnick/assimpnet/src/master/)
- [OpenTK](https://github.com/opentk/opentk)
- [BezelEngineArchive Library](https://github.com/KillzXGaming/BEA-Library-Editor)
- [Syroot BinaryData](https://gitlab.com/Syroot/BinaryData)
- [Syroot Maths](https://gitlab.com/Syroot/Maths)
- [Syroot Bfres Library (Wii U)](https://gitlab.com/Syroot/NintenTools.Bfres)
- [Costura for embedding data for plugins](https://github.com/Fody/Costura)
- [CsvHelper (unused atm but planned to be used](https://joshclose.github.io/CsvHelper/)
License
in Switch_Toolbox\Lib\Licenses
Please note if you do not want your library used or if i'm missing credits!

View File

@ -1,96 +0,0 @@
using System;
using System.Collections.Generic;
using System.Xml;
using System.Drawing;
using System.IO;
using Switch_Toolbox.Library;
namespace FirstPlugin
{
//Based on
// https://github.com/jam1garner/Smash-Forge/blob/26e0dcbd84cdf8a4ffe3fbe0b0317520a4099286/Smash%20Forge/Filetypes/Application/Config.cs
class Config
{
public static void StartupFromFile(string fileName)
{
if (!File.Exists(fileName))
{
Save();
return;
}
ReadConfigFromFile(fileName);
}
private static void ReadConfigFromFile(string fileName)
{
int discordImageKey;
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
Queue<XmlNode> que = new Queue<XmlNode>();
foreach (XmlNode node in doc.ChildNodes)
que.Enqueue(node);
while (que.Count > 0)
{
XmlNode node = que.Dequeue();
foreach (XmlNode n in node.ChildNodes)
que.Enqueue(n);
switch (node.Name)
{
case "FSHPDockState":
if (node.ParentNode != null && node.ParentNode.Name.Equals("DOCKSETTINGS"))
Enum.TryParse(node.InnerText, out PluginRuntime.FSHPDockState);
break;
case "ExternalFMATPath":
if (node.ParentNode != null && node.ParentNode.Name.Equals("PATHSETTINGS"))
if (File.Exists(node.InnerText))
PluginRuntime.ExternalFMATPath = node.InnerText;
break;
case "MarioOdysseyGamePath":
if (node.ParentNode != null && node.ParentNode.Name.Equals("PATHSETTINGS"))
if (File.Exists(node.InnerText))
PluginRuntime.OdysseyGamePath = node.InnerText;
break;
}
}
}
public static void Save()
{
XmlDocument doc = CreateXmlFromSettings();
doc.Save("Lib/Plugins/config.xml");
}
private static XmlDocument CreateXmlFromSettings()
{
XmlDocument doc = new XmlDocument();
XmlNode mainNode = doc.CreateElement("FORGECONFIG");
doc.AppendChild(mainNode);
AppendDOCKSettings(doc, mainNode);
AppendPathSettings(doc, mainNode);
return doc;
}
private static void AppendPathSettings(XmlDocument doc, XmlNode parentNode)
{
XmlNode pathSettingsNode = doc.CreateElement("PATHSETTINGS");
parentNode.AppendChild(pathSettingsNode);
pathSettingsNode.AppendChild(createNode(doc, "ExternalFMATPath", PluginRuntime.ExternalFMATPath));
pathSettingsNode.AppendChild(createNode(doc, "MarioOdysseyGamePath", PluginRuntime.OdysseyGamePath));
}
private static void AppendDOCKSettings(XmlDocument doc, XmlNode parentNode)
{
XmlNode renderSettingsNode = doc.CreateElement("DOCKSETTINGS");
parentNode.AppendChild(renderSettingsNode);
renderSettingsNode.AppendChild(createNode(doc, "FSHPDockState", PluginRuntime.FSHPDockState.ToString()));
}
public static XmlNode createNode(XmlDocument doc, string el, string v)
{
XmlNode floorstyle = doc.CreateElement(el);
floorstyle.InnerText = v;
return floorstyle;
}
}
}

View File

@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
namespace FirstPlugin
{
public class AAMP : IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "AAMP" };
public string[] Extension { get; set; } = new string[] { "*.aamp" };
public string Magic { get; set; } = "AAMP";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
}
}

View File

@ -1,238 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using BarsLib;
using WeifenLuo.WinFormsUI.Docking;
using VGAudio.Formats;
using VGAudio;
using VGAudio.Containers.NintendoWare;
using VGAudio.Containers.Wave;
using NAudio.Wave;
namespace FirstPlugin
{
public class BARS : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "Sound Archive" };
public string[] Extension { get; set; } = new string[] { "*.bars" };
public string Magic { get; set; } = "BARS";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public class AudioEntry : TreeNodeCustom
{
public AudioType Type;
public byte[] Data;
BFAVEditor BFAVEditor;
public AudioEntry()
{
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public void SetupMusic()
{
if (Type == AudioType.Bfwav)
{
ImageKey = "bfwav";
SelectedImageKey = "bfwav";
}
else if (Type == AudioType.Bfstp)
{
ImageKey = "bfstp";
SelectedImageKey = "bfstp";
}
else
{
ImageKey = "fileBlank";
SelectedImageKey = "fileBlank";
}
}
public AudioData GetAudioData()
{
BCFstmReader reader = new BCFstmReader();
return reader.Read(Data);
}
public byte[] BfwavToWav()
{
MemoryStream mem = new MemoryStream();
WaveWriter writer = new WaveWriter();
AudioData audioData = GetAudioData();
writer.WriteToStream(audioData, mem);
return mem.ToArray();
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = Path.GetExtension(Text);
sfd.Filter = "All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
File.WriteAllBytes(sfd.FileName, Data);
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.FileName = Text;
ofd.DefaultExt = Path.GetExtension(Text);
ofd.Filter = "All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
Data = File.ReadAllBytes(ofd.FileName);
UpdateEditor();
}
}
public void UpdateEditor()
{
if (Viewport.Instance.gL_ControlModern1.Visible == false)
PluginRuntime.FSHPDockState = WeifenLuo.WinFormsUI.Docking.DockState.Document;
BFAVEditor docked = (BFAVEditor)LibraryGUI.Instance.GetContentDocked(new BFAVEditor());
if (docked == null)
{
docked = new BFAVEditor();
LibraryGUI.Instance.LoadDockContent(docked, PluginRuntime.FSHPDockState);
}
docked.Text = Text;
docked.Dock = DockStyle.Fill;
docked.LoadFile(this);
}
public override void OnClick(TreeView treeview)
{
if (Type == AudioType.Bfwav)
{
UpdateEditor();
}
} bool EditorIsActive(DockContent dock)
{
foreach (Control ctrl in dock.Controls)
{
if (ctrl is BFAVEditor)
{
dock.Text = Text;
((BFAVEditor)ctrl).LoadFile(this);
return true;
}
}
return false;
}
}
public BarsLib.BARS bars;
public void Load()
{
IsActive = true;
CanSave = true;
Text = FileName;
bars = new BarsLib.BARS(new MemoryStream(Data));
Nodes.Add("AMTA");
Nodes.Add("Audio");
for (int i = 0; i < bars.AmtaList.Count; i++)
{
string audioName = bars.AmtaList[i].Name;
Nodes[0].Nodes.Add(audioName + ".amta");
BARSAudioFile audio = bars.audioList[i];
AudioEntry node = new AudioEntry();
node.Type = audio.AudioType;
node.Data = audio.data;
node.SetupMusic();
if (audio.AudioType == AudioType.Bfwav)
node.Text = audioName + ".bfwav";
else if (audio.AudioType == AudioType.Bfstp)
node.Text = audioName + ".bfstp";
else
node.Text = audioName + ".UNKOWN";
Nodes[1].Nodes.Add(node);
}
ContextMenu = new ContextMenu();
MenuItem save = new MenuItem("Save");
ContextMenu.MenuItems.Add(save);
save.Click += Save;
}
public void Unload()
{
}
private void Save(object sender, EventArgs args)
{
List<IFileFormat> formats = new List<IFileFormat>();
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(formats);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName);
}
}
public byte[] Save()
{
MemoryStream mem = new MemoryStream();
foreach (TreeNode node in Nodes[1].Nodes)
{
for (int i = 0; i < bars.AmtaList.Count; i++)
{
string audioName = bars.AmtaList[i].Name;
if (Path.GetFileNameWithoutExtension(node.Text) == audioName)
{
Console.WriteLine(audioName);
bars.audioList[i].data = ((AudioEntry)node).Data;
}
}
}
bars.Save(mem);
return mem.ToArray();
}
}
}

View File

@ -1,536 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using System.IO;
using BezelEngineArchive_Lib;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
namespace FirstPlugin
{
public class BEA : TreeNode, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "Bevel Engine Archive" };
public string[] Extension { get; set; } = new string[] { "*.bea" };
public string Magic { get; set; } = "SCNE";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
types.Add(typeof(MenuExt));
return types.ToArray();
}
}
class MenuExt : IFileMenuExtension
{
public ToolStripItemDark[] NewFileMenuExtensions => null;
public ToolStripItemDark[] ToolsMenuExtensions => null;
public ToolStripItemDark[] TitleBarExtensions => null;
public ToolStripItemDark[] CompressionMenuExtensions => null;
public ToolStripItemDark[] ExperimentalMenuExtensions => experimentalMenu;
ToolStripItemDark[] experimentalMenu = new ToolStripItemDark[1];
public MenuExt()
{
experimentalMenu[0] = new ToolStripItemDark("BEA");
ToolStripItemDark batchLUA = new ToolStripItemDark("Batch Extract LUA");
batchLUA.Click += BatchExtractLUA;
experimentalMenu[0].DropDownItems.Add(batchLUA);
}
private void BatchExtractLUA(object sender, EventArgs e)
{
FolderSelectDialog ofd = new FolderSelectDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
string folderPath = ofd.SelectedPath;
foreach (string file in Directory.GetFiles(folderPath))
{
Console.WriteLine(file);
if (Path.GetExtension(file) == ".bea")
{
BEA bea = new BEA();
bea.Data = File.ReadAllBytes(file);
bea.FileName = file;
bea.Load();
foreach (FileEntry asset in bea.Nodes)
{
if (Path.GetExtension(asset.FullName) == ".lua")
{
try
{
if (!String.IsNullOrWhiteSpace(Path.GetDirectoryName($"{folderPath}/{bea.Name}/{asset.FullName}")))
{
if (!File.Exists(asset.FullName))
{
if (!Directory.Exists($"{folderPath}/{bea.Name}/{asset.FullName}"))
{
Directory.CreateDirectory(Path.GetDirectoryName($"{folderPath}/{bea.Name}/{asset.FullName}"));
}
}
}
File.WriteAllBytes($"{folderPath}/{bea.Name}/{asset.FullName}", GetASSTData(asset));
}
catch
{
}
}
}
}
}
}
}
}
public static BezelEngineArchive beaFile;
static ProgressBarWindow progressBar;
public void Load()
{
Text = FileName;
IsActive = true;
CanSave = true;
beaFile = new BezelEngineArchive(new MemoryStream(Data));
FillTreeNodes(this, beaFile.FileList);
ContextMenu = new ContextMenu();
MenuItem save = new MenuItem("Save");
ContextMenu.MenuItems.Add(save);
save.Click += Save;
MenuItem previewFiles = new MenuItem("Preview Window");
ContextMenu.MenuItems.Add(previewFiles);
previewFiles.Click += PreviewWindow;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
}
public void Unload()
{
}
IEnumerable<TreeNode> Collect(TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes)
{
yield return node;
foreach (var child in Collect(node.Nodes))
yield return child;
}
}
private void Save(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
List<IFileFormat> formats = new List<IFileFormat>();
formats.Add(this);
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(formats);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName);
}
GC.Collect();
}
public byte[] Save()
{
beaFile.FileList.Clear();
beaFile.FileDictionary.Clear();
foreach (TreeNode node in Collect(Nodes))
{
if (node is TreeNodeFile && node != this)
{
IFileFormat fileFormat = (IFileFormat)node;
if (fileFormat != null)
{
byte[] uncomrompressedData = fileFormat.Data;
//Save any active files in the editor if supported
if (fileFormat.CanSave)
uncomrompressedData = fileFormat.Save();
//Create a new asset entry
ASST asset = new ASST();
asset.unk = 2;
asset.unk2 = 2;
asset.UncompressedSize = uncomrompressedData.LongLength;
if (fileFormat.FileIsCompressed)
asset.FileData = STLibraryCompression.ZSTD.Compress(uncomrompressedData);
else
asset.FileData = fileFormat.Data;
asset.FileName = fileFormat.FilePath;
beaFile.FileList.Add(fileFormat.FilePath, asset);
beaFile.FileDictionary.Add(fileFormat.FilePath);
}
}
else if (node is FileEntry)
{
ASST asset = new ASST();
asset.unk = ((FileEntry)node).unk1;
asset.unk2 = ((FileEntry)node).unk2;
asset.FileName = ((FileEntry)node).FullName;
asset.FileData = ((FileEntry)node).data;
byte[] uncomp = GetASSTData((FileEntry)node);
asset.UncompressedSize = uncomp.Length;
beaFile.FileList.Add(asset.FileName, asset);
beaFile.FileDictionary.Add(asset.FileName);
}
}
MemoryStream mem = new MemoryStream();
beaFile.Save(mem);
return mem.ToArray();
}
private void ExportAll(object sender, EventArgs args)
{
FolderSelectDialog fsd = new FolderSelectDialog();
if (fsd.ShowDialog() == DialogResult.OK)
{
progressBar = new ProgressBarWindow();
progressBar.Task = "Extracing Files...";
progressBar.Refresh();
progressBar.Value = 0;
progressBar.StartPosition = FormStartPosition.CenterScreen;
progressBar.Show();
ExportAll(fsd.SelectedPath, progressBar);
}
}
private void ExportAll(string Folder, ProgressBarWindow progressBar)
{
int Curfile = 0;
foreach (FileEntry asst in Nodes)
{
int value = (Curfile * 100) / beaFile.FileList.Count;
progressBar.Value = value;
progressBar.Refresh();
try
{
if (!String.IsNullOrWhiteSpace(Path.GetDirectoryName($"{Folder}/{beaFile.Name}/{asst.FullName}")))
{
if (!File.Exists(asst.FullName))
{
if (!Directory.Exists($"{Folder}/{beaFile.Name}/{asst.FullName}"))
{
Directory.CreateDirectory(Path.GetDirectoryName($"{Folder}/{beaFile.Name}/{asst.FullName}"));
}
}
}
File.WriteAllBytes($"{Folder}/{beaFile.Name}/{asst.FullName}", GetASSTData(asst));
}
catch
{
}
Curfile++;
if (value == 99)
value = 100;
progressBar.Value = value;
progressBar.Refresh();
}
}
private void CallRecursive(TreeView treeView)
{
// Print each node recursively.
TreeNodeCollection nodes = treeView.Nodes;
foreach (TreeNode n in nodes)
{
PrintRecursive(n);
}
}
private void PrintRecursive(TreeNode treeNode)
{
// Print each node recursively.
foreach (TreeNode tn in treeNode.Nodes)
{
PrintRecursive(tn);
}
}
public void PreviewWindow(object sender, EventArgs args)
{
PreviewFormatList previewFormatList = new PreviewFormatList();
if (previewFormatList.ShowDialog() == DialogResult.OK)
{
CallRecursive(TreeView);
Console.WriteLine("Loaded files");
Console.WriteLine(PluginRuntime.bntxContainers.Count);
PreviewEditor previewWindow = new PreviewEditor();
previewWindow.Show();
}
}
public bool Compressed;
public class FolderEntry : TreeNode
{
public FolderEntry()
{
ImageKey = "folder";
SelectedImageKey = "folder";
}
public FolderEntry(string Name)
{
Text = Name;
}
}
public class FileEntry : TreeNodeCustom
{
public FileEntry()
{
ImageKey = "fileBlank";
SelectedImageKey = "fileBlank";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public string FullName;
public IFileFormat FileHandle; //Load file instance to save later if possible
public byte[] data;
public ushort unk1;
public ushort unk2;
public bool IsCompressed;
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = Path.GetExtension(Text);
sfd.Filter = "All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
File.WriteAllBytes(sfd.FileName, GetASSTData(this));
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.FileName = Text;
ofd.DefaultExt = Path.GetExtension(Text);
ofd.Filter = "All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
SetASST(this, File.ReadAllBytes(ofd.FileName));
}
}
public override void OnDoubleMouseClick(TreeView treeview)
{
if (GetASSTData(this) != null)
{
TreeNode node = STFileLoader.GetNodeFileFormat(FullName, GetASSTData(this), true, "", this, IsCompressed, CompressionType.Zstb);
if (node != null)
ReplaceNode(this.Parent, this, node);
}
}
}
public static void ReplaceNode(TreeNode node, TreeNode replaceNode, TreeNode NewNode)
{
int index = node.Nodes.IndexOf(replaceNode);
node.Nodes.RemoveAt(index);
node.Nodes.Insert(index, NewNode);
}
public static byte[] GetASSTData(FileEntry entry)
{
if (entry.IsCompressed)
return STLibraryCompression.ZSTD.Decompress(entry.data);
else
return entry.data;
}
public static void SetASST(FileEntry fileEntry, byte[] data)
{
if (fileEntry.IsCompressed)
fileEntry.data = STLibraryCompression.ZSTD.Compress(data);
else
fileEntry.data = data;
}
void FillTreeNodes(TreeNode root, Dictionary<string, ASST> files)
{
var rootText = root.Text;
var rootTextLength = rootText.Length;
var nodeStrings = files;
foreach (var node in nodeStrings)
{
string nodeString = node.Key;
var roots = nodeString.Split(new char[] { '/' },
StringSplitOptions.RemoveEmptyEntries);
// The initial parent is the root node
TreeNode parentNode = root;
var sb = new StringBuilder(rootText, nodeString.Length + rootTextLength);
for (int rootIndex = 0; rootIndex < roots.Length; rootIndex++)
{
// Build the node name
var parentName = roots[rootIndex];
sb.Append("/");
sb.Append(parentName);
var nodeName = sb.ToString();
// Search for the node
var index = parentNode.Nodes.IndexOfKey(nodeName);
if (index == -1)
{
// Node was not found, add it
var temp = new TreeNode(parentName, 0, 0);
if (rootIndex == roots.Length - 1)
temp = SetupFileEntry(node.Value,parentName, node.Value.FileName, node.Value.IsCompressed);
else
temp = SetupFolderEntry(temp);
temp.Name = nodeName;
parentNode.Nodes.Add(temp);
parentNode = temp;
}
else
{
// Node was found, set that as parent and continue
parentNode = parentNode.Nodes[index];
}
}
}
}
public FolderEntry SetupFolderEntry(TreeNode node)
{
FolderEntry folder = new FolderEntry();
folder.Text = node.Text;
return folder;
}
List<string> BuildFinalList(List<string> paths)
{
var finalList = new List<string>();
foreach (var path in paths)
{
bool found = false;
foreach (var item in finalList)
{
if (item.StartsWith(path, StringComparison.Ordinal))
{
found = true;
break;
}
}
if (!found)
{
finalList.Add(path);
}
}
return finalList;
}
public FileEntry SetupFileEntry(ASST asset,string name, string fullName, bool IsCompressed)
{
FileEntry fileEntry = new FileEntry();
fileEntry.FullName = fullName;
fileEntry.Name = name;
fileEntry.Text = name;
fileEntry.unk1 = asset.unk;
fileEntry.unk2 = asset.unk2;
fileEntry.IsCompressed = IsCompressed;
fileEntry.data = asset.FileData;
//Now check magic
//Todo clean this part up
byte[] data = asset.FileData;
if (IsCompressed)
{
try
{
data = STLibraryCompression.ZSTD.Decompress(asset.FileData);
}
catch
{
Console.WriteLine("Unkwon compression for file " + fileEntry.Name);
}
}
string ext = Path.GetExtension(name);
string SarcEx = SARCExt.SARC.GuessFileExtension(data);
if (name.EndsWith("bfres") || name.EndsWith("fmdb") || name.EndsWith("fskb") ||
name.EndsWith("ftsb") || name.EndsWith("fvmb") || name.EndsWith("fvbb") ||
name.EndsWith("fspb") || name.EndsWith("fsnb"))
{
fileEntry.ImageKey = "bfres";
fileEntry.SelectedImageKey = "bfres";
}
if (SarcEx == ".bntx")
{
fileEntry.ImageKey = "bntx";
fileEntry.SelectedImageKey = "bntx";
}
if (SarcEx == ".byaml")
{
fileEntry.ImageKey = "byaml";
fileEntry.SelectedImageKey = "byaml";
}
if (SarcEx == ".aamp")
{
fileEntry.ImageKey = "aamp";
fileEntry.SelectedImageKey = "aamp";
}
if (ext == ".lua")
{
}
data = null;
return fileEntry;
}
}
}

View File

@ -1,212 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using System.IO;
using Switch_Toolbox.Library.IO;
namespace FirstPlugin
{
public class BFFNT : TreeNode, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "Cafe Font" };
public string[] Extension { get; set; } = new string[] { "*.bffnt" };
public string Magic { get; set; } = "FFNT";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
FFNT bffnt = new FFNT();
bffnt.Read(new FileReader(new MemoryStream(Data)));
TGLP tglp = bffnt.finf.tglp;
int i = 0;
foreach (byte[] texture in tglp.SheetDataList)
{
SheetEntry sheet = new SheetEntry();
sheet.data = texture;
sheet.Text = "Sheet" + i++;
}
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
public class SheetEntry : TreeNodeCustom
{
public SheetEntry()
{
ImageKey = "fileBlank";
SelectedImageKey = "fileBlank";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
}
public byte[] data;
public override void OnClick(TreeView treeview)
{
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = "bntx";
sfd.Filter = "Supported Formats|*.bntx;|" +
"All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
File.WriteAllBytes(sfd.FileName, data);
}
}
}
}
public class FFNT
{
public ushort BOM;
public uint Version;
public FINF finf;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "FFNT")
throw new Exception($"Invalid signature {Signature}! Expected FFNT.");
char[] Magic = reader.ReadChars(4);
BOM = reader.ReadUInt16();
Version = reader.ReadUInt32();
uint FileSize = reader.ReadUInt16();
uint BlockCount = reader.ReadUInt16();
uint unk = reader.ReadUInt16();
finf = new FINF();
finf.Read(reader);
}
}
public class FINF
{
public uint Size;
public uint Type;
public uint Width;
public uint Height;
public uint Ascend;
public uint LineFeed;
public uint AlterCharIndex;
public uint DefaultLeftWidth;
public uint DefaultGlyphWidth;
public uint DefaultCharWidth;
public uint CharEncoding;
public TGLP tglp;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "FINF")
throw new Exception($"Invalid signature {Signature}! Expected FINF.");
Size = reader.ReadUInt32();
Type = reader.ReadByte();
Height = reader.ReadByte();
Width = reader.ReadByte();
Ascend = reader.ReadByte();
LineFeed = reader.ReadUInt16();
AlterCharIndex = reader.ReadUInt16();
DefaultLeftWidth = reader.ReadByte();
DefaultGlyphWidth = reader.ReadByte();
DefaultCharWidth = reader.ReadByte();
CharEncoding = reader.ReadByte();
uint tglpOffset = reader.ReadUInt32();
uint cwdhOffset = reader.ReadUInt32();
uint cmapOffset = reader.ReadUInt32();
tglp = new TGLP();
using (reader.TemporarySeek(tglpOffset - 8, SeekOrigin.Begin))
{
tglp.Read(reader);
}
}
}
public class TGLP
{
public uint Size;
public uint CellWidth;
public uint CellHeight;
public uint MaxCharWidth;
public uint SheetSize;
public uint BaseLinePos;
public uint Format;
public uint ColumnCount;
public uint RowCount;
public uint SheetWidth;
public uint SheetHeight;
public List<byte[]> SheetDataList = new List<byte[]>();
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "TGLP")
throw new Exception($"Invalid signature {Signature}! Expected TGLP.");
Size = reader.ReadUInt32();
CellWidth = reader.ReadByte();
CellHeight = reader.ReadByte();
byte SheetCount = reader.ReadByte();
MaxCharWidth = reader.ReadByte();
SheetSize = reader.ReadUInt32();
BaseLinePos = reader.ReadUInt16();
Format = reader.ReadUInt16();
ColumnCount = reader.ReadUInt16();
RowCount = reader.ReadUInt16();
SheetWidth = reader.ReadUInt16();
SheetHeight = reader.ReadUInt16();
uint sheetOffset = reader.ReadUInt32();
using (reader.TemporarySeek(sheetOffset, SeekOrigin.Begin))
{
for (int i = 0; i < SheetCount; i++)
{
}
SheetDataList.Add(reader.ReadBytes((int)SheetSize * SheetCount));
}
}
}
}

View File

@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
namespace FirstPlugin
{
public class BFLAN : IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "Cafe Layout Animation (GUI)" };
public string[] Extension { get; set; } = new string[] { "*.bflan" };
public string Magic { get; set; } = "FLAN";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
}
}

View File

@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
namespace FirstPlugin
{
public class BFLYT : IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "Cafe Layout (GUI)" };
public string[] Extension { get; set; } = new string[] { "*.bflyt" };
public string Magic { get; set; } = "FLYT";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
}
}

View File

@ -1,658 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Forms;
using Switch_Toolbox.Library.IO;
using Bfres.Structs;
using ResU = Syroot.NintenTools.Bfres;
using Syroot.NintenTools.NSW.Bfres;
namespace FirstPlugin
{
public class BFRES : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "BFRES", "*BFRES", "*BFRES" };
public string[] Extension { get; set; } = new string[] { "*.bfres", "*.sbfres" };
public string Magic { get; set; } = "FRES";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public bool IsWiiU
{
get
{
if (Data == null)
return false;
using (FileReader reader = new FileReader(new MemoryStream(Data)))
{
reader.Seek(4);
if (reader.ReadInt32() != 0x20202020)
{
return true;
}
else
return false;
}
}
}
public BFRESRender BFRESRender;
public void Load()
{
IsActive = true;
CanSave = true;
ImageKey = "bfres";
SelectedImageKey = "bfres";
ContextMenu = new ContextMenu();
MenuItem save = new MenuItem("Save");
ContextMenu.MenuItems.Add(save);
save.Click += Save;
MenuItem newMenu = new MenuItem("New");
MenuItem import = new MenuItem("Import");
// ContextMenu.MenuItems.Add(newMenu);
// ContextMenu.MenuItems.Add(import);
MenuItem rename = new MenuItem("Rename");
ContextMenu.MenuItems.Add(rename);
rename.Click += Rename;
MenuItem remove = new MenuItem("Remove");
ContextMenu.MenuItems.Add(remove);
remove.Click += Remove;
if (Parent == null)
remove.Enabled = false;
if (IsWiiU)
{
}
else
{
MenuItem model = new MenuItem("Model");
MenuItem fska = new MenuItem("Skeletal Animation");
MenuItem fmaa = new MenuItem("Material Animation");
MenuItem bonevis = new MenuItem("Bone Visual Animation");
MenuItem shape = new MenuItem("Shape Animation");
MenuItem scene = new MenuItem("Scene Animation");
MenuItem embedded = new MenuItem("Embedded File");
MenuItem texture = new MenuItem("Texture File");
texture.Click += NewTextureFile;
newMenu.MenuItems.Add(model);
newMenu.MenuItems.Add(fska);
newMenu.MenuItems.Add(fmaa);
newMenu.MenuItems.Add(bonevis);
newMenu.MenuItems.Add(shape);
newMenu.MenuItems.Add(scene);
newMenu.MenuItems.Add(embedded);
newMenu.MenuItems.Add(texture);
MenuItem importmodel = new MenuItem("Model");
MenuItem importfska = new MenuItem("Skeletal Animation");
MenuItem importfmaa = new MenuItem("Material Animation");
MenuItem importbonevis = new MenuItem("Bone Visual Animation");
MenuItem importshape = new MenuItem("Shape Animation");
MenuItem importscene = new MenuItem("Scene Animation");
MenuItem importembedded = new MenuItem("Embedded File");
MenuItem importtexture = new MenuItem("Texture File");
import.MenuItems.Add(importmodel);
import.MenuItems.Add(importfska);
import.MenuItems.Add(importfmaa);
import.MenuItems.Add(importbonevis);
import.MenuItems.Add(importshape);
import.MenuItems.Add(importscene);
import.MenuItems.Add(importembedded);
import.MenuItems.Add(importtexture);
}
BFRESRender = new BFRESRender();
BFRESRender.ResFileNode = this;
if (IsWiiU)
{
BFRESRender.LoadFile(new Syroot.NintenTools.Bfres.ResFile(new System.IO.MemoryStream(Data)));
}
else
{
BFRESRender.LoadFile(new Syroot.NintenTools.NSW.Bfres.ResFile(new System.IO.MemoryStream(Data)));
}
Runtime.abstractGlDrawables.Add(BFRESRender);
}
public void Unload()
{
BFRESRender.Destroy();
BFRESRender.ResFileNode.Nodes.Clear();
}
public byte[] Save()
{
MemoryStream mem = new MemoryStream();
if (IsWiiU)
SaveWiiU(mem);
else
SaveSwitch(mem);
return mem.ToArray();
}
public ResFile resFile = null;
public ResU.ResFile resFileU = null;
public TreeNode TextureFolder = new TreeNode("Textures");
public override void OnClick(TreeView treeView)
{
if (Viewport.Instance.gL_ControlModern1 == null)
return;
//If has models
if (Nodes.ContainsKey("FMDL"))
{
LibraryGUI.Instance.LoadViewport(Viewport.Instance);
Viewport.Instance.gL_ControlModern1.MainDrawable = BFRESRender;
BFRESRender.UpdateVertexData();
}
}
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 Load(ResFile res)
{
resFile = res;
Text = resFile.Name;
UpdateTree(resFile);
foreach (ShapeAnim anim in resFile.ShapeAnims)
Nodes["FSHPA"].Nodes.Add(anim.Name);
foreach (VisibilityAnim anim in resFile.BoneVisibilityAnims)
Nodes["FBNV"].Nodes.Add(anim.Name);
int ext = 0;
foreach (ExternalFile extfile in resFile.ExternalFiles)
{
string Name = resFile.ExternalFileDict.GetKey(ext);
FileReader f = new FileReader(extfile.Data);
string Magic = f.ReadMagic(0, 4);
if (Magic == "BNTX")
{
BNTX bntx = new BNTX();
bntx.Data = extfile.Data;
bntx.FileName = Name;
bntx.Load();
bntx.IFileInfo.InArchive = true;
Nodes["EXT"].Nodes.Add(bntx);
}
else if (Magic == "FSHA")
{
Nodes["EXT"].Nodes.Add(new BfshaFileData(extfile.Data, Name));
}
else
Nodes["EXT"].Nodes.Add(new ExternalFileData(extfile.Data, Name));
f.Dispose();
f.Close();
ext++;
}
}
private void NewTextureFile(object sender, EventArgs args)
{
string Name = "textures";
for (int i = 0; i < resFile.ExternalFiles.Count; i++)
{
if (resFile.ExternalFileDict.GetKey(i) == Name)
Name = Name + i;
}
if (!Nodes.ContainsKey("EXT"))
{
Nodes.Add(new EmbeddedFilesFolder());
}
BNTX bntx = new BNTX();
bntx.Data = new byte[0];
bntx.FileName = "textures";
Nodes["EXT"].Nodes.Add(bntx);
}
private void NewEmbeddedFile(object sender, EventArgs args)
{
}
private void Save(object sender, EventArgs args)
{
List<IFileFormat> formats = new List<IFileFormat>();
formats.Add(this);
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(formats);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName, Alignment);
}
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
Text = dialog.textBox1.Text;
}
}
private void Remove(object sender, EventArgs args)
{
BFRESRender.DisposeFile();
}
private void UpdateTree(ResFile resFile)
{
if (resFile.Models.Count > 0)
Nodes.Add(new FmdlFolder());
if (resFile.SkeletalAnims.Count > 0)
AddSkeletonAnims(resFile);
if (resFile.MaterialAnims.Count > 0)
AddMaterialAnims(resFile);
if (resFile.ShapeAnims.Count > 0)
AddShapeAnims(resFile);
if (resFile.BoneVisibilityAnims.Count > 0)
AddBoneVisAnims(resFile);
if (resFile.SceneAnims.Count > 0)
AddSceneAnims(resFile);
if (resFile.ExternalFiles.Count > 0)
Nodes.Add(new EmbeddedFilesFolder());
}
private void AddFTEXTextures(ResU.ResFile resFile)
{
FTEXContainer ftexContainer = new FTEXContainer();
Nodes.Add(ftexContainer);
foreach (ResU.Texture tex in resFile.Textures.Values)
{
string TextureName = tex.Name;
FTEX texture = new FTEX();
ftexContainer.Nodes.Add(texture);
texture.Read(tex);
ftexContainer.Textures.Add(texture.Text, texture);
}
PluginRuntime.ftexContainers.Add(ftexContainer);
}
private void AddSkeletonAnims(ResU.ResFile resFile)
{
FskaFolder fksaFolder = new FskaFolder();
Nodes.Add(fksaFolder);
foreach (ResU.SkeletalAnim ska in resFile.SkeletalAnims.Values)
{
FSKA skeletonAnim = new FSKA(ska.Name);
skeletonAnim.Read(ska);
fksaFolder.Nodes.Add(skeletonAnim);
}
}
private void AddSkeletonAnims(ResFile resFile)
{
FskaFolder fksaFolder = new FskaFolder();
Nodes.Add(fksaFolder);
foreach (SkeletalAnim ska in resFile.SkeletalAnims)
{
FSKA skeletonAnim = new FSKA(ska.Name);
skeletonAnim.Read(ska);
fksaFolder.Nodes.Add(skeletonAnim);
}
}
private void AddSceneAnims(ResU.ResFile resFile)
{
FscnFolder FSCN = new FscnFolder();
Nodes.Add(FSCN);
}
private void AddSceneAnims(ResFile resFile)
{
FscnFolder fscnFolder = new FscnFolder();
Nodes.Add(fscnFolder);
foreach (var scn in resFile.SceneAnims)
{
FSCN sceneAnim = new FSCN();
sceneAnim.Text = scn.Name;
sceneAnim.Read(scn);
fscnFolder.Nodes.Add(sceneAnim);
}
}
private void AddMaterialAnims(ResFile resFile)
{
FmaaFolder fmaaFolder = new FmaaFolder();
Nodes.Add(fmaaFolder);
foreach (var fmaa in resFile.MaterialAnims)
{
FMAA materialAnim = new FMAA();
materialAnim.Text = fmaa.Name;
materialAnim.BFRESRender = BFRESRender;
materialAnim.Read(fmaa);
fmaaFolder.Nodes.Add(materialAnim);
}
}
private void AddShapeAnims(ResFile resFile)
{
FshpaFolder fshaFolder = new FshpaFolder();
Nodes.Add(fshaFolder);
foreach (var fsha in resFile.ShapeAnims)
{
FSHA shapeAnim = new FSHA();
shapeAnim.Text = fsha.Name;
shapeAnim.Read(fsha);
fshaFolder.Nodes.Add(shapeAnim);
}
}
private void AddBoneVisAnims(ResFile resFile)
{
FbnvFolder fbnvFolder = new FbnvFolder();
Nodes.Add(fbnvFolder);
foreach (var fbnv in resFile.BoneVisibilityAnims)
{
FBNV boneVis = new FBNV();
boneVis.Text = fbnv.Name;
boneVis.Read(fbnv);
fbnvFolder.Nodes.Add(boneVis);
}
}
private void SaveSwitch(MemoryStream mem)
{
var resFile = BFRESRender.ResFileNode.resFile;
resFile.Models.Clear();
resFile.SkeletalAnims.Clear();
resFile.MaterialAnims.Clear();
resFile.SceneAnims.Clear();
resFile.ShapeAnims.Clear();
resFile.BoneVisibilityAnims.Clear();
resFile.ModelDict.Clear();
resFile.SkeletalAnimDict.Clear();
resFile.MaterialAnimDict.Clear();
resFile.SceneAnimDict.Clear();
resFile.ShapeAnimDict.Clear();
resFile.BoneVisibilityAnimDict.Clear();
int CurMdl = 0;
if (Nodes.ContainsKey("FMDL"))
{
foreach (FMDL model in Nodes["FMDL"].Nodes)
resFile.Models.Add(BfresSwitch.SetModel(model));
}
if (Nodes.ContainsKey("FSKA"))
{
foreach (FSKA ska in Nodes["FSKA"].Nodes)
resFile.SkeletalAnims.Add(ska.SkeletalAnim);
}
if (Nodes.ContainsKey("FMAA"))
{
foreach (FMAA fmaa in Nodes["FMAA"].Nodes)
resFile.MaterialAnims.Add(fmaa.MaterialAnim);
}
if (Nodes.ContainsKey("FBNV"))
{
foreach (FBNV fbnv in Nodes["FBNV"].Nodes)
resFile.BoneVisibilityAnims.Add(fbnv.VisibilityAnim);
}
if (Nodes.ContainsKey("FSHPA"))
{
foreach (FSHA fsha in Nodes["FSHPA"].Nodes)
resFile.ShapeAnims.Add(fsha.ShapeAnim);
}
if (Nodes.ContainsKey("FSCN"))
{
foreach (FSCN fscn in Nodes["FSCN"].Nodes)
resFile.SceneAnims.Add(fscn.SceneAnim);
}
ErrorCheck();
BfresSwitch.WriteExternalFiles(resFile, this);
resFile.Save(mem);
}
private void SaveWiiU(MemoryStream mem)
{
var resFileU = BFRESRender.ResFileNode.resFileU;
resFileU.Models.Clear();
resFileU.SkeletalAnims.Clear();
// resFileU.SceneAnims.Clear();
// resFileU.ShapeAnims.Clear();
// resFileU.BoneVisibilityAnims.Clear();
resFileU.Textures.Clear();
int CurMdl = 0;
if (Nodes.ContainsKey("FMDL"))
{
foreach (FMDL model in Nodes["FMDL"].Nodes)
resFileU.Models.Add(model.Text, BfresWiiU.SetModel(model));
}
if (Nodes.ContainsKey("FTEX"))
{
foreach (FTEX tex in Nodes["FTEX"].Nodes)
{
tex.texture.Name = tex.Text;
resFileU.Textures.Add(tex.Text, tex.texture);
}
}
if (Nodes.ContainsKey("FSKA"))
{
foreach (FSKA ska in Nodes["FSKA"].Nodes)
{
ska.SkeletalAnimU.Name = ska.Text;
resFileU.SkeletalAnims.Add(ska.Text, ska.SkeletalAnimU);
}
}
else
throw new Exception("Failed to find textures");
ErrorCheck();
resFileU.Save(mem);
}
public static void SetShaderAssignAttributes(FMAT.ShaderAssign shd, FSHP shape)
{
foreach (var att in shape.vertexAttributes)
{
if (!shd.attributes.ContainsValue(att.Name) && !shd.attributes.ContainsKey(att.Name))
shd.attributes.Add(att.Name, att.Name);
}
foreach (var tex in shape.GetMaterial().TextureMaps)
{
if (!shd.samplers.ContainsValue(((MatTexture)tex).SamplerName))
shd.samplers.Add(((MatTexture)tex).SamplerName, ((MatTexture)tex).SamplerName);
}
}
private void SetDuplicateShapeName(FSHP shape)
{
DialogResult dialogResult = MessageBox.Show($"A shape {shape.Text} already exists with that name", "", MessageBoxButtons.OK);
if (dialogResult == DialogResult.OK)
{
RenameDialog renameDialog = new RenameDialog();
renameDialog.Text = "Rename Texture";
if (renameDialog.ShowDialog() == DialogResult.OK)
{
shape.Text = renameDialog.textBox1.Text;
}
}
}
public static void CheckMissingTextures(FSHP shape)
{
bool ImportMissingTextures = false;
foreach (BNTX bntx in PluginRuntime.bntxContainers)
{
foreach (MatTexture tex in shape.GetMaterial().TextureMaps)
{
if (!bntx.Textures.ContainsKey(tex.Name))
{
if (!ImportMissingTextures)
{
DialogResult result = MessageBox.Show("Missing textures found! Would you like to use placeholders?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
ImportMissingTextures = true;
}
else
{
return;
}
}
if (ImportMissingTextures)
bntx.ImportPlaceholderTexture(tex.Name);
}
}
}
}
public void ErrorCheck()
{
if (BFRESRender != null)
{
List<Errors> Errors = new List<Errors>();
foreach (FMDL model in BFRESRender.models)
{
foreach (FSHP shp in model.shapes)
{
if (!IsWiiU)
{
Syroot.NintenTools.NSW.Bfres.VertexBuffer vtx = shp.VertexBuffer;
Syroot.NintenTools.NSW.Bfres.Material mat = shp.GetMaterial().Material;
Syroot.NintenTools.NSW.Bfres.ShaderAssign shdr = mat.ShaderAssign;
for (int att = 0; att < vtx.Attributes.Count; att++)
{
if (!shdr.AttribAssigns.Contains(vtx.Attributes[att].Name))
MessageBox.Show($"Error! Attribute {vtx.Attributes[att].Name} is unlinked!");
}
for (int att = 0; att < mat.TextureRefs.Count; att++)
{
if (!shdr.SamplerAssigns.Contains(mat.SamplerDict.GetKey(att))) //mat.SamplerDict[att]
MessageBox.Show($"Error! Sampler {mat.SamplerDict.GetKey(att)} is unlinked!");
}
}
else
{
Syroot.NintenTools.Bfres.VertexBuffer vtx = shp.VertexBufferU;
Syroot.NintenTools.Bfres.Material mat = shp.GetMaterial().MaterialU;
Syroot.NintenTools.Bfres.ShaderAssign shdr = mat.ShaderAssign;
for (int att = 0; att < vtx.Attributes.Count; att++)
{
if (!shdr.AttribAssigns.ContainsKey(vtx.Attributes[att].Name))
MessageBox.Show($"Error! Attribute {vtx.Attributes[att].Name} is unlinked!");
}
for (int att = 0; att < mat.TextureRefs.Count; att++)
{
string samp = "";
mat.Samplers.TryGetKey(mat.Samplers[att], out samp);
if (!shdr.SamplerAssigns.ContainsKey(samp)) //mat.SamplerDict[att]
MessageBox.Show($"Error! Sampler {samp} is unlinked!");
}
}
}
}
// ErrorList errorList = new ErrorList();
// errorList.LoadList(Errors);
// errorList.Show();
}
}
public class Errors
{
public string Section = "None";
public string Section2 = "None";
public string Message = "";
public string Type = "Unkown";
}
}
}

View File

@ -1,51 +0,0 @@
using System;
using System.Windows.Forms;
namespace Bfres.Structs
{
public class BfshaFileData : TreeNode
{
public byte[] Data;
public BfshaFileData(byte[] data, string Name)
{
Text = Name;
ImageKey = "bfsha";
SelectedImageKey = "bfsha";
Data = data;
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Import;
}
private void Import(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
Data = System.IO.File.ReadAllBytes(ofd.FileName);
}
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "All files(*.*)|*.*";
sfd.DefaultExt = System.IO.Path.GetExtension(Text);
sfd.FileName = Text;
if (sfd.ShowDialog() == DialogResult.OK)
{
System.IO.File.WriteAllBytes(sfd.FileName, Data);
}
}
}
}

View File

@ -1,102 +0,0 @@
using System;
using Switch_Toolbox.Library;
using System.Windows.Forms;
using FirstPlugin;
namespace Bfres.Structs
{
public class EmbeddedFilesFolder : TreeNodeCustom
{
public EmbeddedFilesFolder()
{
Text = "Embedded Files";
Name = "EXT";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Import");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
public void Import(object sender, EventArgs args)
{
}
public void ExportAll(object sender, EventArgs args)
{
}
private void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all external files? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
foreach (var ext in Nodes)
{
if (ext is BNTX)
{
PluginRuntime.bntxContainers.Remove((BNTX)ext);
}
}
Nodes.Clear();
Viewport.Instance.Refresh();
}
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class ExternalFileData : TreeNode
{
public byte[] Data;
public ExternalFileData(byte[] data, string Name)
{
Text = Name;
ImageKey = "folder";
Data = data;
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Import;
}
private void Import(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
Data = System.IO.File.ReadAllBytes(ofd.FileName);
}
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "All files(*.*)|*.*";
sfd.DefaultExt = System.IO.Path.GetExtension(Text);
sfd.FileName = Text;
if (sfd.ShowDialog() == DialogResult.OK)
{
System.IO.File.WriteAllBytes(sfd.FileName, Data);
}
}
}
}

View File

@ -1,109 +0,0 @@
using System;
using Switch_Toolbox.Library;
using System.Windows.Forms;
using FirstPlugin;
using Syroot.NintenTools.NSW.Bfres;
namespace Bfres.Structs
{
public class FbnvFolder : TreeNodeCustom
{
public FbnvFolder()
{
Text = "Bone Visabilty Animations";
Name = "FBNV";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Import");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
public void Import(object sender, EventArgs args)
{
}
public void ExportAll(object sender, EventArgs args)
{
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
foreach (FBNV fbnv in Nodes)
{
string FileName = folderPath + '\\' + fbnv.Text + ".bfska";
((FBNV)fbnv).VisibilityAnim.Export(FileName, fbnv.GetResFile());
}
}
}
public void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all visibility animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Nodes.Clear();
}
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class FBNV : TreeNodeCustom
{
public VisibilityAnim VisibilityAnim;
public FBNV()
{
ImageKey = "visibilityAnim";
SelectedImageKey = "visibilityAnim";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public ResFile GetResFile()
{
return ((BFRES)Parent.Parent).resFile;
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfvis;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfvis";
if (sfd.ShowDialog() == DialogResult.OK)
{
VisibilityAnim.Export(sfd.FileName, GetResFile());
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfvis;";
if (ofd.ShowDialog() == DialogResult.OK)
{
VisibilityAnim.Import(ofd.FileName);
}
VisibilityAnim.Name = Text;
}
public void Read(VisibilityAnim vis)
{
VisibilityAnim = vis;
}
}
}

View File

@ -1,108 +0,0 @@
using System;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using FirstPlugin;
using Syroot.NintenTools.NSW.Bfres;
namespace Bfres.Structs
{
public class FmaaFolder : TreeNodeCustom
{
public FmaaFolder()
{
Text = "Material Animations";
Name = "FMAA";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Import");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
public void Import(object sender, EventArgs args)
{
}
public void ExportAll(object sender, EventArgs args)
{
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
foreach (FMAA fmaa in Nodes)
{
string FileName = folderPath + '\\' + fmaa.Text + ".bfmaa";
((FMAA)fmaa).MaterialAnim.Export(FileName, fmaa.GetResFile());
}
}
}
private void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all material animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Nodes.Clear();
}
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class FMAA : TreeNodeCustom
{
public BFRESRender BFRESRender;
public MaterialAnim MaterialAnim;
public FMAA()
{
ImageKey = "materialAnim";
SelectedImageKey = "materialAnim";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public ResFile GetResFile()
{
return ((BFRES)Parent.Parent).resFile;
}
public void Read(MaterialAnim anim)
{
MaterialAnim = anim;
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfmaa;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfska";
if (sfd.ShowDialog() == DialogResult.OK)
{
MaterialAnim.Export(sfd.FileName, GetResFile());
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfmaa;";
if (ofd.ShowDialog() == DialogResult.OK)
{
MaterialAnim.Import(ofd.FileName);
}
MaterialAnim.Name = Text;
}
}
}

View File

@ -1,442 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Syroot.NintenTools.NSW.Bfres;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Rendering;
using Switch_Toolbox.Library.Forms;
using ResU = Syroot.NintenTools.Bfres;
using FirstPlugin;
using OpenTK;
namespace Bfres.Structs
{
public class FMATFolder : TreeNodeCustom
{
public FMATFolder()
{
Text = "Materials";
Name = "FmatFolder";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Add Material");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
}
public void Import(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Bfres Material |*.bfmat;";
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
foreach (string file in ofd.FileNames)
((FMDL)Parent).AddMaterials(file, false);
}
}
public override void OnClick(TreeView treeView)
{
}
}
public class FMAT : STGenericMaterial
{
public FMAT()
{
Checked = true;
ImageKey = "material";
SelectedImageKey = "material";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
MenuItem copy = new MenuItem("Copy");
ContextMenu.MenuItems.Add(copy);
copy.Click += Copy;
MenuItem rename = new MenuItem("Rename");
ContextMenu.MenuItems.Add(rename);
rename.Click += Rename;
}
public bool Enabled = true;
public override void OnClick(TreeView treeView)
{
UpdateFMATEditor();
}
public void UpdateFMATEditor()
{
FMATEditor docked = (FMATEditor)LibraryGUI.Instance.GetContentDocked(new FMATEditor());
if (docked == null)
{
docked = new FMATEditor();
LibraryGUI.Instance.LoadDockContent(docked, PluginRuntime.FSHPDockState);
}
docked.Text = Text;
docked.Dock = DockStyle.Fill;
docked.LoadMaterial(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()
{
((BFRES)Parent.Parent.Parent.Parent).BFRESRender.UpdateSingleMaterialTextureMaps(this);
}
public void SetActiveGame()
{
Runtime.activeGame = Runtime.ActiveGame.SMO;
return;
string ShaderName = shaderassign.ShaderArchive;
string ShaderModel = shaderassign.ShaderModel;
if (ShaderName == "alRenderMaterial" || ShaderName == "alRenderCloudLayer" || ShaderName == "alRenderSky")
Runtime.activeGame = Runtime.ActiveGame.SMO;
else if (ShaderName == "Turbo_UBER")
Runtime.activeGame = Runtime.ActiveGame.MK8D;
else if (ShaderName.Contains("uking_mat"))
Runtime.activeGame = Runtime.ActiveGame.BOTW;
else if (ShaderName.Contains("Blitz_UBER"))
Runtime.activeGame = Runtime.ActiveGame.Splatoon2;
else
Runtime.activeGame = Runtime.ActiveGame.KSA;
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
((FMDL)Parent.Parent).materials.Remove(Text);
Text = dialog.textBox1.Text;
((FMDL)Parent.Parent).materials.Add(Text, this);
}
}
private void Copy(object sender, EventArgs args)
{
((FMDL)Parent.Parent).CopyMaterial(this);
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfmat;";
sfd.DefaultExt = ".bfmat";
sfd.FileName = Text;
if (sfd.ShowDialog() == DialogResult.OK)
{
if (GetResFileU() != null)
MaterialU.Export(sfd.FileName, GetResFileU());
else
Material.Export(sfd.FileName, GetResFile());
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfmat;";
if (ofd.ShowDialog() == DialogResult.OK)
{
if (GetResFileU() != null)
{
MaterialU.Import(ofd.FileName, GetResFileU());
MaterialU.Name = Text;
BfresWiiU.ReadMaterial(this, MaterialU);
}
else
{
Material.Import(ofd.FileName);
Material.Name = Text;
BfresSwitch.ReadMaterial(this, Material);
}
}
}
public Dictionary<string, float[]> anims = new Dictionary<string, float[]>();
public Dictionary<string, int> Samplers = new Dictionary<string, int>();
public List<BfresRenderInfo> renderinfo = new List<BfresRenderInfo>();
public List<SamplerInfo> samplerinfo = new List<SamplerInfo>();
public Dictionary<string, BfresShaderParam> matparam = new Dictionary<string, BfresShaderParam>();
public Material Material;
public ResU.Material MaterialU;
public ShaderAssign shaderassign = new ShaderAssign();
public class ShaderAssign
{
public string ShaderModel = "";
public string ShaderArchive = "";
public Dictionary<string, string> options = new Dictionary<string, string>();
public Dictionary<string, string> samplers = new Dictionary<string, string>();
public Dictionary<string, string> attributes = new Dictionary<string, string>();
}
public class SamplerInfo
{
public int WrapModeU;
public int WrapModeV;
public int WrapModeW;
}
public bool HasDiffuseMap = false;
public bool HasNormalMap = false;
public bool HasSpecularMap = false;
public bool HasEmissionMap = false;
public bool HasDiffuseLayer = false;
public bool HasTeamColorMap = false; //Splatoon uses this (TLC)
public bool HasTransparencyMap = false;
public bool HasShadowMap = false;
public bool HasAmbientOcclusionMap = false;
public bool HasLightMap = false;
public bool HasSphereMap = false;
public bool HasSubSurfaceScatteringMap = false;
//PBR (Switch) data
public bool HasMetalnessMap = false;
public bool HasRoughnessMap = false;
public bool HasMRA = false;
}
public class BfresShaderParam
{
public ShaderParamType Type;
public string Name;
public float[] ValueFloat;
public bool[] ValueBool;
public uint[] ValueUint;
public int[] ValueInt;
public byte[] ValueReserved;
public Srt2D ValueSrt2D;
public Srt3D ValueSrt3D;
public TexSrt ValueTexSrt;
public TexSrtEx ValueTexSrtEx;
//If a data set is not defined then defaults in this to save back properly
//Note this may be rarely needed or not at all
public byte[] Value_Unk;
private void ReadSRT2D(FileReader reader)
{
ValueSrt2D = new Srt2D();
ValueSrt2D.Scaling = reader.ReadVec2SY();
ValueSrt2D.Rotation = reader.ReadSingle();
ValueSrt2D.Translation = reader.ReadVec2SY();
}
private void ReadSRT3D(FileReader reader)
{
ValueSrt3D = new Srt3D();
ValueSrt3D.Scaling = reader.ReadVec3SY();
ValueSrt3D.Rotation = reader.ReadVec3SY();
ValueSrt3D.Translation = reader.ReadVec3SY();
}
private void ReadTexSrt(FileReader reader)
{
ValueTexSrt = new TexSrt();
ValueTexSrt.Mode = reader.ReadEnum<TexSrtMode>(false);
ValueTexSrt.Scaling = reader.ReadVec2SY();
ValueTexSrt.Rotation = reader.ReadSingle();
ValueTexSrt.Translation = reader.ReadVec2SY();
}
private void ReadTexSrtEx(FileReader reader)
{
ValueTexSrtEx = new TexSrtEx();
ValueTexSrtEx.Mode = reader.ReadEnum<TexSrtMode>(true);
ValueTexSrtEx.Scaling = reader.ReadVec2SY();
ValueTexSrtEx.Rotation = reader.ReadSingle();
ValueTexSrtEx.Translation = reader.ReadVec2SY();
ValueTexSrtEx.MatrixPointer = reader.ReadUInt32();
}
public ShaderParamType GetTypeWiiU(ResU.ShaderParamType type)
{
return (ShaderParamType)System.Enum.Parse(typeof(ShaderParamType), type.ToString());
}
public ResU.ShaderParamType SetTypeWiiU(ShaderParamType type)
{
return (ResU.ShaderParamType)System.Enum.Parse(typeof(ResU.ShaderParamType), type.ToString());
}
public void ReadValue(FileReader reader, int Size)
{
switch (Type)
{
case ShaderParamType.Bool:
case ShaderParamType.Bool2:
case ShaderParamType.Bool3:
case ShaderParamType.Bool4:
ValueBool = reader.ReadBooleans(Size / sizeof(bool)); break;
case ShaderParamType.Float:
case ShaderParamType.Float2:
case ShaderParamType.Float3:
case ShaderParamType.Float4:
case ShaderParamType.Float2x2:
case ShaderParamType.Float2x3:
case ShaderParamType.Float2x4:
case ShaderParamType.Float4x2:
case ShaderParamType.Float4x3:
case ShaderParamType.Float4x4:
ValueFloat = reader.ReadSingles(Size / sizeof(float)); break;
case ShaderParamType.Int:
case ShaderParamType.Int2:
case ShaderParamType.Int3:
case ShaderParamType.Int4:
ValueInt = reader.ReadInt32s(Size / sizeof(int)); break;
case ShaderParamType.Reserved2:
case ShaderParamType.Reserved3:
case ShaderParamType.Reserved4:
ValueReserved = reader.ReadBytes(Size / sizeof(byte)); break;
case ShaderParamType.Srt2D:
ReadSRT2D(reader); break;
case ShaderParamType.Srt3D:
ReadSRT3D(reader); break;
case ShaderParamType.TexSrt:
ReadTexSrt(reader); break;
case ShaderParamType.TexSrtEx:
ReadTexSrtEx(reader); break;
case ShaderParamType.UInt:
case ShaderParamType.UInt2:
case ShaderParamType.UInt3:
case ShaderParamType.UInt4:
ValueUint = reader.ReadUInt32s(Size / sizeof(uint)); break;
// Invalid
default:
throw new ArgumentException($"Invalid {nameof(ShaderParamType)} {Type}.",
nameof(Type));
}
}
public void WriteValue(FileWriter writer)
{
switch (Type)
{
case ShaderParamType.Bool:
case ShaderParamType.Bool2:
case ShaderParamType.Bool3:
case ShaderParamType.Bool4:
writer.Write(ValueBool); break;
case ShaderParamType.Float:
case ShaderParamType.Float2:
case ShaderParamType.Float3:
case ShaderParamType.Float4:
case ShaderParamType.Float2x2:
case ShaderParamType.Float2x3:
case ShaderParamType.Float2x4:
case ShaderParamType.Float4x2:
case ShaderParamType.Float4x3:
case ShaderParamType.Float4x4:
writer.Write(ValueFloat); break;
case ShaderParamType.Int:
case ShaderParamType.Int2:
case ShaderParamType.Int3:
case ShaderParamType.Int4:
writer.Write(ValueInt); break;
case ShaderParamType.Reserved2:
case ShaderParamType.Reserved3:
case ShaderParamType.Reserved4:
writer.Write(ValueInt); break;
case ShaderParamType.Srt2D:
WriteSRT2D(writer); break;
case ShaderParamType.Srt3D:
WriteSRT3D(writer); break;
case ShaderParamType.TexSrt:
WriteTexSrt(writer); break;
case ShaderParamType.TexSrtEx:
WriteTexSrtEx(writer); break;
case ShaderParamType.UInt:
case ShaderParamType.UInt2:
case ShaderParamType.UInt3:
case ShaderParamType.UInt4:
writer.Write(ValueUint); break;
// Invalid
default:
throw new ArgumentException($"Invalid {nameof(ShaderParamType)} {Type}.",
nameof(Type));
}
}
private void WriteSRT2D(FileWriter writer)
{
writer.Write(ValueSrt2D.Scaling);
writer.Write(ValueSrt2D.Rotation);
writer.Write(ValueSrt2D.Translation);
}
private void WriteSRT3D(FileWriter writer)
{
writer.Write(ValueSrt3D.Scaling);
writer.Write(ValueSrt3D.Rotation);
writer.Write(ValueSrt3D.Translation);
}
private void WriteTexSrt(FileWriter writer)
{
writer.Write((uint)ValueTexSrt.Mode);
writer.Write(ValueTexSrt.Scaling);
writer.Write(ValueTexSrt.Rotation);
writer.Write(ValueTexSrt.Translation);
}
private void WriteTexSrtEx(FileWriter writer)
{
writer.Write((uint)ValueTexSrtEx.Mode);
writer.Write(ValueTexSrtEx.Scaling);
writer.Write(ValueTexSrtEx.Rotation);
writer.Write(ValueTexSrtEx.Translation);
writer.Write(ValueTexSrtEx.MatrixPointer);
}
}
public class BfresRenderInfo
{
public string Name;
public long DataOffset;
public RenderInfoType Type;
public int ArrayLength;
//Data Section by "Type"
public int[] ValueInt;
public string[] ValueString;
public float[] ValueFloat;
public RenderInfoType GetTypeWiiU(ResU.RenderInfoType type)
{
return (RenderInfoType)System.Enum.Parse(typeof(RenderInfoType), type.ToString());
}
public ResU.RenderInfoType SetTypeWiiU(RenderInfoType type)
{
return (ResU.RenderInfoType)System.Enum.Parse(typeof(ResU.RenderInfoType), type.ToString());
}
}
public class MatTexture : STGenericMatTexture
{
public int hash;
public string SamplerName;
//Note samplers will get converted to another sampler type sometimes in the shader assign section
//Use this string if not empty for our bfres fragment shader to produce the accurate affects
//An example of a conversion maybe be like a1 - t0 so texture gets used as a transparent map/alpha texture
public string FragShaderSampler = "";
public MatTexture()
{
}
}
}

View File

@ -1,745 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Syroot.NintenTools.NSW.Bfres;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using Switch_Toolbox.Library.Forms;
using ResU = Syroot.NintenTools.Bfres;
using ResUGX2 = Syroot.NintenTools.Bfres.GX2;
using ResGFX = Syroot.NintenTools.NSW.Bfres.GFX;
using FirstPlugin;
namespace Bfres.Structs
{
public class FmdlFolder : TreeNodeCustom
{
public FmdlFolder()
{
Text = "Models";
Name = "FMDL";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Import");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
public void Import(object sender, EventArgs args)
{
}
public void ExportAll(object sender, EventArgs args)
{
}
private void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Nodes.Clear();
((BFRES)Parent).BFRESRender.models.Clear();
((BFRES)Parent).BFRESRender.UpdateVertexData();
}
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class FMDL : STGenericModel
{
public List<FSHP> shapes = new List<FSHP>();
public Dictionary<string, FMAT> materials = new Dictionary<string, FMAT>();
public Model Model;
public ResU.Model ModelU;
public ResFile GetResFile()
{
//ResourceFile -> FMDL -> Material Folder -> this
return ((BFRES)Parent.Parent).resFile;
}
public ResU.ResFile GetResFileU()
{
return ((BFRES)Parent.Parent).resFileU;
}
public void UpdateVertexData()
{
((BFRES)Parent.Parent).BFRESRender.UpdateVertexData();
}
public List<FMDL> GetModelList()
{
return ((BFRES)Parent.Parent).BFRESRender.models;
}
public bool IsWiiU
{
get
{
return GetResFileU() != null;
}
}
public FMDL()
{
ImageKey = "model";
SelectedImageKey = "model";
Nodes.Add(new FSHPFolder());
Nodes.Add(new FMATFolder());
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export Model");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace Model");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
MenuItem rename = new MenuItem("Rename");
ContextMenu.MenuItems.Add(rename);
rename.Click += Rename;
MenuItem calcTansBitans = new MenuItem("Calculate Tangents/Bitangents");
ContextMenu.MenuItems.Add(calcTansBitans);
calcTansBitans.Click += CalcTansBitansAllShapes;
MenuItem normals = new MenuItem("Normals");
ContextMenu.MenuItems.Add(normals);
MenuItem smoothNormals = new MenuItem("Smooth");
normals.MenuItems.Add(smoothNormals);
smoothNormals.Click += SmoothNormals;
MenuItem recalculateNormals = new MenuItem("Recalculate");
normals.MenuItems.Add(recalculateNormals);
recalculateNormals.Click += RecalculateNormals;
}
private void SmoothNormals(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
foreach (FSHP shp in shapes)
{
bool HasNormals = shp.vertexAttributes.Any(x => x.Name == "_n0");
if (HasNormals)
shp.SmoothNormals();
shp.SaveVertexBuffer(IsWiiU);
}
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
private void RecalculateNormals(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
foreach (FSHP shp in shapes)
{
bool HasNormals = shp.vertexAttributes.Any(x => x.Name == "_n0");
if (HasNormals)
shp.CalculateNormals();
shp.SaveVertexBuffer(IsWiiU);
}
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
Text = dialog.textBox1.Text;
}
}
private void CalcTansBitansAllShapes(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
foreach (FSHP shp in shapes)
{
bool HasTans = shp.vertexAttributes.Any(x => x.Name == "_t0");
bool HasBiTans = shp.vertexAttributes.Any(x => x.Name == "_b0");
if (!shp.HasUV0())
{
MessageBox.Show($"Error! {Text} does not have UVs!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!HasBiTans)
{
DialogResult dialogResult2 = MessageBox.Show("Mesh does not have bitangents. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);
FSHP.VertexAttribute att2 = new FSHP.VertexAttribute();
att2.Name = "_b0";
att2.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;
if (dialogResult2 == DialogResult.Yes)
{
if (!HasBiTans)
shp.vertexAttributes.Add(att2);
}
}
if (!HasTans)
{
DialogResult dialogResult = MessageBox.Show("Mesh does not have tangets. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_t0";
att.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;
if (dialogResult == DialogResult.Yes)
{
if (!HasTans)
shp.vertexAttributes.Add(att);
}
}
shp.CalculateTangentBitangent();
shp.SaveVertexBuffer(IsWiiU);
}
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
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 SetCopiedMaterialData(CopyMaterialMenu menu,
FMAT selectedMaterial, FMAT targetMaterial)
{
targetMaterial.Material.Flags = selectedMaterial.Material.Flags;
targetMaterial.Material.UserDatas = selectedMaterial.Material.UserDatas;
targetMaterial.Material.UserDataDict = selectedMaterial.Material.UserDataDict;
if (menu.chkBoxRenderInfo.Checked)
{
targetMaterial.Material.RenderInfoDict = selectedMaterial.Material.RenderInfoDict;
targetMaterial.Material.RenderInfos = selectedMaterial.Material.RenderInfos;
}
if (menu.chkBoxShaderOptions.Checked)
{
targetMaterial.Material.ShaderAssign = selectedMaterial.Material.ShaderAssign;
}
if (menu.chkBoxShaderParams.Checked)
{
targetMaterial.Material.ShaderParamData = selectedMaterial.Material.ShaderParamData;
targetMaterial.Material.ShaderParamDict = selectedMaterial.Material.ShaderParamDict;
targetMaterial.Material.ShaderParams = selectedMaterial.Material.ShaderParams;
targetMaterial.Material.VolatileFlags = selectedMaterial.Material.VolatileFlags;
}
if (menu.chkBoxTextures.Checked)
{
targetMaterial.Material.SamplerDict = selectedMaterial.Material.SamplerDict;
targetMaterial.Material.Samplers = selectedMaterial.Material.Samplers;
targetMaterial.Material.SamplerSlotArray = selectedMaterial.Material.SamplerSlotArray;
targetMaterial.Material.TextureSlotArray = selectedMaterial.Material.TextureSlotArray;
targetMaterial.Material.TextureRefs = selectedMaterial.Material.TextureRefs;
}
targetMaterial.ReadMaterial(targetMaterial.Material);
}
public void ExportAll()
{
FolderSelectDialog sfd = new FolderSelectDialog();
List<string> Formats = new List<string>();
Formats.Add("Bfres object (.bfobj)");
Formats.Add("CSV (.csv)");
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
TextureFormatExport form = new TextureFormatExport(Formats);
if (form.ShowDialog() == DialogResult.OK)
{
foreach (FSHP shp in shapes)
{
if (form.Index == 0)
shp.ExportBinaryObject(folderPath + '\\' + shp.Text + ".bfobj");
}
}
}
}
public void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfmdl;*.fbx;*.dae; *.obj;*.csv;|" +
"Bfres Model|*.bfmdl|" +
"FBX |*.fbx|" +
"DAE |*.dae|" +
"OBJ |*.obj|" +
"CSV |*.csv|" +
"All files(*.*)|*.*";
sfd.DefaultExt = ".bfobj";
sfd.FileName = Text;
if (sfd.ShowDialog() == DialogResult.OK)
{
string ext = System.IO.Path.GetExtension(sfd.FileName);
ext = ext.ToLower();
switch (ext)
{
case ".bfmdl":
if (GetResFileU() != null)
{
}
else
Model.Export(sfd.FileName, GetResFile());
break;
case ".csv":
CsvModel csv = new CsvModel();
foreach (FSHP shape in shapes)
{
STGenericObject obj = new STGenericObject();
obj.ObjectName = shape.Text;
obj.vertices = shape.vertices;
obj.faces = shape.lodMeshes[shape.DisplayLODIndex].faces;
csv.objects.Add(obj);
int CurVtx = 0;
foreach (Vertex v in shape.vertices)
{
if (v.boneIds[0] != 0)
obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[0]));
if (v.boneIds[1] != 0)
obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[1]));
if (v.boneIds[2] != 0)
obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[2]));
if (v.boneIds[3] != 0)
obj.vertices[CurVtx].boneNames.Add(shape.GetBoneNameFromIndex(this, v.boneIds[3]));
CurVtx++;
}
}
System.IO.File.WriteAllBytes(sfd.FileName, csv.Save());
break;
default:
List<STGenericTexture> Surfaces = new List<STGenericTexture>();
foreach (FSHP fshp in shapes)
{
foreach (var bntx in PluginRuntime.bntxContainers)
{
foreach (var tex in fshp.GetMaterial().TextureMaps)
{
if (bntx.Textures.ContainsKey(tex.Name))
{
Surfaces.Add(bntx.Textures[tex.Name]);
}
}
}
foreach (var ftex in PluginRuntime.ftexContainers)
{
foreach (var tex in fshp.GetMaterial().TextureMaps)
{
if (ftex.Textures.ContainsKey(tex.Name))
{
Surfaces.Add(ftex.Textures[tex.Name]);
}
}
}
}
Console.WriteLine("tex count " + Surfaces.Count);
AssimpData assimp = new AssimpData();
assimp.SaveFromModel(this, sfd.FileName, Surfaces);
break;
}
}
}
public void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfobj;*.fbx;*.dae;*.obj;*.csv;|" +
"Bfres Object (shape/vertices) |*.bfobj|" +
"FBX |*.fbx|" +
"DAE |*.dae|" +
"OBJ |*.obj|" +
"CSV |*.csv|" +
"All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
AddOjects(ofd.FileName);
}
}
//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 FMAT GetMaterial(int index)
{
return materials.Values.ElementAt(index);
}
public void AddMaterials(string FileName, bool Replace = true)
{
string ext = System.IO.Path.GetExtension(FileName);
ext = ext.ToLower();
switch (ext)
{
case ".bfmat":
Cursor.Current = Cursors.WaitCursor;
if (Replace)
{
materials.Clear();
Nodes["FmatFolder"].Nodes.Clear();
}
FMAT mat = new FMAT();
mat.Material = new Material();
mat.Material.Import(FileName);
mat.ReadMaterial(mat.Material);
mat.Text = mat.Material.Name;
materials.Add(mat.Text, mat);
Nodes["FmatFolder"].Nodes.Add(mat);
break;
}
}
public override void OnClick(TreeView treeView)
{
}
private void CreateSkeleton()
{
}
private void CreateBones(STBone bone)
{
Bone bn = new Bone();
bn.BillboardIndex = (ushort)bone.BillboardIndex;
bn.Flags = BoneFlags.Visible;
bn.FlagsRotation = BoneFlagsRotation.EulerXYZ;
bn.FlagsTransform = BoneFlagsTransform.None;
bn.FlagsTransformCumulative = BoneFlagsTransformCumulative.None;
bn.Name = bone.Text;
bn.RigidMatrixIndex = 0;
bn.Rotation = new Syroot.Maths.Vector4F(bone.rotation[0],
bone.rotation[1], bone.rotation[2], bone.rotation[3]);
bn.Position = new Syroot.Maths.Vector3F(bone.position[0],
bone.position[1], bone.position[2]);
bn.Scale = new Syroot.Maths.Vector3F(bone.scale[0],
bone.scale[1], bone.scale[2]);
bn.UserData = new List<UserData>();
bn.UserDataDict = new ResDict();
}
public FSKL Skeleton
{
get
{
return skeleton;
}
set
{
skeleton = value;
}
}
private FSKL skeleton = new FSKL();
}
}

View File

@ -1,109 +0,0 @@
using System;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using FirstPlugin;
using Syroot.NintenTools.NSW.Bfres;
namespace Bfres.Structs
{
public class FscnFolder : TreeNodeCustom
{
public FscnFolder()
{
Text = "Scene Animations";
Name = "FSCN";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Import");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
private void Import(object sender, EventArgs args)
{
}
private void ExportAll(object sender, EventArgs args)
{
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
foreach (FSCN fscn in Nodes)
{
string FileName = folderPath + '\\' + fscn.Text + ".bfscn";
((FSCN)fscn).SceneAnim.Export(FileName, fscn.GetResFile());
}
}
}
private void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all scene animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Nodes.Clear();
}
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class FSCN : TreeNodeCustom
{
public SceneAnim SceneAnim;
public FSCN()
{
ImageKey = "sceneAnimation";
SelectedImageKey = "sceneAnimation";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public ResFile GetResFile()
{
return ((BFRES)Parent.Parent).resFile;
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfscn;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfska";
if (sfd.ShowDialog() == DialogResult.OK)
{
SceneAnim.Export(sfd.FileName, GetResFile());
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfscn;";
if (ofd.ShowDialog() == DialogResult.OK)
{
SceneAnim.Import(ofd.FileName);
}
SceneAnim.Name = Text;
}
public void Read(SceneAnim scn)
{
SceneAnim = scn;
}
}
}

View File

@ -1,108 +0,0 @@
using System;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using FirstPlugin;
using Syroot.NintenTools.NSW.Bfres;
namespace Bfres.Structs
{
public class FshpaFolder : TreeNodeCustom
{
public FshpaFolder()
{
Text = "Shape Animations";
Name = "FSHPA";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Import");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
private void Import(object sender, EventArgs args)
{
}
public void ExportAll(object sender, EventArgs args)
{
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
foreach (FSHA fsha in Nodes)
{
string FileName = folderPath + '\\' + fsha.Text + ".bfshpa";
((FSHA)fsha).ShapeAnim.Export(FileName, fsha.GetResFile());
}
}
}
private void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all shape animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Nodes.Clear();
}
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class FSHA : TreeNodeCustom
{
public ShapeAnim ShapeAnim;
public FSHA()
{
ImageKey = "shapeAnimation";
SelectedImageKey = "shapeAnimation";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public ResFile GetResFile()
{
return ((BFRES)Parent.Parent).resFile;
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfshpa;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfshpa";
if (sfd.ShowDialog() == DialogResult.OK)
{
ShapeAnim.Export(sfd.FileName, GetResFile());
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfshpa;";
if (ofd.ShowDialog() == DialogResult.OK)
{
ShapeAnim.Import(ofd.FileName);
}
ShapeAnim.Name = Text;
}
public void Read(ShapeAnim shapeAnim)
{
ShapeAnim = shapeAnim;
}
}
}

View File

@ -1,946 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Syroot.NintenTools.NSW.Bfres;
using Syroot.NintenTools.NSW.Bfres.Helpers;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using Switch_Toolbox.Library.Forms;
using ResU = Syroot.NintenTools.Bfres;
using ResUGX2 = Syroot.NintenTools.Bfres.GX2;
using ResGFX = Syroot.NintenTools.NSW.Bfres.GFX;
using FirstPlugin;
using OpenTK;
namespace Bfres.Structs
{
public class FSHPFolder : TreeNodeCustom
{
public FSHPFolder()
{
Text = "Objects";
Name = "FshpFolder";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Add Object");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All Objects");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear All Objects");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
private void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all objects? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Nodes.Clear();
((FMDL)Parent).shapes.Clear();
((FMDL)Parent).UpdateVertexData();
}
}
private void ExportAll(object sender, EventArgs args)
{
((FMDL)Parent).ExportAll();
}
private void Import(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfobj;*.fbx;*.dae; *.obj;*.csv;|" +
"Bfres Object (shape/vertices) |*.bfobj|" +
"FBX |*.fbx|" +
"DAE |*.dae|" +
"OBJ |*.obj|" +
"CSV |*.csv|" +
"All files(*.*)|*.*";
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
foreach (string file in ofd.FileNames)
((FMDL)Parent).AddOjects(file, false);
}
}
public override void OnClick(TreeView treeView)
{
}
}
public struct DisplayVertex
{
// Used for rendering.
public Vector3 pos;
public Vector3 nrm;
public Vector3 tan;
public Vector3 bit;
public Vector2 uv;
public Vector4 col;
public Vector4 node;
public Vector4 weight;
public Vector2 uv2;
public Vector2 uv3;
public Vector3 pos1;
public Vector3 pos2;
public static int Size = 4 * (3 + 3 + 3 + 3 + 2 + 4 + 4 + 4 + 2 + 2 + 3 + 3);
}
public class FSHP : STGenericObject
{
public bool IsWiiU
{
get
{
return GetResFileU() != null;
}
}
public FSHP()
{
Checked = true;
ImageKey = "mesh";
SelectedImageKey = "mesh";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export Mesh");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace Mesh");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
MenuItem remove = new MenuItem("Delete Mesh");
ContextMenu.MenuItems.Add(remove);
remove.Click += Remove;
MenuItem calcTansBitans = new MenuItem("Recalulate Tangents/Bitangents");
ContextMenu.MenuItems.Add(calcTansBitans);
calcTansBitans.Click += CalcTansBitans;
MenuItem flipUVsY = new MenuItem("Flip UVs (Vertical)");
ContextMenu.MenuItems.Add(flipUVsY);
flipUVsY.Click += FlipUvsVertical;
MenuItem flipUVsX = new MenuItem("Flip UVs (Horizontal)");
ContextMenu.MenuItems.Add(flipUVsX);
flipUVsX.Click += FlipUvsHorizontal;
MenuItem normals = new MenuItem("Normals");
ContextMenu.MenuItems.Add(normals);
MenuItem smoothNormals = new MenuItem("Smooth");
normals.MenuItems.Add(smoothNormals);
smoothNormals.Click += SmoothNormals;
MenuItem recalculateNormals = new MenuItem("Recalculate");
normals.MenuItems.Add(recalculateNormals);
recalculateNormals.Click += RecalculateNormals;
MenuItem matEditor = new MenuItem("Open Material Editor");
ContextMenu.MenuItems.Add(matEditor);
matEditor.Click += OpenMaterialEditor;
MenuItem rename = new MenuItem("Rename");
ContextMenu.MenuItems.Add(rename);
rename.Click += Rename;
}
public int ModelIndex; //For getting the model the shape is in
public VertexBuffer VertexBuffer;
public Shape Shape;
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);
}
public void SetMaterial(FMAT material)
{
((FMDL)Parent.Parent).materials[material.Text] = material;
}
public override void OnClick(TreeView treeView)
{
UpdateFSHPEditor();
}
public void UpdateFSHPEditor()
{
FSHPEditor docked = (FSHPEditor)LibraryGUI.Instance.GetContentDocked(new FSHPEditor());
if (docked == null)
{
docked = new FSHPEditor();
LibraryGUI.Instance.LoadDockContent(docked, PluginRuntime.FSHPDockState);
}
docked.Text = Text;
docked.Dock = DockStyle.Fill;
docked.LoadObject((FMDL)Parent.Parent, this);
}
private void SmoothNormals(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
SmoothNormals();
SaveVertexBuffer(IsWiiU);
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
private void RecalculateNormals(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
CalculateNormals();
SaveVertexBuffer(IsWiiU);
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
Text = dialog.textBox1.Text;
}
}
private void Remove(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove this object? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
((FMDL)Parent.Parent).shapes.Remove(this);
((FMDL)Parent.Parent).UpdateVertexData();
Parent.Nodes.Remove(this);
}
}
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":
case "gsys_bake_st1":
param.ValueFloat = new float[] { 1, 1, 0, 0 };
break;
}
}
}
}
public void TransformPosition(Vector3 Position, Vector3 Rotation, Vector3 Scale)
{
Matrix4 BonePosExtra = Utils.TransformValues(Position, Rotation, Scale);
foreach (Vertex v in vertices)
{
v.pos = Vector3.TransformPosition(v.pos, BonePosExtra);
v.nrm = Vector3.TransformNormal(v.pos, BonePosExtra);
}
}
private void OpenMaterialEditor(object sender, EventArgs args)
{
GetMaterial().UpdateFMATEditor();
}
private void CalcTansBitans(object sender, EventArgs args)
{
Cursor.Current = Cursors.WaitCursor;
bool HasTans = vertexAttributes.Any(x => x.Name == "_t0");
bool HasBiTans = vertexAttributes.Any(x => x.Name == "_b0");
if (!HasUV0())
{
MessageBox.Show($"Error! {Text} does not have UVs!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!HasBiTans)
{
DialogResult dialogResult2 = MessageBox.Show("Mesh does not have bitangents. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);
VertexAttribute att2 = new VertexAttribute();
att2.Name = "_b0";
att2.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;
if (dialogResult2 == DialogResult.Yes)
{
if (!HasBiTans)
vertexAttributes.Add(att2);
}
}
if (!HasTans)
{
DialogResult dialogResult = MessageBox.Show("Mesh does not have tangets. Do you want to create them? (will make file size bigger)", "", MessageBoxButtons.YesNo);
VertexAttribute att = new VertexAttribute();
att.Name = "_t0";
att.Format = ResGFX.AttribFormat.Format_10_10_10_2_SNorm;
if (dialogResult == DialogResult.Yes)
{
if (!HasTans)
vertexAttributes.Add(att);
}
}
CalculateTangentBitangent();
SaveVertexBuffer(IsWiiU);
UpdateVertexData();
Cursor.Current = Cursors.Default;
}
public bool HasUV0()
{
return vertexAttributes.Any(x => x.Name == "_u0");
}
public bool HasUV1()
{
return vertexAttributes.Any(x => x.Name == "_u1");
}
public bool HasUV2()
{
return vertexAttributes.Any(x => x.Name == "_u2");
}
public void FlipUvsVertical(object sender, EventArgs args)
{
if (!HasUV0())
{
MessageBox.Show($"Error! {Text} does not have UVs!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
FlipUvsVertical();
SaveVertexBuffer(IsWiiU);
UpdateVertexData();
}
public void FlipUvsHorizontal(object sender, EventArgs args)
{
if (!HasUV0())
{
MessageBox.Show($"Error! {Text} does not have UVs!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
FlipUvsHorizontal();
SaveVertexBuffer(IsWiiU);
UpdateVertexData();
}
public void ExportMaterials(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Materials|*.bfmat;";
sfd.DefaultExt = ".bfmat";
sfd.FileName = GetMaterial().Text;
if (sfd.ShowDialog() == DialogResult.OK)
{
GetMaterial().Material.Export(sfd.FileName, GetResFile());
}
}
public void ReplaceMaterials(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Materials|*.bfmat;";
ofd.DefaultExt = ".bfmat";
ofd.FileName = GetMaterial().Text;
if (ofd.ShowDialog() == DialogResult.OK)
{
GetMaterial().Material.Import(ofd.FileName);
}
}
public void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfobj;*.fbx;*.dae; *.obj;|" +
"Bfres Object (shape/vertices) |*.bfobj|" +
"FBX |*.fbx|" +
"DAE |*.dae|" +
"OBJ |*.obj|" +
"All files(*.*)|*.*";
sfd.DefaultExt = ".bfobj";
sfd.FileName = Text;
if (sfd.ShowDialog() == DialogResult.OK)
{
string ext = System.IO.Path.GetExtension(sfd.FileName);
ext = ext.ToLower();
switch (ext)
{
case ".bfobj":
ExportBinaryObject(sfd.FileName);
break;
default:
AssimpData assimp = new AssimpData();
assimp.SaveFromObject(vertices, lodMeshes[DisplayLODIndex].faces, Text, sfd.FileName);
break;
}
}
}
public void ExportBinaryObject(string FileName)
{
Shape.Export(FileName, GetResFile());
}
public void Replace(object sender, EventArgs args)
{
bool IsWiiU = (GetResFileU() != null);
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfobj;*.fbx;*.dae; *.obj;|" +
"Bfres Object (shape/vertices) |*.bfobj|" +
"FBX |*.fbx|" +
"DAE |*.dae|" +
"OBJ |*.obj|" +
"All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
string ext = System.IO.Path.GetExtension(ofd.FileName);
ext = ext.ToLower();
switch (ext)
{
case ".bfobj":
Shape shp = new Shape();
shp.Import(ofd.FileName, VertexBuffer);
shp.Name = Text;
shp.MaterialIndex = (ushort)MaterialIndex;
BfresSwitch.ReadShapesVertices(this, shp, VertexBuffer, GetModelList()[ModelIndex]);
break;
default:
AssimpData assimp = new AssimpData();
assimp.LoadFile(ofd.FileName);
AssimpMeshSelector selector = new AssimpMeshSelector();
selector.LoadMeshes(assimp, Index);
if (selector.ShowDialog() == DialogResult.OK)
{
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)
{
STGenericObject obj = selector.GetSelectedMesh();
Cursor.Current = Cursors.WaitCursor;
VertexBufferIndex = obj.VertexBufferIndex;
vertices = obj.vertices;
CreateBoneList(obj, (FMDL)Parent.Parent);
VertexSkinCount = obj.MaxSkinInfluenceCount;
vertexAttributes = settings.CreateNewAttributes();
lodMeshes = obj.lodMeshes;
CreateNewBoundingBoxes();
SaveShape(IsWiiU);
SaveVertexBuffer(IsWiiU);
Cursor.Current = Cursors.Default;
}
}
break;
}
UpdateVertexData();
}
}
public void CreateIndexList(STGenericObject ob, FMDL mdl = null)
{
BoneIndices = new List<ushort>();
List<string> boneNames = new List<string>();
foreach (Vertex v in ob.vertices)
{
foreach (string bn in v.boneNames)
{
if (!boneNames.Contains(bn))
boneNames.Add(bn);
}
}
int index = 0;
foreach (STBone bone in mdl.Skeleton.bones)
{
foreach (string bnam in boneNames)
{
if (bone.Text == bnam)
{
BoneIndices.Add((ushort)index);
}
}
index++;
}
}
public void CreateBoneList(STGenericObject ob, FMDL mdl)
{
string[] nodeArrStrings = new string[mdl.Skeleton.Node_Array.Length];
int CurNode = 0;
foreach (int thing in mdl.Skeleton.Node_Array)
nodeArrStrings[CurNode++] = mdl.Skeleton.bones[thing].Text;
foreach (Vertex v in ob.vertices)
{
foreach (string bn in v.boneNames)
{
foreach (var defBn in nodeArrStrings.Select((Value, Index) => new { Value, Index }))
{
if (bn == defBn.Value)
{
v.boneIds.Add(defBn.Index);
}
}
}
}
}
public void CreateNewBoundingBoxes()
{
boundingBoxes.Clear();
boundingRadius.Clear();
foreach (LOD_Mesh mesh in lodMeshes)
{
BoundingBox box = CalculateBoundingBox();
boundingBoxes.Add(box);
boundingRadius.Add((float)(box.Center.Length + box.Extend.Length));
foreach (LOD_Mesh.SubMesh sub in mesh.subMeshes)
boundingBoxes.Add(box);
}
}
private BoundingBox CalculateBoundingBox()
{
Vector3 Max = new Vector3();
Vector3 Min = new Vector3();
Min = Max = vertices[0].pos;
Min = CalculateBBMin(vertices);
Max = CalculateBBMax(vertices);
Vector3 center = (Max + Min);
Vector3 extend = Max - Min;
return new BoundingBox() { Center = center, Extend = extend };
}
private Vector3 CalculateBBMin(List<Vertex> positionVectors)
{
Vector3 minimum = new Vector3();
foreach (Vertex vtx in positionVectors)
{
if (vtx.pos.X < minimum.X) minimum.X = vtx.pos.X;
if (vtx.pos.Y < minimum.Y) minimum.Y = vtx.pos.Y;
if (vtx.pos.Z < minimum.Z) minimum.Z = vtx.pos.Z;
}
return minimum;
}
private Vector3 CalculateBBMax(List<Vertex> positionVectors)
{
Vector3 maximum = new Vector3();
foreach (Vertex vtx in positionVectors)
{
if (vtx.pos.X > maximum.X) maximum.X = vtx.pos.X;
if (vtx.pos.Y > maximum.Y) maximum.Y = vtx.pos.Y;
if (vtx.pos.Z > maximum.Z) maximum.Z = vtx.pos.Z;
}
return maximum;
}
private void UpdateShaderAssignAttributes(FMAT material)
{
material.shaderassign.attributes.Clear();
foreach (VertexAttribute att in vertexAttributes)
{
material.shaderassign.attributes.Add(att.Name, att.Name);
}
}
public int[] Faces;
public List<ushort> BoneIndices = new List<ushort>();
// for drawing
public int[] display;
public int VertexSkinCount;
public int DisplayId;
public int boneIndx;
public int VertexBufferIndex;
public int TargetAttribCount;
public List<float> boundingRadius = new List<float>();
public List<BoundingBox> boundingBoxes = new List<BoundingBox>();
public class BoundingBox
{
public Vector3 Center;
public Vector3 Extend;
}
public int DisplayLODIndex = 0;
public List<VertexAttribute> vertexAttributes = new List<VertexAttribute>();
public class VertexAttribute
{
public string Name;
public ResGFX.AttribFormat Format;
public override string ToString()
{
return Name;
}
public ResGFX.AttribFormat GetTypeWiiU(ResUGX2.GX2AttribFormat type)
{
return (ResGFX.AttribFormat)System.Enum.Parse(typeof(ResGFX.AttribFormat), $"{type.ToString()}");
}
public ResUGX2.GX2AttribFormat SetTypeWiiU(ResGFX.AttribFormat type)
{
return (ResUGX2.GX2AttribFormat)System.Enum.Parse(typeof(ResUGX2.GX2AttribFormat), type.ToString());
}
}
public void SaveShape(bool IsWiiU)
{
if (IsWiiU)
ShapeU = BfresWiiU.SaveShape(this);
else
Shape = BfresSwitch.SaveShape(this);
}
public IList<ushort> GetIndices()
{
IList<ushort> indices = new List<ushort>();
List<string> BoneNodes = new List<string>();
foreach (Vertex vtx in vertices)
{
}
return indices;
}
public Vector3 TransformLocal(Vector3 position, bool IsPos = true)
{
Matrix4 trans = Matrix4.CreateTranslation(0, 0, 0);
if (IsPos)
return Vector3.TransformPosition(position, trans);
else
return Vector3.TransformNormal(position, trans);
}
public void SaveVertexBuffer(bool IsWiiU)
{
if (IsWiiU)
{
BfresWiiU.SaveVertexBuffer(this);
return;
}
VertexBufferHelper helpernx = new VertexBufferHelper(new VertexBuffer(), Syroot.BinaryData.ByteOrder.LittleEndian);
List<VertexBufferHelperAttrib> atrib = new List<VertexBufferHelperAttrib>();
UpdateVertices();
foreach (VertexAttribute att in vertexAttributes)
{
if (att.Name == "_p0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = verts.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_n0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = norms.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_u0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = uv0.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_u1")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = uv1.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_u2")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = uv2.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_w0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = weights.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_i0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = boneInd.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_b0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = bitans.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_t0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = tans.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
if (att.Name == "_c0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = colors.ToArray();
vert.Format = att.Format;
atrib.Add(vert);
}
}
if (atrib.Count == 0)
{
MessageBox.Show("Attributes are empty?");
return;
}
helpernx.Attributes = atrib;
VertexBuffer = helpernx.ToVertexBuffer();
}
internal List<Syroot.Maths.Vector4F> verts = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> norms = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> uv0 = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> uv1 = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> uv2 = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> tans = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> bitans = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> weights = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> boneInd = new List<Syroot.Maths.Vector4F>();
internal List<Syroot.Maths.Vector4F> colors = new List<Syroot.Maths.Vector4F>();
public string GetBoneNameFromIndex(FMDL mdl, int index)
{
if (index == 0)
return "";
return mdl.Skeleton.bones[mdl.Skeleton.Node_Array[index]].Text;
}
public void UpdateVertices()
{
// CalculateTangentBitangent();
foreach (Vertex vtx in vertices)
{
if (VertexSkinCount == 0 || VertexSkinCount == 1)
{
// Console.WriteLine("Old " + vtx.pos);
// vtx.pos = TransformLocal(vtx.pos);
// vtx.nrm = TransformLocal(vtx.nrm, false);
// Console.WriteLine("New " + vtx.pos);
}
//Console.WriteLine($"Weight count {vtx.boneWeights.Count}");
//Console.WriteLine($"Index count {vtx.boneIds.Count}");
verts.Add(new Syroot.Maths.Vector4F(vtx.pos.X, vtx.pos.Y, vtx.pos.Z, 1.0f));
norms.Add(new Syroot.Maths.Vector4F(vtx.nrm.X, vtx.nrm.Y, vtx.nrm.Z, 0));
uv0.Add(new Syroot.Maths.Vector4F(vtx.uv0.X, vtx.uv0.Y, 0, 0));
uv1.Add(new Syroot.Maths.Vector4F(vtx.uv1.X, vtx.uv1.Y, 0, 0));
uv2.Add(new Syroot.Maths.Vector4F(vtx.uv2.X, vtx.uv2.Y, 0, 0));
tans.Add(new Syroot.Maths.Vector4F(vtx.tan.X, vtx.tan.Y, vtx.tan.Z, vtx.tan.W));
bitans.Add(new Syroot.Maths.Vector4F(vtx.bitan.X, vtx.bitan.Y, vtx.bitan.Z, vtx.bitan.W));
if (vtx.boneWeights.Count == 0)
{
vtx.boneWeights.Add(0);
vtx.boneWeights.Add(0);
vtx.boneWeights.Add(0);
vtx.boneWeights.Add(0);
}
if (vtx.boneWeights.Count == 1)
{
vtx.boneWeights.Add(0);
vtx.boneWeights.Add(0);
vtx.boneWeights.Add(0);
}
if (vtx.boneWeights.Count == 2)
{
vtx.boneWeights.Add(0);
vtx.boneWeights.Add(0);
}
if (vtx.boneWeights.Count == 3)
{
vtx.boneWeights.Add(0);
}
if (vtx.boneIds.Count == 0)
{
vtx.boneIds.Add(0);
vtx.boneIds.Add(0);
vtx.boneIds.Add(0);
vtx.boneIds.Add(0);
}
if (vtx.boneIds.Count == 1)
{
vtx.boneIds.Add(0);
vtx.boneIds.Add(0);
vtx.boneIds.Add(0);
}
if (vtx.boneIds.Count == 2)
{
vtx.boneIds.Add(0);
vtx.boneIds.Add(0);
}
if (vtx.boneIds.Count == 3)
{
vtx.boneIds.Add(0);
}
weights.Add(new Syroot.Maths.Vector4F(vtx.boneWeights[0], vtx.boneWeights[1], vtx.boneWeights[2], vtx.boneWeights[3]));
boneInd.Add(new Syroot.Maths.Vector4F(vtx.boneIds[0], vtx.boneIds[1], vtx.boneIds[2], vtx.boneIds[3]));
colors.Add(new Syroot.Maths.Vector4F(vtx.col.X, vtx.col.Y, vtx.col.Z, vtx.col.W));
}
}
public List<DisplayVertex> CreateDisplayVertices()
{
// rearrange faces
display = lodMeshes[DisplayLODIndex].getDisplayFace().ToArray();
List<DisplayVertex> displayVertList = new List<DisplayVertex>();
if (lodMeshes[DisplayLODIndex].faces.Count <= 3)
return displayVertList;
foreach (Vertex v in vertices)
{
DisplayVertex displayVert = new DisplayVertex()
{
pos = v.pos,
nrm = v.nrm,
tan = v.tan.Xyz,
bit = v.bitan.Xyz,
col = v.col,
uv = v.uv0,
uv2 = v.uv1,
uv3 = v.uv2,
node = new Vector4(
v.boneIds.Count > 0 ? v.boneIds[0] : -1,
v.boneIds.Count > 1 ? v.boneIds[1] : -1,
v.boneIds.Count > 2 ? v.boneIds[2] : -1,
v.boneIds.Count > 3 ? v.boneIds[3] : -1),
weight = new Vector4(
v.boneWeights.Count > 0 ? v.boneWeights[0] : 0,
v.boneWeights.Count > 1 ? v.boneWeights[1] : 0,
v.boneWeights.Count > 2 ? v.boneWeights[2] : 0,
v.boneWeights.Count > 3 ? v.boneWeights[3] : 0),
};
displayVertList.Add(displayVert);
/* Console.WriteLine($"---------------------------------------------------------------------------------------");
Console.WriteLine($"Position {displayVert.pos.X} {displayVert.pos.Y} {displayVert.pos.Z}");
Console.WriteLine($"Normal {displayVert.nrm.X} {displayVert.nrm.Y} {displayVert.nrm.Z}");
Console.WriteLine($"Binormal {displayVert.bit.X} {displayVert.bit.Y} {displayVert.bit.Z}");
Console.WriteLine($"Tanget {displayVert.tan.X} {displayVert.tan.Y} {displayVert.tan.Z}");
Console.WriteLine($"Color {displayVert.col.X} {displayVert.col.Y} {displayVert.col.Z} {displayVert.col.W}");
Console.WriteLine($"UV Layer 1 {displayVert.uv.X} {displayVert.uv.Y}");
Console.WriteLine($"UV Layer 2 {displayVert.uv2.X} {displayVert.uv2.Y}");
Console.WriteLine($"UV Layer 3 {displayVert.uv3.X} {displayVert.uv3.Y}");
Console.WriteLine($"Bone Index {displayVert.node.X} {displayVert.node.Y} {displayVert.node.Z} {displayVert.node.W}");
Console.WriteLine($"Weights {displayVert.weight.X} {displayVert.weight.Y} {displayVert.weight.Z} {displayVert.weight.W}");
Console.WriteLine($"---------------------------------------------------------------------------------------");*/
}
return displayVertList;
}
}
}

View File

@ -1,487 +0,0 @@
using System;
using System.Collections.Generic;
using Syroot.NintenTools.NSW.Bfres;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using ResU = Syroot.NintenTools.Bfres;
using FirstPlugin;
using OpenTK;
namespace Bfres.Structs
{
public class FskaFolder : AnimationGroupNode
{
public FskaFolder()
{
Text = "Skeleton Animations";
Name = "FSKA";
ContextMenu = new ContextMenu();
MenuItem import = new MenuItem("Import");
ContextMenu.MenuItems.Add(import);
import.Click += Import;
MenuItem exportAll = new MenuItem("Export All");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
public void Import(object sender, EventArgs args)
{
}
public void ExportAll(object sender, EventArgs args)
{
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
foreach (FSKA fska in Nodes)
{
string FileName = folderPath + '\\' + fska.Text + ".bfska";
if (fska.GetResFileU() != null)
((FSKA)fska).SkeletalAnimU.Export(FileName, fska.GetResFileU());
else
((FSKA)fska).SkeletalAnim.Export(FileName, fska.GetResFile());
}
}
}
private void Clear(object sender, EventArgs args)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to remove all skeletal animations? This cannot be undone!", "", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Nodes.Clear();
}
}
}
public class FSKA : Animation
{
public enum TrackType
{
XSCA = 0x4,
YSCA = 0x8,
ZSCA = 0xC,
XPOS = 0x10,
YPOS = 0x14,
ZPOS = 0x18,
XROT = 0x20,
YROT = 0x24,
ZROT = 0x28,
}
public SkeletalAnim SkeletalAnim;
public ResU.SkeletalAnim SkeletalAnimU;
public FSKA()
{
ImageKey = "skeletonAnimation";
SelectedImageKey = "skeletonAnimation";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public FSKA(string name)
{
Text = name;
ImageKey = "skeletonAnimation";
SelectedImageKey = "skeletonAnimation";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public ResFile GetResFile()
{
//ResourceFile -> FMDL -> Material Folder -> this
return ((BFRES)Parent.Parent).resFile;
}
public ResU.ResFile GetResFileU()
{
//ResourceFile -> FMDL -> Material Folder -> this
return ((BFRES)Parent.Parent).resFileU;
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfska;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfska";
if (sfd.ShowDialog() == DialogResult.OK)
{
if (GetResFileU() != null)
{
SkeletalAnimU.Export(sfd.FileName, GetResFileU());
}
else
{
SkeletalAnim.Export(sfd.FileName, GetResFile());
}
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfska;";
if (ofd.ShowDialog() == DialogResult.OK)
{
if (GetResFileU() != null)
{
SkeletalAnimU.Import(ofd.FileName, GetResFileU());
SkeletalAnimU.Name = Text;
Read(SkeletalAnimU);
}
else
{
SkeletalAnim.Import(ofd.FileName);
SkeletalAnim.Name = Text;
Read(SkeletalAnim);
}
}
}
public void Read(ResU.SkeletalAnim ska)
{
Nodes.Clear();
Bones.Clear();
FrameCount = ska.FrameCount;
SkeletalAnimU = ska;
foreach (ResU.BoneAnim bn in ska.BoneAnims)
{
FSKANode bonean = new FSKANode(bn);
Animation.KeyNode bone = new Animation.KeyNode("");
Bones.Add(bone);
if (ska.FlagsRotate == ResU.SkeletalAnimFlagsRotate.EulerXYZ)
bone.RotType = Animation.RotationType.EULER;
else
bone.RotType = Animation.RotationType.QUATERNION;
bone.Text = bonean.Text;
for (int Frame = 0; Frame < ska.FrameCount; Frame++)
{
if (Frame == 0)
{
if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Scale))
{
bone.XSCA.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.sca.X });
bone.YSCA.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.sca.Y });
bone.ZSCA.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.sca.Z });
}
if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Rotate))
{
bone.XROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.X });
bone.YROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.Y });
bone.ZROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.Z });
bone.WROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.W });
}
if (bn.FlagsBase.HasFlag(ResU.BoneAnimFlagsBase.Translate))
{
bone.XPOS.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.pos.X });
bone.YPOS.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.pos.Y });
bone.ZPOS.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.pos.Z });
}
}
foreach (FSKATrack track in bonean.tracks)
{
KeyFrame frame = new KeyFrame();
frame.InterType = Animation.InterpolationType.HERMITE;
frame.Frame = Frame;
FSKAKey left = track.GetLeft(Frame);
FSKAKey right = track.GetRight(Frame);
float value;
value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);
// interpolate the value and apply
switch (track.flag)
{
case (int)TrackType.XPOS: frame.Value = value; bone.XPOS.Keys.Add(frame); break;
case (int)TrackType.YPOS: frame.Value = value; bone.YPOS.Keys.Add(frame); break;
case (int)TrackType.ZPOS: frame.Value = value; bone.ZPOS.Keys.Add(frame); break;
case (int)TrackType.XROT: frame.Value = value; bone.XROT.Keys.Add(frame); break;
case (int)TrackType.YROT: frame.Value = value; bone.YROT.Keys.Add(frame); break;
case (int)TrackType.ZROT: frame.Value = value; bone.ZROT.Keys.Add(frame); break;
case (int)TrackType.XSCA: frame.Value = value; bone.XSCA.Keys.Add(frame); break;
case (int)TrackType.YSCA: frame.Value = value; bone.YSCA.Keys.Add(frame); break;
case (int)TrackType.ZSCA: frame.Value = value; bone.ZSCA.Keys.Add(frame); break;
}
}
}
}
}
public void Read(SkeletalAnim ska)
{
Nodes.Clear();
Bones.Clear();
FrameCount = ska.FrameCount;
SkeletalAnim = ska;
foreach (BoneAnim bn in ska.BoneAnims)
{
FSKANode bonean = new FSKANode(bn);
Animation.KeyNode bone = new Animation.KeyNode("");
Bones.Add(bone);
if (ska.FlagsRotate == SkeletalAnimFlagsRotate.EulerXYZ)
bone.RotType = Animation.RotationType.EULER;
else
bone.RotType = Animation.RotationType.QUATERNION;
bone.Text = bonean.Text;
for (int Frame = 0; Frame < ska.FrameCount; Frame++)
{
if (Frame == 0)
{
if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Scale))
{
bone.XSCA.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.sca.X });
bone.YSCA.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.sca.Y });
bone.ZSCA.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.sca.Z });
}
if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Rotate))
{
bone.XROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.X });
bone.YROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.Y });
bone.ZROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.Z });
bone.WROT.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.rot.W });
}
if (bn.FlagsBase.HasFlag(BoneAnimFlagsBase.Translate))
{
bone.XPOS.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.pos.X });
bone.YPOS.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.pos.Y });
bone.ZPOS.Keys.Add(new KeyFrame() { Frame = 0, Value = bonean.pos.Z });
}
}
foreach (FSKATrack track in bonean.tracks)
{
KeyFrame frame = new KeyFrame();
frame.InterType = Animation.InterpolationType.HERMITE;
frame.Frame = Frame;
FSKAKey left = track.GetLeft(Frame);
FSKAKey right = track.GetRight(Frame);
float value;
value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);
// interpolate the value and apply
switch (track.flag)
{
case (int)TrackType.XPOS: frame.Value = value; bone.XPOS.Keys.Add(frame); break;
case (int)TrackType.YPOS: frame.Value = value; bone.YPOS.Keys.Add(frame); break;
case (int)TrackType.ZPOS: frame.Value = value; bone.ZPOS.Keys.Add(frame); break;
case (int)TrackType.XROT: frame.Value = value; bone.XROT.Keys.Add(frame); break;
case (int)TrackType.YROT: frame.Value = value; bone.YROT.Keys.Add(frame); break;
case (int)TrackType.ZROT: frame.Value = value; bone.ZROT.Keys.Add(frame); break;
case (int)TrackType.XSCA: frame.Value = value; bone.XSCA.Keys.Add(frame); break;
case (int)TrackType.YSCA: frame.Value = value; bone.YSCA.Keys.Add(frame); break;
case (int)TrackType.ZSCA: frame.Value = value; bone.ZSCA.Keys.Add(frame); break;
}
}
}
}
}
public class FSKANode
{
public int flags;
public int flags2;
public int stride;
public int BeginRotate;
public int BeginTranslate;
public long offBase;
public int trackCount;
public int trackFlag;
public long offTrack;
public string Text;
public Vector3 sca, pos;
public Vector4 rot;
public List<FSKATrack> tracks = new List<FSKATrack>();
public FSKANode(ResU.BoneAnim b)
{
Text = b.Name;
sca = new Vector3(b.BaseData.Scale.X, b.BaseData.Scale.Y, b.BaseData.Scale.Z);
rot = new Vector4(b.BaseData.Rotate.X, b.BaseData.Rotate.Y, b.BaseData.Rotate.Z, b.BaseData.Rotate.W);
pos = new Vector3(b.BaseData.Translate.X, b.BaseData.Translate.Y, b.BaseData.Translate.Z);
foreach (ResU.AnimCurve tr in b.Curves)
{
FSKATrack t = new FSKATrack();
t.flag = (int)tr.AnimDataOffset;
tracks.Add(t);
float tanscale = tr.Delta;
if (tanscale == 0)
tanscale = 1;
for (int i = 0; i < (ushort)tr.Frames.Length; i++)
{
if (tr.CurveType == ResU.AnimCurveType.Cubic)
{
int framedata = (int)tr.Frames[i];
float keydata = tr.Offset + ((tr.Keys[i, 0] * tr.Scale));
float keydata2 = tr.Offset + ((tr.Keys[i, 1] * tr.Scale));
float keydata3 = tr.Offset + ((tr.Keys[i, 2] * tr.Scale));
float keydata4 = tr.Offset + ((tr.Keys[i, 3] * tr.Scale));
}
if (tr.KeyType == ResU.AnimCurveKeyType.Int16)
{
}
else if (tr.KeyType == ResU.AnimCurveKeyType.Single)
{
}
else if (tr.KeyType == ResU.AnimCurveKeyType.SByte)
{
}
t.keys.Add(new FSKAKey()
{
frame = (int)tr.Frames[i],
unk1 = tr.Offset + ((tr.Keys[i, 0] * tr.Scale)),
unk2 = tr.Offset + ((tr.Keys[i, 1] * tr.Scale)),
unk3 = tr.Offset + ((tr.Keys[i, 2] * tr.Scale)),
unk4 = tr.Offset + ((tr.Keys[i, 3] * tr.Scale)),
});
}
}
}
public FSKANode(BoneAnim b)
{
Text = b.Name;
sca = new Vector3(b.BaseData.Scale.X, b.BaseData.Scale.Y, b.BaseData.Scale.Z);
rot = new Vector4(b.BaseData.Rotate.X, b.BaseData.Rotate.Y, b.BaseData.Rotate.Z, b.BaseData.Rotate.W);
pos = new Vector3(b.BaseData.Translate.X, b.BaseData.Translate.Y, b.BaseData.Translate.Z);
foreach (AnimCurve tr in b.Curves)
{
FSKATrack t = new FSKATrack();
t.flag = (int)tr.AnimDataOffset;
tracks.Add(t);
float tanscale = tr.Delta;
if (tanscale == 0)
tanscale = 1;
for (int i = 0; i < (ushort)tr.Frames.Length; i++)
{
if (tr.CurveType == AnimCurveType.Cubic)
{
int framedata = (int)tr.Frames[i];
float keydata = tr.Offset + ((tr.Keys[i, 0] * tr.Scale));
float keydata2 = tr.Offset + ((tr.Keys[i, 1] * tr.Scale));
float keydata3 = tr.Offset + ((tr.Keys[i, 2] * tr.Scale));
float keydata4 = tr.Offset + ((tr.Keys[i, 3] * tr.Scale));
}
if (tr.KeyType == AnimCurveKeyType.Int16)
{
}
else if (tr.KeyType == AnimCurveKeyType.Single)
{
}
else if (tr.KeyType == AnimCurveKeyType.SByte)
{
}
t.keys.Add(new FSKAKey()
{
frame = (int)tr.Frames[i],
unk1 = tr.Offset + ((tr.Keys[i, 0] * tr.Scale)),
unk2 = tr.Offset + ((tr.Keys[i, 1] * tr.Scale)),
unk3 = tr.Offset + ((tr.Keys[i, 2] * tr.Scale)),
unk4 = tr.Offset + ((tr.Keys[i, 3] * tr.Scale)),
});
}
}
}
}
public class FSKATrack
{
public short type;
public short keyCount;
public int flag;
public int unk2;
public int padding1;
public int padding2;
public int padding3;
public float frameCount;
public float scale, init, unkf3;
public long offtolastKeys, offtolastData;
public List<FSKAKey> keys = new List<FSKAKey>();
public int offset;
public FSKAKey GetLeft(int frame)
{
FSKAKey prev = keys[0];
for (int i = 0; i < keys.Count - 1; i++)
{
FSKAKey key = keys[i];
if (key.frame > frame && prev.frame <= frame)
break;
prev = key;
}
return prev;
}
public FSKAKey GetRight(int frame)
{
FSKAKey cur = keys[0];
FSKAKey prev = keys[0];
for (int i = 1; i < keys.Count; i++)
{
FSKAKey key = keys[i];
cur = key;
if (key.frame > frame && prev.frame <= frame)
break;
prev = key;
}
return cur;
}
}
public class FSKAKey
{
public int frame;
public float unk1, unk2, unk3, unk4;
public int offset;
}
}
}

View File

@ -1,151 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Syroot.NintenTools.NSW.Bfres;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using ResU = Syroot.NintenTools.Bfres;
using FirstPlugin;
using OpenTK;
namespace Bfres.Structs
{
public class FSKL : STSkeleton
{
public int[] Node_Array;
public List<Matrix3x4> matrices = new List<Matrix3x4>();
public fsklNode node;
public class fsklNode : TreeNodeCustom
{
public Skeleton Skeleton;
public ResU.Skeleton SkeletonU;
public BFRESRender BFRESRender;
public fsklNode()
{
Text = "Skeleton";
ImageKey = "skeleton";
SelectedImageKey = "skeleton";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Bfres Skeleton|*.bfskl;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfskl";
if (sfd.ShowDialog() == DialogResult.OK)
{
Skeleton.Export(sfd.FileName, ((FMDL)Parent).GetResFile());
}
}
public void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfska;|" +
"Bfres Object (shape/vertices) |*.bfska|" +
"All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
Skeleton.Import(ofd.FileName);
}
}
public override void OnClick(TreeView treeView)
{
}
}
public FSKL()
{
}
public FSKL(Skeleton skl)
{
node = new fsklNode();
node.Skeleton = skl;
BfresSwitch.ReadSkeleton(node, skl, this);
}
public FSKL(ResU.Skeleton skl)
{
node = new fsklNode();
node.SkeletonU = skl;
BfresWiiU.SetSkeleton(node, skl, this);
}
}
public class BfresBone : STBone
{
public bool IsVisable = true;
public BoneFlagsBillboard billboard;
public BoneFlagsRotation rotationFlags;
public BoneFlagsTransform transformFlags;
public Bone Bone;
public ResU.Bone BoneU;
public BFRESRender BFRESRender;
public BfresBone()
{
ImageKey = "bone";
SelectedImageKey = "bone";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
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();
sfd.Filter = "Bfres Bone|*.bfbn;";
sfd.FileName = Text;
sfd.DefaultExt = ".bfbn";
if (sfd.ShowDialog() == DialogResult.OK)
{
Bone.Export(sfd.FileName, GetResFile());
}
}
public void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfska;|" +
"Bfres Object (shape/vertices) |*.bfska|" +
"All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
Bone.Import(ofd.FileName);
}
Bone.Name = Text;
}
public BfresBone(STSkeleton skeleton)
{
skeletonParent = skeleton;
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadBoneEditor(this);
}
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Syroot.NintenTools.NSW.Bfres;
using Syroot.NintenTools.NSW.Bfres.Helpers;
using OpenTK;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using WeifenLuo.WinFormsUI.Docking;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
using FirstPlugin;
namespace Bfres.Structs
{
public class Misc
{
public static List<string> HackyTextureList = new List<string>(new string[] {
"Alb", "alb", "Base", "base", "bonbon.167300917","Eye.00","EyeIce.00", "FaceDummy", "Eye01.17", "Dee.00",
"rainbow.758540574", "Mucus._1700670200", "Eye.11", "CapTail00","eye.0","pallet_texture","Mark.930799313","InEye.1767598300","Face.00",
"ThunderHair_Thunder_BaseColor.1751853236","FireHair_Thunder_BaseColor._162539711","IceHair_Thunder_BaseColor.674061150","BodyEnemy.1866226988",
"Common_Scroll01._13827715"
});
}
}

View File

@ -1,43 +0,0 @@
using Switch_Toolbox.Library;
using System.Windows.Forms;
using FirstPlugin;
namespace Bfres.Structs
{
public class TexSrtFolder : TreeNodeCustom
{
public TexSrtFolder()
{
Text = "Texture SRT Animations";
Name = "TEXSRT";
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class FshuFolder : TreeNodeCustom
{
public FshuFolder()
{
Text = "Shader Parameter Animations";
Name = "FSHA";
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
public class FshuColorFolder : TreeNodeCustom
{
public FshuColorFolder()
{
Text = "Color Animations";
Name = "FSHAColor";
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
}

View File

@ -1,20 +0,0 @@
using Switch_Toolbox.Library;
using System.Windows.Forms;
using FirstPlugin;
namespace Bfres.Structs
{
public class TexPatFolder : TreeNodeCustom
{
public TexPatFolder()
{
Text = "Texture Pattern Animations";
Name = "TEXPAT";
}
public override void OnClick(TreeView treeView)
{
FormLoader.LoadEditor(this, Text);
}
}
}

View File

@ -1,988 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Syroot.NintenTools.NSW.Bfres;
using Syroot.NintenTools.NSW.Bfres.Helpers;
using Syroot.NintenTools.NSW.Bfres.GFX;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using OpenTK;
using System.Windows.Forms;
using Bfres.Structs;
namespace FirstPlugin
{
public static class BfresSwitch
{
public static Model SetModel(FMDL fmdl)
{
Model model = new Model();
model.Name = fmdl.Text;
model.Path = "";
model.Shapes = new List<Shape>();
model.VertexBuffers = new List<VertexBuffer>();
model.Materials = new List<Material>();
model.UserData = new List<UserData>();
model.Skeleton = new Skeleton();
model.Skeleton = fmdl.Skeleton.node.Skeleton;
model.ShapeDict = new ResDict();
model.MaterialDict = new ResDict();
model.UserDataDict = new ResDict();
int i = 0;
var duplicates = fmdl.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c);
foreach (var shape in duplicates)
shape.Text += i++;
foreach (FSHP shape in fmdl.shapes)
{
BFRES.CheckMissingTextures(shape);
SetShape(shape, shape.Shape);
model.Shapes.Add(shape.Shape);
model.VertexBuffers.Add(shape.VertexBuffer);
shape.Shape.VertexBufferIndex = (ushort)(model.VertexBuffers.Count - 1);
BFRES.SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape);
}
foreach (FMAT mat in fmdl.materials.Values)
{
SetMaterial(mat, mat.Material);
model.Materials.Add(mat.Material);
}
return model;
}
public static void Read(BFRESRender renderer, ResFile resFile, TreeNode ResFileNode)
{
int CurMdl = 0;
foreach (Model mdl in resFile.Models)
{
FMDL model = new FMDL();
model.Text = mdl.Name;
model.Skeleton = new FSKL(mdl.Skeleton);
model.Nodes.Add(model.Skeleton.node);
model.Skeleton.reset();
model.Skeleton.update();
model.Skeleton.node.BFRESRender = renderer;
model.Model = mdl;
foreach (Material mat in mdl.Materials)
{
FMAT FMAT = new FMAT();
FMAT.Text = mat.Name;
FMAT.ReadMaterial(mat);
model.Nodes[1].Nodes.Add(FMAT);
model.materials.Add(FMAT.Text, FMAT);
}
foreach (Shape shp in mdl.Shapes)
{
VertexBuffer vertexBuffer = mdl.VertexBuffers[shp.VertexBufferIndex];
Material material = mdl.Materials[shp.MaterialIndex];
FSHP mesh = new FSHP();
mesh.ModelIndex = CurMdl;
ReadShapesVertices(mesh, shp, vertexBuffer, model);
mesh.MaterialIndex = shp.MaterialIndex;
model.Nodes[0].Nodes.Add(mesh);
model.shapes.Add(mesh);
}
ResFileNode.Nodes[0].Nodes.Add(model);
renderer.models.Add(model);
CurMdl++;
}
}
public static Shape SaveShape(FSHP fshp)
{
Shape Shape = new Shape();
Shape.VertexSkinCount = (byte)fshp.VertexSkinCount;
Shape.Flags = ShapeFlags.HasVertexBuffer;
Shape.BoneIndex = (ushort)fshp.boneIndx;
Shape.MaterialIndex = (ushort)fshp.MaterialIndex;
Shape.VertexBufferIndex = (ushort)fshp.VertexBufferIndex;
Shape.KeyShapes = new List<KeyShape>();
Shape.KeyShapeDict = new ResDict();
Shape.Name = fshp.Text;
Shape.SkinBoneIndices = fshp.GetIndices();
Shape.TargetAttribCount = (byte)fshp.TargetAttribCount;
Shape.SkinBoneIndices = fshp.BoneIndices;
Shape.SubMeshBoundings = new List<Bounding>();
Shape.RadiusArray = new List<float>();
Shape.RadiusArray = fshp.boundingRadius;
Shape.Meshes = new List<Mesh>();
foreach (FSHP.BoundingBox box in fshp.boundingBoxes)
{
Bounding bnd = new Bounding();
bnd.Center = new Syroot.Maths.Vector3F(box.Center.X, box.Center.Y, box.Center.Z);
bnd.Extent = new Syroot.Maths.Vector3F(box.Extend.X, box.Extend.Y, box.Extend.Z);
Shape.SubMeshBoundings.Add(bnd);
}
foreach (FSHP.LOD_Mesh mesh in fshp.lodMeshes)
{
Mesh msh = new Mesh();
msh.MemoryPool = new MemoryPool();
msh.SubMeshes = new List<SubMesh>();
msh.PrimitiveType = (PrimitiveType)mesh.PrimitiveType;
msh.FirstVertex = mesh.FirstVertex;
foreach (FSHP.LOD_Mesh.SubMesh sub in mesh.subMeshes)
{
SubMesh subMesh = new SubMesh();
subMesh.Offset = sub.offset;
subMesh.Count = (uint)mesh.faces.Count;
msh.SubMeshes.Add(subMesh);
}
IList<uint> faceList = new List<uint>();
foreach (int f in mesh.faces)
{
faceList.Add((uint)f);
}
if (faceList.Count > 65000)
{
MessageBox.Show($"Warning! Your poly count for a single mesh {fshp.Text} is pretty high! ({faceList.Count})." +
$" You may want to split this!");
msh.SetIndices(faceList, IndexFormat.UInt32);
}
else
msh.SetIndices(faceList, IndexFormat.UInt16);
Shape.Meshes.Add(msh);
break;
}
return Shape;
}
public static void ReadShapesVertices(FSHP fshp, Shape shp, VertexBuffer vertexBuffer, FMDL model)
{
fshp.boundingBoxes.Clear();
fshp.boundingRadius.Clear();
fshp.BoneIndices.Clear();
foreach (Bounding bnd in shp.SubMeshBoundings)
{
FSHP. BoundingBox box = new FSHP.BoundingBox();
box.Center = new Vector3(bnd.Center.X, bnd.Center.Y, bnd.Center.Z);
box.Extend = new Vector3(bnd.Extent.X, bnd.Extent.Y, bnd.Extent.Z);
fshp. boundingBoxes.Add(box);
}
foreach (float rad in shp.RadiusArray)
{
fshp.boundingRadius.Add(rad);
}
fshp.VertexBufferIndex = shp.VertexBufferIndex;
fshp.Shape = shp;
fshp.VertexBuffer = vertexBuffer;
fshp.VertexSkinCount = shp.VertexSkinCount;
fshp.boneIndx = shp.BoneIndex;
fshp.Text = shp.Name;
fshp.TargetAttribCount = shp.TargetAttribCount;
fshp.MaterialIndex = shp.MaterialIndex;
if (shp.SkinBoneIndices != null)
{
foreach (ushort bn in shp.SkinBoneIndices)
fshp.BoneIndices.Add(bn);
}
ReadMeshes(fshp, shp);
ReadVertexBuffer(fshp, vertexBuffer, model);
}
private static void ReadMeshes(FSHP fshp, Shape shp)
{
fshp.lodMeshes.Clear();
foreach (Mesh msh in shp.Meshes)
{
uint FaceCount = msh.IndexCount;
uint[] indicesArray = msh.GetIndices().ToArray();
FSHP.LOD_Mesh lod = new FSHP.LOD_Mesh();
foreach (SubMesh subMsh in msh.SubMeshes)
{
FSHP.LOD_Mesh.SubMesh sub = new FSHP.LOD_Mesh.SubMesh();
sub.size = subMsh.Count;
sub.offset = subMsh.Offset;
lod.subMeshes.Add(sub);
}
lod.IndexFormat = (STIndexFormat)msh.IndexFormat;
lod.PrimitiveType = (STPolygonType)msh.PrimitiveType;
lod.FirstVertex = msh.FirstVertex;
for (int face = 0; face < FaceCount; face++)
lod.faces.Add((int)indicesArray[face] + (int)msh.FirstVertex);
fshp.lodMeshes.Add(lod);
}
}
private static void ReadVertexBuffer(FSHP fshp, VertexBuffer vtx, FMDL model)
{
fshp.vertices.Clear();
fshp.vertexAttributes.Clear();
//Create a buffer instance which stores all the buffer data
VertexBufferHelper helper = new VertexBufferHelper(vtx);
//Set each array first from the lib if exist. Then add the data all in one loop
Syroot.Maths.Vector4F[] vec4Positions = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4Normals = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4uv0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4uv1 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4uv2 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4c0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4t0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4b0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4w0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4i0 = new Syroot.Maths.Vector4F[0];
//For shape morphing
Syroot.Maths.Vector4F[] vec4Positions1 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4Positions2 = new Syroot.Maths.Vector4F[0];
foreach (VertexAttrib att in vtx.Attributes)
{
FSHP.VertexAttribute attr = new FSHP.VertexAttribute();
attr.Name = att.Name;
attr.Format = att.Format;
if (att.Name == "_p0")
vec4Positions = AttributeData(att, helper, "_p0");
if (att.Name == "_n0")
vec4Normals = AttributeData(att, helper, "_n0");
if (att.Name == "_u0")
vec4uv0 = AttributeData(att, helper, "_u0");
if (att.Name == "_u1")
vec4uv1 = AttributeData(att, helper, "_u1");
if (att.Name == "_u2")
vec4uv2 = AttributeData(att, helper, "_u2");
if (att.Name == "_c0")
vec4c0 = AttributeData(att, helper, "_c0");
if (att.Name == "_t0")
vec4t0 = AttributeData(att, helper, "_t0");
if (att.Name == "_b0")
vec4b0 = AttributeData(att, helper, "_b0");
if (att.Name == "_w0")
vec4w0 = AttributeData(att, helper, "_w0");
if (att.Name == "_i0")
vec4i0 = AttributeData(att, helper, "_i0");
if (att.Name == "_p1")
vec4Positions1 = AttributeData(att, helper, "_p1");
if (att.Name == "_p2")
vec4Positions2 = AttributeData(att, helper, "_p2");
fshp.vertexAttributes.Add(attr);
}
for (int i = 0; i < vec4Positions.Length; i++)
{
Vertex v = new Vertex();
if (vec4Positions.Length > 0)
v.pos = new Vector3(vec4Positions[i].X, vec4Positions[i].Y, vec4Positions[i].Z);
if (vec4Positions1.Length > 0)
v.pos1 = new Vector3(vec4Positions1[i].X, vec4Positions1[i].Y, vec4Positions1[i].Z);
if (vec4Positions2.Length > 0)
v.pos2 = new Vector3(vec4Positions2[i].X, vec4Positions2[i].Y, vec4Positions2[i].Z);
if (vec4Normals.Length > 0)
v.nrm = new Vector3(vec4Normals[i].X, vec4Normals[i].Y, vec4Normals[i].Z);
if (vec4uv0.Length > 0)
v.uv0 = new Vector2(vec4uv0[i].X, vec4uv0[i].Y);
if (vec4uv1.Length > 0)
v.uv1 = new Vector2(vec4uv1[i].X, vec4uv1[i].Y);
if (vec4uv2.Length > 0)
v.uv2 = new Vector2(vec4uv2[i].X, vec4uv2[i].Y);
if (vec4w0.Length > 0)
{
v.boneWeights.Add(vec4w0[i].X);
v.boneWeights.Add(vec4w0[i].Y);
v.boneWeights.Add(vec4w0[i].Z);
v.boneWeights.Add(vec4w0[i].W);
}
if (vec4i0.Length > 0)
{
v.boneIds.Add((int)vec4i0[i].X);
v.boneIds.Add((int)vec4i0[i].Y);
v.boneIds.Add((int)vec4i0[i].Z);
v.boneIds.Add((int)vec4i0[i].W);
}
if (vec4t0.Length > 0)
v.tan = new Vector4(vec4t0[i].X, vec4t0[i].Y, vec4t0[i].Z, vec4t0[i].W);
if (vec4b0.Length > 0)
v.bitan = new Vector4(vec4b0[i].X, vec4b0[i].Y, vec4b0[i].Z, vec4b0[i].W);
if (vec4c0.Length > 0)
v.col = new Vector4(vec4c0[i].X, vec4c0[i].Y, vec4c0[i].Z, vec4c0[i].W);
if (fshp.VertexSkinCount == 1)
{
Matrix4 sb = model.Skeleton.bones[model.Skeleton.Node_Array[v.boneIds[0]]].transform;
v.pos = Vector3.TransformPosition(v.pos, sb);
v.nrm = Vector3.TransformNormal(v.nrm, sb);
}
if (fshp.VertexSkinCount == 0)
{
Matrix4 NoBindFix = model.Skeleton.bones[fshp.boneIndx].transform;
v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
}
fshp.vertices.Add(v);
}
}
private static Syroot.Maths.Vector4F[] AttributeData(VertexAttrib att, VertexBufferHelper helper, string attName)
{
VertexBufferHelperAttrib attd = helper[attName];
return attd.Data;
}
public static SkeletalAnim SetSkeletalAniamtion(FSKA anim)
{
SkeletalAnim animation = new SkeletalAnim();
animation.Name = anim.Text;
animation.FrameCount = anim.FrameCount;
animation.FlagsAnimSettings = SkeletalAnimFlags.Looping;
animation.FlagsRotate = SkeletalAnimFlagsRotate.EulerXYZ;
animation.FlagsScale = SkeletalAnimFlagsScale.Maya;
animation.BindIndices = new ushort[anim.Bones.Count];
animation.BindSkeleton = new Skeleton();
animation.BakedSize = 0;
animation.BoneAnims = new List<BoneAnim>();
animation.UserDataDict = new ResDict();
animation.UserDatas = new List<UserData>();
foreach (var bone in anim.Bones)
animation.BoneAnims.Add(createBoneAnim(bone, anim));
return animation;
}
private static BoneAnim createBoneAnim(Animation.KeyNode bone, FSKA anim)
{
BoneAnim boneAnim = new BoneAnim();
boneAnim.Name = bone.Name;
var posx = bone.XPOS.GetValue(0);
var posy = bone.YPOS.GetValue(0);
var posz = bone.ZPOS.GetValue(0);
var scax = bone.XSCA.GetValue(0);
var scay = bone.YSCA.GetValue(0);
var scaz = bone.ZSCA.GetValue(0);
var rotx = bone.XROT.GetValue(0);
var roty = bone.YROT.GetValue(0);
var rotz = bone.ZROT.GetValue(0);
var rotw = bone.WROT.GetValue(0);
BoneAnimData boneBaseData = new BoneAnimData();
boneBaseData.Translate = new Syroot.Maths.Vector3F(posx, posy, posz);
boneBaseData.Scale = new Syroot.Maths.Vector3F(scax, scay, scaz);
boneBaseData.Rotate = new Syroot.Maths.Vector4F(rotx, roty, rotz, rotw);
boneAnim.BaseData = boneBaseData;
boneAnim.BeginBaseTranslate = 0;
boneAnim.BeginRotate = 0;
boneAnim.BeginTranslate = 0;
boneAnim.Curves = new List<AnimCurve>();
boneAnim.FlagsBase = BoneAnimFlagsBase.Translate | BoneAnimFlagsBase.Scale | BoneAnimFlagsBase.Rotate;
boneAnim.FlagsTransform = BoneAnimFlagsTransform.Identity;
if (bone.XPOS.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.TranslateX;
boneAnim.Curves.Add(SetAnimationCurve(bone.XPOS));
}
if (bone.YPOS.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.TranslateY;
boneAnim.Curves.Add(SetAnimationCurve(bone.YPOS));
}
if (bone.ZPOS.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.TranslateZ;
boneAnim.Curves.Add(SetAnimationCurve(bone.ZPOS));
}
if (bone.XSCA.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.ScaleX;
boneAnim.Curves.Add(SetAnimationCurve(bone.XSCA));
}
if (bone.YSCA.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.ScaleY;
boneAnim.Curves.Add(SetAnimationCurve(bone.YSCA));
}
if (bone.ZSCA.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.ScaleZ;
boneAnim.Curves.Add(SetAnimationCurve(bone.ZSCA));
}
if (bone.XROT.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.RotateX;
boneAnim.Curves.Add(SetAnimationCurve(bone.XROT));
}
if (bone.YROT.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.RotateY;
boneAnim.Curves.Add(SetAnimationCurve(bone.YROT));
}
if (bone.ZROT.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.RotateZ;
boneAnim.Curves.Add(SetAnimationCurve(bone.ZROT));
}
if (bone.WROT.HasAnimation())
{
boneAnim.FlagsCurve |= BoneAnimFlagsCurve.RotateW;
boneAnim.Curves.Add(SetAnimationCurve(bone.WROT));
}
return boneAnim;
}
private static AnimCurve SetAnimationCurve(Animation.KeyGroup keyGroup)
{
AnimCurve curve = new AnimCurve();
curve.Frames = new float[(int)keyGroup.Keys.Count];
curve.FrameType = AnimCurveFrameType.Single;
curve.KeyType = AnimCurveKeyType.Single;
curve.EndFrame = keyGroup.FrameCount;
curve.AnimDataOffset = 0;
curve.Delta = 0;
curve.Scale = 1;
curve.StartFrame = 0;
curve.Offset = 0;
var frame = keyGroup.GetKeyFrame(0);
int valuesLength = 1;
if (frame.InterType == Animation.InterpolationType.HERMITE)
{
curve.CurveType = AnimCurveType.Cubic;
curve.Keys = new float[keyGroup.Keys.Count, 4];
for (int k = 0; k < keyGroup.Keys.Count; k++)
{
float value = keyGroup.GetValue(keyGroup.Keys[k].Frame);
curve.Keys[k, 0] = value;
curve.Keys[k, 1] = 0;
curve.Keys[k, 2] = 0;
curve.Keys[k, 3] = 0;
curve.Frames[k] = keyGroup.Keys[k].Frame;
}
}
if (frame.InterType == Animation.InterpolationType.LINEAR)
{
curve.CurveType = AnimCurveType.Linear;
curve.Keys = new float[keyGroup.Keys.Count, 2];
}
if (frame.InterType == Animation.InterpolationType.STEP)
{
curve.CurveType = AnimCurveType.StepInt;
curve.Keys = new float[keyGroup.Keys.Count, 1];
}
if (frame.InterType == Animation.InterpolationType.STEPBOOL)
{
curve.CurveType = AnimCurveType.StepBool;
curve.Keys = new float[keyGroup.Keys.Count, 1];
}
return curve;
}
public static void ReadSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton)
{
if (skeleton.MatrixToBoneList == null)
skeleton.MatrixToBoneList = new List<ushort>();
RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count];
int nodes = 0;
foreach (ushort node in skeleton.MatrixToBoneList)
{
RenderableSkeleton.Node_Array[nodes] = node;
nodes++;
}
foreach (Bone bone in skeleton.Bones)
{
BfresBone STBone = new BfresBone(RenderableSkeleton);
ReadBone(STBone, bone);
RenderableSkeleton.bones.Add(STBone);
}
RenderableSkeleton.update();
RenderableSkeleton.reset();
// foreach (var bone in RenderableSkeleton.bones)
// if (bone.Parent == null)
// skl.Nodes.Add(bone);
Runtime.abstractGlDrawables.Add(RenderableSkeleton);
}
public static void ReadBone(this BfresBone bone, Bone bn)
{
bone.Bone = bn;
bone.Text = bn.Name;
bone.BillboardIndex = bn.BillboardIndex;
bone.parentIndex = bn.ParentIndex;
bone.scale = new float[3];
bone.rotation = new float[4];
bone.position = new float[3];
if (bn.FlagsRotation == BoneFlagsRotation.Quaternion)
bone.boneRotationType = 1;
else
bone.boneRotationType = 0;
bone.scale[0] = bn.Scale.X;
bone.scale[1] = bn.Scale.Y;
bone.scale[2] = bn.Scale.Z;
bone.rotation[0] = bn.Rotation.X;
bone.rotation[1] = bn.Rotation.Y;
bone.rotation[2] = bn.Rotation.Z;
bone.rotation[3] = bn.Rotation.W;
bone.position[0] = bn.Position.X;
bone.position[1] = bn.Position.Y;
bone.position[2] = bn.Position.Z;
}
public static void SetShape(this FSHP s, Shape shp)
{
shp.Name = s.Text;
shp.MaterialIndex = (ushort)s.MaterialIndex;
shp.BoneIndex = (ushort)s.boneIndx;
}
public static void CreateNewMaterial(string Name)
{
FMAT mat = new FMAT();
mat.Text = Name;
mat.Material = new Material();
SetMaterial(mat, mat.Material);
}
public static void SetMaterial(this FMAT m, Material mat)
{
mat.Name = m.Text;
if (m.Enabled)
mat.Flags = MaterialFlags.Visible;
else
mat.Flags = MaterialFlags.None;
if (mat.ShaderParamData == null)
mat.ShaderParamData = new byte[0];
byte[] ParamData = WriteShaderParams(m, mat);
if (ParamData.Length != mat.ShaderParamData.Length)
throw new Exception("Param size mis match!");
else
mat.ShaderParamData = ParamData;
WriteRenderInfo(m, mat);
WriteTextureRefs(m, mat);
WriteShaderAssign(m.shaderassign, mat);
}
public static void ReadMaterial(this FMAT m, Material mat)
{
if (mat.Flags == MaterialFlags.Visible)
m.Enabled = true;
else
m.Enabled = false;
m.ReadRenderInfo(mat);
m.ReadShaderAssign(mat);
m.SetActiveGame();
m.ReadShaderParams(mat);
m.Material = mat;
m.ReadTextureRefs(mat);
}
public static void ReadTextureRefs(this FMAT m, Material mat)
{
m.TextureMaps.Clear();
int AlbedoCount = 0;
int id = 0;
string TextureName = "";
if (mat.TextureRefs == null)
mat.TextureRefs = new List<string>();
foreach (string tex in mat.TextureRefs)
{
TextureName = tex;
MatTexture texture = new MatTexture();
texture.wrapModeS = (int)mat.Samplers[id].WrapModeU;
texture.wrapModeT = (int)mat.Samplers[id].WrapModeV;
texture.wrapModeW = (int)mat.Samplers[id].WrapModeW;
texture.SamplerName = mat.SamplerDict.GetKey(id);
bool IsAlbedo = Misc.HackyTextureList.Any(TextureName.Contains);
if (Runtime.activeGame == Runtime.ActiveGame.MK8D)
{
if (texture.SamplerName == "_a0")
{
if (AlbedoCount == 0)
{
m.HasDiffuseMap = true;
AlbedoCount++;
texture.hash = 0;
texture.Type = MatTexture.TextureType.Diffuse;
}
}
if (texture.SamplerName == "_n0")
{
texture.hash = 1;
m.HasNormalMap = true;
texture.Type = MatTexture.TextureType.Normal;
}
if (texture.SamplerName == "_e0")
{
texture.hash = 8;
m.HasEmissionMap = true;
texture.Type = MatTexture.TextureType.Emission;
}
if (texture.SamplerName == "_s0")
{
texture.hash = 4;
m.HasSpecularMap = true;
texture.Type = MatTexture.TextureType.Specular;
}
if (texture.SamplerName == "_x0")
{
texture.hash = 6;
m.HasSphereMap = true;
texture.Type = MatTexture.TextureType.SphereMap;
}
if (texture.SamplerName == "_b0")
{
texture.hash = 2;
m.HasShadowMap = true;
texture.Type = MatTexture.TextureType.Shadow;
}
if (texture.SamplerName == "_b1")
{
texture.hash = 3;
m.HasLightMap = true;
texture.Type = MatTexture.TextureType.Light;
}
}
else if (Runtime.activeGame == Runtime.ActiveGame.SMO)
{
if (texture.SamplerName == "_a0")
{
if (AlbedoCount == 0)
{
m.HasDiffuseMap = true;
AlbedoCount++;
texture.hash = 0;
texture.Type = MatTexture.TextureType.Diffuse;
}
}
if (texture.SamplerName == "_n0")
{
texture.hash = 1;
m.HasNormalMap = true;
texture.Type = MatTexture.TextureType.Normal;
}
if (texture.SamplerName == "_e0")
{
texture.hash = 8;
m.HasEmissionMap = true;
texture.Type = MatTexture.TextureType.Emission;
}
if (TextureName.Contains("mtl"))
{
texture.hash = 16;
m.HasMetalnessMap = true;
texture.Type = MatTexture.TextureType.Metalness;
}
else if (TextureName.Contains("rgh"))
{
texture.Type = MatTexture.TextureType.Roughness;
texture.hash = 18;
m.HasRoughnessMap = true;
}
else if (TextureName.Contains("sss"))
{
texture.Type = MatTexture.TextureType.SubSurfaceScattering;
texture.hash = 19;
m.HasSubSurfaceScatteringMap = true;
}
}
else
{
//This works decently for now. I tried samplers but Kirby Star Allies doesn't map with samplers properly?
if (IsAlbedo)
{
if (AlbedoCount == 0)
{
m.HasDiffuseMap = true;
AlbedoCount++;
texture.hash = 0;
texture.Type = MatTexture.TextureType.Diffuse;
}
if (AlbedoCount == 1)
{
// poly.material.HasDiffuseLayer = true;
// texture.hash = 19;
// texture.Type = MatTexture.TextureType.DiffuseLayer2;
}
}
else if (TextureName.Contains("Nrm") || TextureName.Contains("Norm") || TextureName.Contains("norm") || TextureName.Contains("nrm"))
{
texture.hash = 1;
m.HasNormalMap = true;
texture.Type = MatTexture.TextureType.Normal;
}
else if (TextureName.Contains("Emm"))
{
texture.hash = 8;
m.HasEmissionMap = true;
texture.Type = MatTexture.TextureType.Emission;
}
else if (TextureName.Contains("Spm"))
{
texture.hash = 4;
m.HasSpecularMap = true;
texture.Type = MatTexture.TextureType.Specular;
}
else if (TextureName.Contains("b00"))
{
texture.hash = 2;
m.HasShadowMap = true;
texture.Type = MatTexture.TextureType.Shadow;
}
else if (TextureName.Contains("Moc") || TextureName.Contains("AO"))
{
texture.hash = 2;
m.HasAmbientOcclusionMap = true;
texture.Type = MatTexture.TextureType.AO;
}
else if (TextureName.Contains("b01"))
{
texture.hash = 3;
m.HasLightMap = true;
texture.Type = MatTexture.TextureType.Light;
}
else if (TextureName.Contains("MRA")) //Metalness, Roughness, and Cavity Map in one
{
texture.hash = 17;
m.HasRoughnessMap = true;
texture.Type = MatTexture.TextureType.MRA;
}
else if (TextureName.Contains("mtl"))
{
texture.hash = 16;
m.HasMetalnessMap = true;
texture.Type = MatTexture.TextureType.Metalness;
}
else if (TextureName.Contains("rgh"))
{
texture.Type = MatTexture.TextureType.Roughness;
texture.hash = 18;
m.HasRoughnessMap = true;
}
else if (TextureName.Contains("sss"))
{
texture.Type = MatTexture.TextureType.SubSurfaceScattering;
texture.hash = 19;
m.HasSubSurfaceScatteringMap = true;
}
}
texture.Name = TextureName;
m.TextureMaps.Add(texture);
id++;
}
}
public static void ReadShaderParams(this FMAT m, Material mat)
{
m.matparam.Clear();
if (mat.ShaderParamData == null)
return;
using (FileReader reader = new FileReader(new System.IO.MemoryStream(mat.ShaderParamData)))
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
foreach (ShaderParam param in mat.ShaderParams)
{
BfresShaderParam shaderParam = new BfresShaderParam();
shaderParam.Type = param.Type;
shaderParam.Name = param.Name;
reader.Seek(param.DataOffset, System.IO.SeekOrigin.Begin);
shaderParam.ReadValue(reader, (int)param.DataSize);
m.matparam.Add(param.Name, shaderParam);
}
reader.Close();
}
}
public static byte[] WriteShaderParams(this FMAT m, Material mat)
{
mat.ShaderParams = new List<ShaderParam>();
System.IO.MemoryStream mem = new System.IO.MemoryStream();
using (FileWriter writer = new FileWriter(mem))
{
uint Offset = 0;
int index = 0;
writer.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian;
foreach (BfresShaderParam shaderParam in m.matparam.Values)
{
ShaderParam param = new ShaderParam();
param.Name = shaderParam.Name;
param.Type = shaderParam.Type;
param.DataOffset = (ushort)Offset;
param.DependedIndex = (ushort)index;
param.DependIndex = (ushort)index;
writer.Seek(param.DataOffset, System.IO.SeekOrigin.Begin);
shaderParam.WriteValue(writer);
Offset += param.DataSize;
mat.ShaderParams.Add(param);
index++;
}
writer.Close();
}
return mem.ToArray();
}
public static void ReadRenderInfo(this FMAT m, Material mat)
{
m.renderinfo.Clear();
foreach (RenderInfo rnd in mat.RenderInfos)
{
BfresRenderInfo r = new BfresRenderInfo();
r.Name = rnd.Name;
r.Type = rnd.Type;
switch (rnd.Type)
{
case RenderInfoType.Int32: r.ValueInt = rnd.GetValueInt32s(); break;
case RenderInfoType.Single: r.ValueFloat = rnd.GetValueSingles(); break;
case RenderInfoType.String: r.ValueString = rnd.GetValueStrings(); break;
}
m.renderinfo.Add(r);
}
}
public static void WriteTextureRefs(this FMAT m, Material mat)
{
mat.TextureRefs = new List<string>();
mat.TextureRefs.Clear();
foreach (var textu in m.TextureMaps)
mat.TextureRefs.Add(textu.Name);
}
public static void WriteRenderInfo(this FMAT m, Material mat)
{
if (mat.RenderInfos == null)
mat.RenderInfos = new List<RenderInfo>();
mat.RenderInfos.Clear();
foreach (BfresRenderInfo rnd in m.renderinfo)
{
RenderInfo r = new RenderInfo();
r.Name = rnd.Name;
switch (rnd.Type)
{
case RenderInfoType.Int32: r.SetValue(rnd.ValueInt); break;
case RenderInfoType.Single: r.SetValue(rnd.ValueFloat); break;
case RenderInfoType.String: r.SetValue(rnd.ValueString); break;
}
mat.RenderInfos.Add(r);
}
}
public static void ReadShaderAssign(this FMAT m, Material mat)
{
m.shaderassign = new FMAT.ShaderAssign();
if (mat.ShaderAssign == null)
mat.ShaderAssign = new ShaderAssign();
if (mat.ShaderAssign.ShaderOptions == null)
mat.ShaderAssign.ShaderOptions = new List<string>();
if (mat.ShaderAssign.AttribAssigns == null)
mat.ShaderAssign.AttribAssigns = new List<string>();
if (mat.ShaderAssign.SamplerAssigns == null)
mat.ShaderAssign.SamplerAssigns = new List<string>();
m.shaderassign.options.Clear();
m.shaderassign.samplers.Clear();
m.shaderassign.attributes.Clear();
m.shaderassign = new FMAT.ShaderAssign();
m.shaderassign.ShaderArchive = mat.ShaderAssign.ShaderArchiveName;
m.shaderassign.ShaderModel = mat.ShaderAssign.ShadingModelName;
for (int op = 0; op < mat.ShaderAssign.ShaderOptions.Count; op++)
m.shaderassign.options.Add(mat.ShaderAssign.ShaderOptionDict.GetKey(op), mat.ShaderAssign.ShaderOptions[op]);
if (mat.ShaderAssign.SamplerAssigns != null)
{
for (int op = 0; op < mat.ShaderAssign.SamplerAssigns.Count; op++)
m.shaderassign.samplers.Add(mat.ShaderAssign.SamplerAssignDict.GetKey(op), mat.ShaderAssign.SamplerAssigns[op]);
}
if (mat.ShaderAssign.AttribAssigns != null)
{
for (int op = 0; op < mat.ShaderAssign.AttribAssigns.Count; op++)
m.shaderassign.attributes.Add(mat.ShaderAssign.AttribAssignDict.GetKey(op), mat.ShaderAssign.AttribAssigns[op]);
}
}
public static void WriteShaderAssign(this FMAT.ShaderAssign shd, Material mat)
{
mat.ShaderAssign = new ShaderAssign();
mat.ShaderAssign.ShaderOptionDict = new ResDict();
mat.ShaderAssign.SamplerAssignDict = new ResDict();
mat.ShaderAssign.AttribAssignDict = new ResDict();
mat.ShaderAssign.ShaderOptions = new List<string>();
mat.ShaderAssign.AttribAssigns = new List<string>();
mat.ShaderAssign.SamplerAssigns = new List<string>();
mat.ShaderAssign.ShaderArchiveName = shd.ShaderArchive;
mat.ShaderAssign.ShadingModelName = shd.ShaderModel;
foreach (var option in shd.options)
{
mat.ShaderAssign.ShaderOptionDict.Add(option.Key);
mat.ShaderAssign.ShaderOptions.Add(option.Value);
}
foreach (var samp in shd.samplers)
{
mat.ShaderAssign.SamplerAssignDict.Add(samp.Key);
mat.ShaderAssign.SamplerAssigns.Add(samp.Value);
}
foreach (var att in shd.attributes)
{
mat.ShaderAssign.AttribAssignDict.Add(att.Key);
mat.ShaderAssign.AttribAssigns.Add(att.Value);
}
}
public static void WriteExternalFiles(ResFile resFile, TreeNode EditorRoot)
{
resFile.ExternalFiles.Clear();
if (EditorRoot.Nodes.ContainsKey("EXT"))
{
foreach (TreeNode node in EditorRoot.Nodes["EXT"].Nodes)
{
ExternalFile ext = new ExternalFile();
if (node is BNTX)
ext.Data = ((BNTX)node).Save();
else if (node is BfshaFileData)
ext.Data = ((BfshaFileData)node).Data;
else
ext.Data = ((ExternalFileData)node).Data;
resFile.ExternalFiles.Add(ext);
}
}
}
}
}

View File

@ -1,938 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Syroot.NintenTools.Bfres;
using Syroot.NintenTools.Bfres.Helpers;
using Syroot.NintenTools.Bfres.GX2;
using System.Windows.Forms;
using Bfres.Structs;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using OpenTK;
using ResNSW = Syroot.NintenTools.NSW.Bfres;
namespace FirstPlugin
{
public static class BfresWiiU
{
public static Model SetModel(FMDL fmdl)
{
Model model = new Model();
model.Name = fmdl.Text;
model.Path = "";
model.Shapes = new ResDict<Shape>();
model.VertexBuffers = new List<VertexBuffer>();
model.Materials = new ResDict<Material>();
model.UserData = new ResDict<UserData>();
model.Skeleton = new Skeleton();
model.Skeleton = fmdl.Skeleton.node.SkeletonU;
int i = 0;
var duplicates = fmdl.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c);
foreach (var shape in duplicates)
shape.Text += i++;
foreach (FSHP shape in fmdl.shapes)
{
BFRES.CheckMissingTextures(shape);
SetShape(shape, shape.ShapeU);
model.Shapes.Add(shape.Text, shape.ShapeU);
model.VertexBuffers.Add(shape.VertexBufferU);
shape.ShapeU.VertexBufferIndex = (ushort)(model.VertexBuffers.Count - 1);
// BFRES.SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape);
}
foreach (FMAT mat in fmdl.materials.Values)
{
SetMaterial(mat, mat.MaterialU);
model.Materials.Add(mat.Text, mat.MaterialU);
}
return model;
}
public static void Read(BFRESRender renderer, ResFile resFile, TreeNode ResFileNode)
{
int CurMdl = 0;
foreach (Model mdl in resFile.Models.Values)
{
FMDL model = new FMDL();
model.Text = mdl.Name;
model.Skeleton = new FSKL(mdl.Skeleton);
model.Nodes.Add(model.Skeleton.node);
model.Skeleton.reset();
model.Skeleton.update();
model.Skeleton.node.BFRESRender = renderer;
model.ModelU = mdl;
foreach (Material mat in mdl.Materials.Values)
{
FMAT FMAT = new FMAT();
FMAT.Text = mat.Name;
FMAT.ReadMaterial(mat);
model.Nodes[1].Nodes.Add(FMAT);
model.materials.Add(FMAT.Text, FMAT);
}
foreach (Shape shp in mdl.Shapes.Values)
{
VertexBuffer vertexBuffer = mdl.VertexBuffers[shp.VertexBufferIndex];
Material material = mdl.Materials[shp.MaterialIndex];
FSHP mesh = new FSHP();
mesh.ModelIndex = CurMdl;
ReadShapesVertices(mesh, shp, vertexBuffer, model);
mesh.MaterialIndex = shp.MaterialIndex;
model.Nodes[0].Nodes.Add(mesh);
model.shapes.Add(mesh);
}
ResFileNode.Nodes[0].Nodes.Add(model);
renderer.models.Add(model);
CurMdl++;
}
}
public static void ReadShapesVertices(FSHP fshp, Shape shp, VertexBuffer vertexBuffer, FMDL model)
{
fshp.boundingBoxes.Clear();
fshp.boundingRadius.Clear();
fshp.BoneIndices.Clear();
foreach (Bounding bnd in shp.SubMeshBoundings)
{
FSHP.BoundingBox box = new FSHP.BoundingBox();
box.Center = new Vector3(bnd.Center.X, bnd.Center.Y, bnd.Center.Z);
box.Extend = new Vector3(bnd.Extent.X, bnd.Extent.Y, bnd.Extent.Z);
fshp.boundingBoxes.Add(box);
}
foreach (float rad in shp.RadiusArray)
{
fshp.boundingRadius.Add(rad);
}
fshp.VertexBufferIndex = shp.VertexBufferIndex;
fshp.ShapeU = shp;
fshp.VertexBufferU = vertexBuffer;
fshp.VertexSkinCount = shp.VertexSkinCount;
fshp.boneIndx = shp.BoneIndex;
fshp.Text = shp.Name;
fshp.TargetAttribCount = shp.TargetAttribCount;
fshp.MaterialIndex = shp.MaterialIndex;
if (shp.SkinBoneIndices != null)
{
foreach (ushort bn in shp.SkinBoneIndices)
fshp.BoneIndices.Add(bn);
}
ReadMeshes(fshp, shp);
ReadVertexBuffer(fshp, vertexBuffer, model);
}
private static void ReadMeshes(FSHP fshp, Shape shp)
{
fshp.lodMeshes.Clear();
foreach (Mesh msh in shp.Meshes)
{
uint FaceCount = msh.IndexCount;
uint[] indicesArray = msh.GetIndices().ToArray();
FSHP.LOD_Mesh lod = new FSHP.LOD_Mesh();
foreach (SubMesh subMsh in msh.SubMeshes)
{
FSHP.LOD_Mesh.SubMesh sub = new FSHP.LOD_Mesh.SubMesh();
sub.size = subMsh.Count;
sub.offset = subMsh.Offset;
lod.subMeshes.Add(sub);
}
lod.IndexFormat = (STIndexFormat)msh.IndexFormat;
lod.PrimitiveType = (STPolygonType)msh.PrimitiveType;
lod.FirstVertex = msh.FirstVertex;
for (int face = 0; face < FaceCount; face++)
lod.faces.Add((int)indicesArray[face] + (int)msh.FirstVertex);
fshp.lodMeshes.Add(lod);
}
}
private static void ReadVertexBuffer(FSHP fshp, VertexBuffer vtx, FMDL model)
{
fshp.vertices.Clear();
fshp.vertexAttributes.Clear();
//Create a buffer instance which stores all the buffer data
VertexBufferHelper helper = new VertexBufferHelper(vtx, Syroot.BinaryData.ByteOrder.BigEndian);
//Set each array first from the lib if exist. Then add the data all in one loop
Syroot.Maths.Vector4F[] vec4Positions = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4Normals = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4uv0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4uv1 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4uv2 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4c0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4t0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4b0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4w0 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4i0 = new Syroot.Maths.Vector4F[0];
//For shape morphing
Syroot.Maths.Vector4F[] vec4Positions1 = new Syroot.Maths.Vector4F[0];
Syroot.Maths.Vector4F[] vec4Positions2 = new Syroot.Maths.Vector4F[0];
foreach (VertexAttrib att in vtx.Attributes.Values)
{
FSHP.VertexAttribute attr = new FSHP.VertexAttribute();
attr.Name = att.Name;
attr.Format = attr.GetTypeWiiU(att.Format);
if (att.Name == "_p0")
vec4Positions = AttributeData(att, helper, "_p0");
if (att.Name == "_n0")
vec4Normals = AttributeData(att, helper, "_n0");
if (att.Name == "_u0")
vec4uv0 = AttributeData(att, helper, "_u0");
if (att.Name == "_u1")
vec4uv1 = AttributeData(att, helper, "_u1");
if (att.Name == "_u2")
vec4uv2 = AttributeData(att, helper, "_u2");
if (att.Name == "_c0")
vec4c0 = AttributeData(att, helper, "_c0");
if (att.Name == "_t0")
vec4t0 = AttributeData(att, helper, "_t0");
if (att.Name == "_b0")
vec4b0 = AttributeData(att, helper, "_b0");
if (att.Name == "_w0")
vec4w0 = AttributeData(att, helper, "_w0");
if (att.Name == "_i0")
vec4i0 = AttributeData(att, helper, "_i0");
if (att.Name == "_p1")
vec4Positions1 = AttributeData(att, helper, "_p1");
if (att.Name == "_p2")
vec4Positions2 = AttributeData(att, helper, "_p2");
fshp.vertexAttributes.Add(attr);
}
for (int i = 0; i < vec4Positions.Length; i++)
{
Vertex v = new Vertex();
if (vec4Positions.Length > 0)
v.pos = new Vector3(vec4Positions[i].X, vec4Positions[i].Y, vec4Positions[i].Z);
if (vec4Positions1.Length > 0)
v.pos1 = new Vector3(vec4Positions1[i].X, vec4Positions1[i].Y, vec4Positions1[i].Z);
if (vec4Positions2.Length > 0)
v.pos2 = new Vector3(vec4Positions2[i].X, vec4Positions2[i].Y, vec4Positions2[i].Z);
if (vec4Normals.Length > 0)
v.nrm = new Vector3(vec4Normals[i].X, vec4Normals[i].Y, vec4Normals[i].Z);
if (vec4uv0.Length > 0)
v.uv0 = new Vector2(vec4uv0[i].X, vec4uv0[i].Y);
if (vec4uv1.Length > 0)
v.uv1 = new Vector2(vec4uv1[i].X, vec4uv1[i].Y);
if (vec4uv2.Length > 0)
v.uv2 = new Vector2(vec4uv2[i].X, vec4uv2[i].Y);
if (vec4w0.Length > 0)
{
v.boneWeights.Add(vec4w0[i].X);
v.boneWeights.Add(vec4w0[i].Y);
v.boneWeights.Add(vec4w0[i].Z);
v.boneWeights.Add(vec4w0[i].W);
}
if (vec4i0.Length > 0)
{
v.boneIds.Add((int)vec4i0[i].X);
v.boneIds.Add((int)vec4i0[i].Y);
v.boneIds.Add((int)vec4i0[i].Z);
v.boneIds.Add((int)vec4i0[i].W);
}
if (vec4t0.Length > 0)
v.tan = new Vector4(vec4t0[i].X, vec4t0[i].Y, vec4t0[i].Z, vec4t0[i].W);
if (vec4b0.Length > 0)
v.bitan = new Vector4(vec4b0[i].X, vec4b0[i].Y, vec4b0[i].Z, vec4b0[i].W);
if (vec4c0.Length > 0)
v.col = new Vector4(vec4c0[i].X, vec4c0[i].Y, vec4c0[i].Z, vec4c0[i].W);
if (fshp.VertexSkinCount == 1)
{
// Matrix4 sb = model.Skeleton.bones[model.Skeleton.Node_Array[v.boneIds[0]]].transform;
// v.pos = Vector3.TransformPosition(v.pos, sb);
// v.nrm = Vector3.TransformNormal(v.nrm, sb);
}
if (fshp.VertexSkinCount == 0)
{
// Matrix4 NoBindFix = model.Skeleton.bones[fshp.boneIndx].transform;
// v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
// v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
}
fshp.vertices.Add(v);
}
}
private static Syroot.Maths.Vector4F[] AttributeData(VertexAttrib att, VertexBufferHelper helper, string attName)
{
VertexBufferHelperAttrib attd = helper[attName];
return attd.Data;
}
public static void SetSkeleton(this TreeNodeCustom skl, Skeleton skeleton, FSKL RenderableSkeleton)
{
if (skeleton.MatrixToBoneList == null)
skeleton.MatrixToBoneList = new List<ushort>();
RenderableSkeleton.Node_Array = new int[skeleton.MatrixToBoneList.Count];
int nodes = 0;
foreach (ushort node in skeleton.MatrixToBoneList)
{
RenderableSkeleton.Node_Array[nodes] = node;
nodes++;
}
for (int i = 0; i < skeleton.Bones.Count; i++)
{
if (skeleton.InverseModelMatrices == null)
break;
if (i < skeleton.InverseModelMatrices.Count)
RenderableSkeleton.matrices.Add(Utils.ToMat3x4(skeleton.InverseModelMatrices[i]));
else
RenderableSkeleton.matrices.Add(Matrix3x4.Zero);
}
foreach (Bone bone in skeleton.Bones.Values)
{
BfresBone STBone = new BfresBone(RenderableSkeleton);
SetBone(STBone, bone);
STBone.BFRESRender = RenderableSkeleton.node.BFRESRender; //to update viewport on bone edits
RenderableSkeleton.bones.Add(STBone);
if (bone.InverseMatrix != null)
RenderableSkeleton.matrices.Add(Utils.ToMat3x4(bone.InverseMatrix));
}
RenderableSkeleton.update();
RenderableSkeleton.reset();
// foreach (var bone in RenderableSkeleton.bones)
// if (bone.Parent == null)
// skl.Nodes.Add(bone);
Runtime.abstractGlDrawables.Add(RenderableSkeleton);
}
public static void SetBone(this BfresBone bone, Bone bn)
{
bone.BoneU = bn;
bone.Text = bn.Name;
bone.BillboardIndex = bn.BillboardIndex;
bone.parentIndex = bn.ParentIndex;
bone.scale = new float[3];
bone.rotation = new float[4];
bone.position = new float[3];
if (bn.FlagsRotation == BoneFlagsRotation.Quaternion)
bone.boneRotationType = 1;
else
bone.boneRotationType = 0;
bone.scale[0] = bn.Scale.X;
bone.scale[1] = bn.Scale.Y;
bone.scale[2] = bn.Scale.Z;
bone.rotation[0] = bn.Rotation.X;
bone.rotation[1] = bn.Rotation.Y;
bone.rotation[2] = bn.Rotation.Z;
bone.rotation[3] = bn.Rotation.W;
bone.position[0] = bn.Position.X;
bone.position[1] = bn.Position.Y;
bone.position[2] = bn.Position.Z;
}
public static void SetShape(this FSHP s, Shape shp)
{
shp.Name = s.Text;
shp.MaterialIndex = (ushort)s.MaterialIndex;
}
public static void CreateNewMaterial(string Name)
{
FMAT mat = new FMAT();
mat.Text = Name;
mat.MaterialU = new Material();
SetMaterial(mat, mat.MaterialU);
}
public static void SetMaterial(this FMAT m, Material mat)
{
mat.Name = m.Text;
if (m.Enabled)
mat.Flags = MaterialFlags.Visible;
else
mat.Flags = MaterialFlags.None;
if (mat.ShaderParamData == null)
mat.ShaderParamData = new byte[0];
byte[] ParamData = WriteShaderParams(m, mat);
if (ParamData.Length != mat.ShaderParamData.Length)
throw new Exception("Param size mis match!");
else
mat.ShaderParamData = ParamData;
WriteRenderInfo(m, mat);
WriteTextureRefs(m, mat);
WriteShaderAssign(m.shaderassign, mat);
}
public static void ReadMaterial(this FMAT m, Material mat)
{
if (mat.Flags == MaterialFlags.Visible)
m.Enabled = true;
else
m.Enabled = false;
m.ReadRenderInfo(mat);
m.ReadShaderAssign(mat);
m.SetActiveGame();
m.ReadShaderParams(mat);
m.MaterialU = mat;
m.ReadTextureRefs(mat);
m.ReadRenderState(mat.RenderState);
}
public static void ReadRenderState(this FMAT m, RenderState renderState)
{
}
public static void ReadTextureRefs(this FMAT m, Material mat)
{
m.TextureMaps.Clear();
int AlbedoCount = 0;
int id = 0;
string TextureName = "";
if (mat.TextureRefs == null)
mat.TextureRefs = new List<TextureRef>();
foreach (var tex in mat.TextureRefs)
{
TextureName = tex.Name;
MatTexture texture = new MatTexture();
texture.wrapModeS = (int)mat.Samplers[id].TexSampler.ClampX;
texture.wrapModeT = (int)mat.Samplers[id].TexSampler.ClampY;
texture.wrapModeW = (int)mat.Samplers[id].TexSampler.ClampZ;
mat.Samplers.TryGetKey(mat.Samplers[id], out texture.SamplerName);
if (mat.Samplers[id].TexSampler.MinFilter == GX2TexXYFilterType.Bilinear)
{
texture.magFilter = 0;
}
if (mat.Samplers[id].TexSampler.MagFilter == GX2TexXYFilterType.Bilinear)
{
}
if (Runtime.activeGame == Runtime.ActiveGame.MK8D)
{
if (texture.SamplerName == "_a0")
{
if (AlbedoCount == 0)
{
m.HasDiffuseMap = true;
AlbedoCount++;
texture.hash = 0;
texture.Type = MatTexture.TextureType.Diffuse;
}
}
if (texture.SamplerName == "_n0")
{
texture.hash = 1;
m.HasNormalMap = true;
texture.Type = MatTexture.TextureType.Normal;
}
if (texture.SamplerName == "_e0")
{
texture.hash = 8;
m.HasEmissionMap = true;
texture.Type = MatTexture.TextureType.Emission;
}
if (texture.SamplerName == "_s0")
{
texture.hash = 4;
m.HasSpecularMap = true;
texture.Type = MatTexture.TextureType.Specular;
}
if (texture.SamplerName == "_x0")
{
texture.hash = 6;
m.HasSphereMap = true;
texture.Type = MatTexture.TextureType.SphereMap;
}
if (texture.SamplerName == "_b0")
{
texture.hash = 2;
m.HasShadowMap = true;
texture.Type = MatTexture.TextureType.Shadow;
}
if (texture.SamplerName == "_b1")
{
texture.hash = 3;
m.HasLightMap = true;
texture.Type = MatTexture.TextureType.Light;
}
}
else if (Runtime.activeGame == Runtime.ActiveGame.SMO)
{
if (texture.SamplerName == "_a0")
{
if (AlbedoCount == 0)
{
m.HasDiffuseMap = true;
AlbedoCount++;
texture.hash = 0;
texture.Type = MatTexture.TextureType.Diffuse;
}
}
if (texture.SamplerName == "_n0")
{
texture.hash = 1;
m.HasNormalMap = true;
texture.Type = MatTexture.TextureType.Normal;
}
if (texture.SamplerName == "_e0")
{
texture.hash = 8;
m.HasEmissionMap = true;
texture.Type = MatTexture.TextureType.Emission;
}
if (TextureName.Contains("mtl"))
{
texture.hash = 16;
m.HasMetalnessMap = true;
texture.Type = MatTexture.TextureType.Metalness;
}
else if (TextureName.Contains("rgh"))
{
texture.Type = MatTexture.TextureType.Roughness;
texture.hash = 18;
m.HasRoughnessMap = true;
}
else if (TextureName.Contains("sss"))
{
texture.Type = MatTexture.TextureType.SubSurfaceScattering;
texture.hash = 19;
m.HasSubSurfaceScatteringMap = true;
}
}
else
{
if (texture.SamplerName == "_a0")
{
m.HasDiffuseMap = true;
AlbedoCount++;
texture.hash = 0;
texture.Type = MatTexture.TextureType.Diffuse;
}
if (texture.SamplerName == "_n0")
{
texture.hash = 1;
m.HasNormalMap = true;
texture.Type = MatTexture.TextureType.Normal;
}
else if (TextureName.Contains("Emm"))
{
texture.hash = 8;
m.HasEmissionMap = true;
texture.Type = MatTexture.TextureType.Emission;
}
else if (TextureName.Contains("Spm"))
{
texture.hash = 4;
m.HasSpecularMap = true;
texture.Type = MatTexture.TextureType.Specular;
}
else if (TextureName.Contains("b00"))
{
texture.hash = 2;
m.HasShadowMap = true;
texture.Type = MatTexture.TextureType.Shadow;
}
else if (TextureName.Contains("Moc") || TextureName.Contains("AO"))
{
texture.hash = 2;
m.HasAmbientOcclusionMap = true;
texture.Type = MatTexture.TextureType.AO;
}
else if (TextureName.Contains("b01"))
{
texture.hash = 3;
m.HasLightMap = true;
texture.Type = MatTexture.TextureType.Light;
}
else if (TextureName.Contains("MRA")) //Metalness, Roughness, and Cavity Map in one
{
texture.hash = 17;
m.HasRoughnessMap = true;
texture.Type = MatTexture.TextureType.MRA;
}
else if (TextureName.Contains("mtl"))
{
texture.hash = 16;
m.HasMetalnessMap = true;
texture.Type = MatTexture.TextureType.Metalness;
}
else if (TextureName.Contains("rgh"))
{
texture.Type = MatTexture.TextureType.Roughness;
texture.hash = 18;
m.HasRoughnessMap = true;
}
else if (TextureName.Contains("sss"))
{
texture.Type = MatTexture.TextureType.SubSurfaceScattering;
texture.hash = 19;
m.HasSubSurfaceScatteringMap = true;
}
}
texture.Name = TextureName;
m.TextureMaps.Add(texture);
id++;
}
}
public static void ReadShaderParams(this FMAT m, Material mat)
{
m.matparam.Clear();
if (mat.ShaderParamData == null)
return;
using (FileReader reader = new FileReader(new System.IO.MemoryStream(mat.ShaderParamData)))
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
foreach (ShaderParam param in mat.ShaderParams.Values)
{
BfresShaderParam shaderParam = new BfresShaderParam();
shaderParam.Type = shaderParam.GetTypeWiiU(param.Type);
shaderParam.Name = param.Name;
reader.Seek(param.DataOffset, System.IO.SeekOrigin.Begin);
Console.WriteLine(shaderParam.Name + " " + shaderParam.Type);
shaderParam.ReadValue(reader, (int)param.DataSize);
m.matparam.Add(param.Name, shaderParam);
}
reader.Close();
}
}
public static byte[] WriteShaderParams(this FMAT m, Material mat)
{
mat.ShaderParams = new ResDict<ShaderParam>();
System.IO.MemoryStream mem = new System.IO.MemoryStream();
using (FileWriter writer = new FileWriter(mem))
{
uint Offset = 0;
int index = 0;
writer.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
foreach (BfresShaderParam shaderParam in m.matparam.Values)
{
ShaderParam param = new ShaderParam();
param.Name = shaderParam.Name;
param.Type = shaderParam.SetTypeWiiU(shaderParam.Type);
param.DataOffset = (ushort)Offset;
param.DependedIndex = (ushort)index;
param.DependIndex = (ushort)index;
writer.Seek(param.DataOffset, System.IO.SeekOrigin.Begin);
shaderParam.WriteValue(writer);
Offset += param.DataSize;
mat.ShaderParams.Add(param.Name, param);
index++;
}
writer.Close();
}
return mem.ToArray();
}
public static void ReadRenderInfo(this FMAT m, Material mat)
{
m.renderinfo.Clear();
foreach (RenderInfo rnd in mat.RenderInfos.Values)
{
BfresRenderInfo r = new BfresRenderInfo();
r.Name = rnd.Name;
r.Type = r.GetTypeWiiU(rnd.Type);
switch (rnd.Type)
{
case RenderInfoType.Int32: r.ValueInt = rnd.GetValueInt32s(); break;
case RenderInfoType.Single: r.ValueFloat = rnd.GetValueSingles(); break;
case RenderInfoType.String: r.ValueString = rnd.GetValueStrings(); break;
}
m.renderinfo.Add(r);
}
}
public static void WriteTextureRefs(this FMAT m, Material mat)
{
mat.TextureRefs = new List<TextureRef>();
mat.TextureRefs.Clear();
foreach (var textu in m.TextureMaps)
{
TextureRef texref = new TextureRef();
texref.Name = textu.Name;
Texture texMapped = new Texture();
m.GetResFileU().Textures.TryGetValue(textu.Name, out texMapped);
texref.Texture = texMapped;
mat.TextureRefs.Add(texref);
}
}
public static void WriteRenderInfo(this FMAT m, Material mat)
{
if (mat.RenderInfos == null)
mat.RenderInfos = new ResDict<RenderInfo>();
mat.RenderInfos.Clear();
foreach (BfresRenderInfo rnd in m.renderinfo)
{
RenderInfo r = new RenderInfo();
r.Name = rnd.Name;
switch (rnd.Type)
{
case ResNSW.RenderInfoType.Int32: r.SetValue(rnd.ValueInt); break;
case ResNSW.RenderInfoType.Single: r.SetValue(rnd.ValueFloat); break;
case ResNSW.RenderInfoType.String: r.SetValue(rnd.ValueString); break;
}
mat.RenderInfos.Add(r.Name, r);
}
}
public static void ReadShaderAssign(this FMAT m, Material mat)
{
m.shaderassign = new FMAT.ShaderAssign();
if (mat.ShaderAssign == null)
mat.ShaderAssign = new ShaderAssign();
if (mat.ShaderAssign.ShaderOptions == null)
mat.ShaderAssign.ShaderOptions = new ResDict<ResString>();
if (mat.ShaderAssign.AttribAssigns == null)
mat.ShaderAssign.AttribAssigns = new ResDict<ResString>();
if (mat.ShaderAssign.SamplerAssigns == null)
mat.ShaderAssign.SamplerAssigns = new ResDict<ResString>();
m.shaderassign.options.Clear();
m.shaderassign.samplers.Clear();
m.shaderassign.attributes.Clear();
m.shaderassign = new FMAT.ShaderAssign();
m.shaderassign.ShaderArchive = mat.ShaderAssign.ShaderArchiveName;
m.shaderassign.ShaderModel = mat.ShaderAssign.ShadingModelName;
foreach (var op in mat.ShaderAssign.ShaderOptions)
m.shaderassign.options.Add(op.Key, op.Value);
if (mat.ShaderAssign.SamplerAssigns != null)
{
foreach (var op in mat.ShaderAssign.SamplerAssigns)
m.shaderassign.samplers.Add(op.Key, op.Value);
}
if (mat.ShaderAssign.AttribAssigns != null)
{
foreach (var op in mat.ShaderAssign.AttribAssigns)
m.shaderassign.attributes.Add(op.Key, op.Value);
}
}
public static void WriteShaderAssign(this FMAT.ShaderAssign shd, Material mat)
{
mat.ShaderAssign = new ShaderAssign();
mat.ShaderAssign.ShaderOptions = new ResDict<ResString>();
mat.ShaderAssign.AttribAssigns = new ResDict<ResString>();
mat.ShaderAssign.SamplerAssigns = new ResDict<ResString>();
mat.ShaderAssign.ShaderArchiveName = shd.ShaderArchive;
mat.ShaderAssign.ShadingModelName = shd.ShaderModel;
foreach (var option in shd.options)
mat.ShaderAssign.ShaderOptions.Add(option.Key, option.Value);
foreach (var samp in shd.samplers)
mat.ShaderAssign.SamplerAssigns.Add(samp.Key, samp.Value);
foreach (var att in shd.attributes)
mat.ShaderAssign.AttribAssigns.Add(att.Key, att.Value);
}
public static Shape SaveShape(FSHP fshp)
{
Shape ShapeU = new Shape();
ShapeU.VertexSkinCount = (byte)fshp.VertexSkinCount;
ShapeU.Flags = ShapeFlags.HasVertexBuffer;
ShapeU.BoneIndex = (ushort)fshp.boneIndx;
ShapeU.MaterialIndex = (ushort)fshp.MaterialIndex;
ShapeU.VertexBufferIndex = (ushort)fshp.VertexBufferIndex;
ShapeU.KeyShapes = new ResDict<KeyShape>();
ShapeU.Name = fshp.Text;
ShapeU.SkinBoneIndices = fshp.GetIndices();
ShapeU.TargetAttribCount = (byte)fshp.TargetAttribCount;
ShapeU.SkinBoneIndices = fshp.BoneIndices;
ShapeU.SubMeshBoundings = new List<Bounding>();
ShapeU.RadiusArray = new List<float>();
ShapeU.RadiusArray = fshp.boundingRadius;
ShapeU.Meshes = new List<Mesh>();
foreach (FSHP.BoundingBox box in fshp.boundingBoxes)
{
Bounding bnd = new Bounding();
bnd.Center = new Syroot.Maths.Vector3F(box.Center.X, box.Center.Y, box.Center.Z);
bnd.Extent = new Syroot.Maths.Vector3F(box.Extend.X, box.Extend.Y, box.Extend.Z);
ShapeU.SubMeshBoundings.Add(bnd);
}
foreach (FSHP.LOD_Mesh mesh in fshp.lodMeshes)
{
Mesh msh = new Mesh();
msh.SubMeshes = new List<SubMesh>();
msh.PrimitiveType = (GX2PrimitiveType)mesh.PrimitiveType;
msh.FirstVertex = mesh.FirstVertex;
foreach (FSHP.LOD_Mesh.SubMesh sub in mesh.subMeshes)
{
SubMesh subMesh = new SubMesh();
subMesh.Offset = sub.offset;
subMesh.Count = (uint)mesh.faces.Count;
msh.SubMeshes.Add(subMesh);
}
IList<uint> faceList = new List<uint>();
msh.IndexBuffer = new Syroot.NintenTools.Bfres.Buffer();
foreach (int f in mesh.faces)
{
faceList.Add((uint)f);
}
if (faceList.Count > 65000)
{
MessageBox.Show($"Warning! Your poly count for a single mesh {fshp.Text} is pretty high! ({faceList.Count})." +
$" You may want to split this!");
msh.SetIndices(faceList, GX2IndexFormat.UInt32);
}
else
msh.SetIndices(faceList, GX2IndexFormat.UInt16);
ShapeU.Meshes.Add(msh);
break;
}
return ShapeU;
}
public static void SaveVertexBuffer(FSHP fshp)
{
VertexBuffer buffer = new VertexBuffer();
buffer.Attributes = new ResDict<VertexAttrib>();
VertexBufferHelper helper = new VertexBufferHelper(buffer, Syroot.BinaryData.ByteOrder.BigEndian);
List<VertexBufferHelperAttrib> atrib = new List<VertexBufferHelperAttrib>();
fshp.UpdateVertices();
foreach (FSHP.VertexAttribute att in fshp.vertexAttributes)
{
if (att.Name == "_p0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.verts.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_n0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.norms.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_u0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.uv0.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_u1")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.uv1.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_u2")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.uv2.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_w0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.weights.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_i0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.boneInd.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_b0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.bitans.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_t0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.tans.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
if (att.Name == "_c0")
{
VertexBufferHelperAttrib vert = new VertexBufferHelperAttrib();
vert.Name = att.Name;
vert.Data = fshp.colors.ToArray();
vert.Format = att.SetTypeWiiU(att.Format);
atrib.Add(vert);
}
}
if (atrib.Count == 0)
{
MessageBox.Show("Attributes are empty?");
return;
}
helper.Attributes = atrib;
fshp.VertexBufferU = helper.ToVertexBuffer();
}
public static void WriteExternalFiles(ResFile resFile, TreeNode EditorRoot)
{
resFile.ExternalFiles.Clear();
if (EditorRoot.Nodes.ContainsKey("EXT"))
{
foreach (TreeNode node in EditorRoot.Nodes["EXT"].Nodes)
{
ExternalFile ext = new ExternalFile();
if (node is BNTX)
ext.Data = ((BNTX)node).Save();
else if (node is BfshaFileData)
ext.Data = ((BfshaFileData)node).Data;
else
ext.Data = ((ExternalFileData)node).Data;
resFile.ExternalFiles.Add(node.Text, ext);
}
}
}
}
}

View File

@ -1,244 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
namespace FirstPlugin
{
public class BFSAR : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "Cafe Sound Archive" };
public string[] Extension { get; set; } = new string[] { "*.bfsar" };
public string Magic { get; set; } = "FSAR";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
FSAR bfsar = new FSAR();
bfsar.Read(new FileReader(new MemoryStream(Data)));
Text = FileName;
Nodes.Add("Audio List");
Nodes.Add("Audio Set List");
Nodes.Add("Bank List");
Nodes.Add("Group List");
Nodes.Add("Players List");
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
private static uint FileSizeOffset;
public class FSAR
{
public uint Size;
private ushort BOM;
public ushort HeaderSize;
public uint Version;
public ushort SectionCount;
public STRG STRG;
public INFO INFO;
public FILE FILE;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "FSAR")
throw new Exception($"Invalid signature {Signature}! Expected FSAR.");
BOM = reader.ReadUInt16();
HeaderSize = reader.ReadUInt16();
Version = reader.ReadUInt32();
uint FileSize = reader.ReadUInt32();
SectionCount = reader.ReadUInt16();
ushort padding = reader.ReadUInt16();
for (int i = 0; i < SectionCount; i++)
{
ushort Identifier = reader.ReadUInt16();
ushort padding2 = reader.ReadUInt16();
uint Offset = reader.ReadUInt32();
uint Size = reader.ReadUInt32();
if (Identifier == 8192)
{
reader.Seek(Offset, SeekOrigin.Begin);
STRG = new STRG();
STRG.Read(reader);
}
if (Identifier == 8193)
{
reader.Seek(Offset, SeekOrigin.Begin);
INFO = new INFO();
INFO.Read(reader);
}
if (Identifier == 8194)
{
reader.Seek(Offset, SeekOrigin.Begin);
FILE = new FILE();
FILE.Read(reader, INFO);
}
}
}
public void Write(FileWriter writer)
{
writer.WriteSignature("FSAR");
writer.Write(BOM);
writer.Write(HeaderSize);
writer.Write(Version);
FileSizeOffset = (uint)writer.Position;
writer.Write(SectionCount);
writer.Write((ushort)0);
for (int i = 0; i < SectionCount; i++)
{
}
}
}
public class INFO
{
public uint SectionSize;
public AudioList audioList;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "INFO")
throw new Exception($"Invalid signature {Signature}! Expected INFO.");
SectionSize = reader.ReadUInt32();
long Pos = reader.Position;
uint AudioListOffset = reader.ReadUInt32();
if (AudioListOffset != 0)
{
using (reader.TemporarySeek(AudioListOffset + Pos, SeekOrigin.Begin))
{
audioList = new AudioList();
audioList.Read(reader);
}
}
}
}
public class AudioList
{
public void Read(FileReader reader)
{
}
}
public class FILE
{
public uint SectionSize;
public void Read(FileReader reader, INFO INFO)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "FILE")
throw new Exception($"Invalid signature {Signature}! Expected FILE.");
SectionSize = reader.ReadUInt32();
byte[] padding = reader.ReadBytes(0x18);
}
}
public class STRG
{
public uint Size;
private uint BOM;
public uint SectionSize;
public uint Version;
public ushort SectionCount;
public StringTable stringTable;
public LookupTable lookupTable;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "STRG")
throw new Exception($"Invalid signature {Signature}! Expected STRG.");
SectionSize = reader.ReadUInt32();
long pos = reader.Position;
uint unk = reader.ReadUInt32();
uint Stringtableoffset = reader.ReadUInt32();
uint unk2 = reader.ReadUInt32();
uint LookupTableOffset = reader.ReadUInt32();
if (Stringtableoffset != 0)
{
reader.Seek(Stringtableoffset + pos, SeekOrigin.Begin);
stringTable = new StringTable();
stringTable.Read(reader);
}
if (LookupTableOffset != 0)
{
reader.Seek(LookupTableOffset + pos, SeekOrigin.Begin);
lookupTable = new LookupTable();
lookupTable.Read(reader);
}
}
public class StringTable
{
public List<string> Names = new List<string>();
public void Read(FileReader reader)
{
long pos = reader.Position;
uint Count = reader.ReadUInt32();
for (int i = 0; i < Count; i++)
{
uint unk = reader.ReadUInt32();
uint Offset = reader.ReadUInt32();
uint Size = reader.ReadUInt32();
using (reader.TemporarySeek(Offset + pos, SeekOrigin.Begin))
{
Names.Add(reader.ReadString(Syroot.BinaryData.BinaryStringFormat.ZeroTerminated));
}
}
foreach (string name in Names)
Console.WriteLine(name);
}
}
public class LookupTable
{
public void Read(FileReader reader)
{
}
}
}
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FirstPlugin
{
public class BFSHA
{
}
}

View File

@ -1,187 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using ByamlExt.Byaml;
using ByamlExt;
using WeifenLuo.WinFormsUI.Docking;
namespace FirstPlugin
{
public class BYAML : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "BYAML" };
public string[] Extension { get; set; } = new string[] { "*.byaml", "*.byml", "*.bprm", "*.sbyml" };
public string Magic { get; set; } = "YB";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
class EditableNode
{
public Type type { get => Node[Index].GetType(); }
dynamic Node;
dynamic Index;
public dynamic Get() => Node[Index];
public void Set(dynamic value) => Node[Index] = value;
public string GetTreeViewString()
{
if (Index is int)
return Node[Index].ToString();
else
return Index + " : " + Node[Index].ToString();
}
public EditableNode(dynamic _node, dynamic _index)
{
Node = _node;
Index = _index;
}
}
MemoryStream mem;
public void Load()
{
IsActive = false;
CanSave = false;
mem = new MemoryStream(Data);
ByamlViewer.OpenByml(mem, FileName);
// BymlFileData byamlFile = ByamlFile.LoadN(new System.IO.MemoryStream(Data), false, Syroot.BinaryData.ByteOrder.LittleEndian);
// LoadDockedEditor(byamlFile);
}
public void Unload()
{
}
public TreeNode LoadByamlNodes(dynamic root)
{
TreeNode node = new TreeNode();
if (root == null)
return node;
if (root is Dictionary<string, dynamic>)
{
parseDictNode(root, node.Nodes);
}
else if (root is List<dynamic>)
{
if (((List<dynamic>)root).Count == 0)
{
MessageBox.Show("This byml is empty");
}
parseArrayNode(root, node.Nodes);
}
else if (root is List<ByamlPathPoint>)
{
}
return node;
}
void parseArrayNode(IList<dynamic> list, TreeNodeCollection addto)
{
int index = 0;
foreach (dynamic k in list)
{
if (k is IDictionary<string, dynamic>)
{
TreeNode current = addto.Add("<Dictionary>");
current.Tag = ((IDictionary<string, dynamic>)k);
current.Nodes.Add("✯✯dummy✯✯");
}
else if (k is IList<dynamic>)
{
TreeNode current = addto.Add("<Array>");
current.Tag = ((IList<dynamic>)k);
current.Nodes.Add("✯✯dummy✯✯");
}
else if (k is IList<ByamlPathPoint>)
{
TreeNode current = addto.Add("<PathPointArray>");
current.Tag = ((IList<ByamlPathPoint>)k);
parsePathPointArray(k, current.Nodes);
}
else
{
var n = addto.Add(k == null ? "<NULL>" : k.ToString());
if (k != null) n.Tag = new EditableNode(list, index);
}
index++;
}
}
void parseDictNode(IDictionary<string, dynamic> node, TreeNodeCollection addto)
{
foreach (string k in node.Keys)
{
TreeNode current = addto.Add(k);
if (node[k] is IDictionary<string, dynamic>)
{
current.Text += " : <Dictionary>";
current.Tag = node[k];
current.Nodes.Add("✯✯dummy✯✯"); //a text that can't be in a byml
}
else if (node[k] is IList<dynamic>)
{
current.Text += " : <Array>";
current.Tag = ((IList<dynamic>)node[k]);
current.Nodes.Add("✯✯dummy✯✯");
}
else if (node[k] is IList<ByamlPathPoint>)
{
current.Text += " : <PathPointArray>";
current.Tag = ((IList<ByamlPathPoint>)node[k]);
parsePathPointArray(node[k], current.Nodes);
}
else
{
current.Text = current.Text + " : " + (node[k] == null ? "<NULL>" : node[k].ToString());
if (node[k] != null) current.Tag = new EditableNode(node, k);
}
}
}
void parsePathPointArray(IList<ByamlPathPoint> list, TreeNodeCollection addto)
{
int index = 0;
foreach (var k in list)
{
index++;
var n = addto.Add(k == null ? "<NULL>" : k.ToString());
if (k != null) n.Tag = new EditableNode(list, index);
}
}
public byte[] Save()
{
if (mem != null)
return mem.ToArray();
return null;
}
}
}

View File

@ -1,345 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using System.Windows.Forms;
using OpenTK;
namespace FirstPlugin
{
public class CsvModel : IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "CSV Model" };
public string[] Extension { get; set; } = new string[] { "*.csv" };
public string Magic { get; set; } = "";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public List<STGenericObject> objects = new List<STGenericObject>();
public class Model
{
public string Name { get; set; }
public int UVChannelCount { get; set; }
public DataType type;
public DataSubType subType;
public List<string[]> bones = new List<string[]>();
public List<float[]> weights = new List<float[]>();
}
public enum DataType : int
{
vertex = 1,
faces = 2,
bones = 3,
}
public enum DataSubType : int
{
position = 0,
normals = 1,
colors = 2,
uv0 = 3,
uv1 = 4,
uv2 = 5,
uv3 = 6,
}
float X, Y, Z, W;
public void Load()
{
LoadFile(FilePath);
}
public void LoadFile(string FileName, bool IsModel = false)
{
if (!IsModel)
{
MessageBox.Show("Not valid model csv");
return;
}
string line = null;
List<Model> models = new List<Model>();
TextReader csv = new StreamReader(FileName);
Model model = new Model();
STGenericObject STobj = new STGenericObject();
Vertex vtx = new Vertex();
STGenericObject.LOD_Mesh lod = new STGenericObject.LOD_Mesh();
int Index = 0;
int ww = 0;
while (true)
{
line = csv.ReadLine();
if (line != null)
{
if (line.StartsWith("Obj Name"))
{
model = new Model();
STobj = new STGenericObject();
model.Name = line.Split(':')[1].Replace("\n", "");
model.subType = DataSubType.position;
models.Add(model);
STobj.ObjectName = model.Name;
lod = new STGenericObject.LOD_Mesh();
lod.IndexFormat = STIndexFormat.UInt16;
lod.PrimitiveType = STPolygonType.Triangle;
STobj.lodMeshes.Add(lod);
STobj.VertexBufferIndex = Index;
objects.Add(STobj);
Index++;
}
else if (line.StartsWith("tex_Array:"))
{
}
else if (line.StartsWith("Bone_Suport"))
{
}
else if (line.StartsWith("Color_Suport"))
{
}
else if (line.StartsWith("UV_Num:"))
{
int uvCount;
int.TryParse(line.Split(':')[1].Replace("\n", ""), out uvCount);
model.UVChannelCount = uvCount;
}
else if (line.StartsWith("vert_Array"))
{
model.type = DataType.vertex;
}
else if (line.StartsWith("face_Array"))
{
model.type = DataType.faces;
}
else if (line.StartsWith("bone_Array"))
{
model.type = DataType.bones;
}
else
{
string[] values = line.Replace("\n", "").Replace("\r", "").Split(',');
if (model.type == DataType.vertex)
{
switch (model.subType)
{
case DataSubType.position:
vtx = new Vertex();
STobj.vertices.Add(vtx);
STobj.HasPos = true;
float.TryParse(values[0], out X);
float.TryParse(values[1], out Y);
float.TryParse(values[2], out Z);
vtx.pos = new Vector3(X, Y, Z);
model.subType = DataSubType.normals;
break;
case DataSubType.normals:
STobj.HasNrm = true;
float.TryParse(values[0], out X);
float.TryParse(values[1], out Y);
float.TryParse(values[2], out Z);
vtx.nrm = new Vector3(X, Y, Z);
model.subType = DataSubType.colors;
break;
case DataSubType.colors:
STobj.HasVertColors = true;
float.TryParse(values[0], out X);
float.TryParse(values[1], out Y);
float.TryParse(values[2], out Z);
float.TryParse(values[3], out W);
vtx.col = new Vector4(X / 255, Y / 255, Z / 255, W / 255);
model.subType = DataSubType.uv0;
break;
case DataSubType.uv0:
STobj.HasUv0 = true;
float.TryParse(values[0], out X);
float.TryParse(values[1], out Y);
vtx.uv0 = new Vector2(X, Y);
if (model.UVChannelCount == 1)
model.subType = DataSubType.position;
else
model.subType = DataSubType.uv1;
break;
case DataSubType.uv1:
STobj.HasUv1 = true;
float.TryParse(values[0], out X);
float.TryParse(values[1], out Y);
vtx.uv1 = new Vector2(X, Y);
if (model.UVChannelCount == 2)
model.subType = DataSubType.position;
else
model.subType = DataSubType.uv2;
break;
case DataSubType.uv2:
STobj.HasUv2 = true;
float.TryParse(values[0], out X);
float.TryParse(values[1], out Y);
vtx.uv2 = new Vector2(X, Y);
if (model.UVChannelCount == 3)
model.subType = DataSubType.position;
else
model.subType = DataSubType.uv3;
break;
case DataSubType.uv3:
float.TryParse(values[0], out X);
float.TryParse(values[1], out Y);
model.subType = DataSubType.position;
break;
}
}
if (model.type == DataType.faces)
{
int face;
foreach (string v in values)
{
var cleaned = v.Replace(".0", string.Empty);
int.TryParse(cleaned, out face);
lod.faces.Add(face-1);
}
}
if (model.type == DataType.bones)
{
STobj.HasWeights = true;
STobj.HasIndices = true;
Array.Resize(ref values, values.Length - 1);
List<string> bones = new List<string>();
List<float> weights = new List<float>();
int bbs = 0;
foreach (string obj in values)
{
if (bbs == 0)
{
bones.Add(obj);
bbs += 1;
}
else
{
float.TryParse(obj, out X);
weights.Add(X);
bbs = 0;
}
}
STobj.bones.Add(bones.ToArray());
STobj.weightsT.Add(weights.ToArray());
}
}
}
else
break;
}
if (objects[0].weightsT.Count != objects[0].vertices.Count)
throw new Exception("Incorrect vertex amount");
foreach (STGenericObject obj in objects)
{
obj.lodMeshes[0].GenerateSubMesh();
for (int v = 0; v < obj.vertices.Count; v++)
{
foreach (string bn in obj.bones[v])
obj.vertices[v].boneNames.Add(bn);
foreach (float f in obj.weightsT[v])
obj.vertices[v].boneWeights.Add(f);
}
foreach (Vertex v in obj.vertices)
{
if (v.boneNames.Count == 1)
Console.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]}");
if (v.boneNames.Count == 2)
Console.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]} {v.boneNames[1]} {v.boneWeights[1]}");
if (v.boneNames.Count == 3)
Console.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]} {v.boneNames[1]} {v.boneWeights[1]} {v.boneNames[2]} {v.boneWeights[2]}");
if (v.boneNames.Count == 4)
Console.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]} {v.boneNames[1]} {v.boneWeights[1]} {v.boneNames[2]} {v.boneWeights[2]} {v.boneNames[3]} {v.boneWeights[3]}");
}
}
csv.Close();
csv = null;
}
public void Unload()
{
}
public byte[] Save()
{
MemoryStream mem = new MemoryStream();
using (System.IO.StreamWriter file = new System.IO.StreamWriter(mem))
{
foreach (STGenericObject obj in objects)
{
file.WriteLine($"Obj Name:" + obj.ObjectName);
file.WriteLine($"Bone_Suport");
file.WriteLine($"UV_Num:1");
file.WriteLine($"vert_Array");
foreach (Vertex v in obj.vertices)
{
file.WriteLine($"{v.pos.X},{v.pos.Y},{v.pos.Z}");
file.WriteLine($"{v.nrm.X},{v.nrm.Y},{v.nrm.Z}");
file.WriteLine($"{v.col.X * 255},{v.col.Y * 255},{v.col.Z * 255},{v.col.W * 255}");
file.WriteLine($"{v.uv0.X},{v.uv0.Y}");
// file.WriteLine($"{v.uv1.X},{v.uv1.Y}");
}
file.WriteLine($"face_Array");
for (int f = 0; f < obj.faces.Count / 3; f++)
{
file.WriteLine($"{obj.faces[f] + 1},{obj.faces[f++] + 1},{obj.faces[f++] + 1}");
}
file.WriteLine($"bone_Array");
foreach (Vertex v in obj.vertices)
{
if (v.boneNames.Count == 1)
file.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]}");
if (v.boneNames.Count == 2)
file.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]} {v.boneNames[1]} {v.boneWeights[1]}");
if (v.boneNames.Count == 3)
file.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]} {v.boneNames[1]} {v.boneWeights[1]} {v.boneNames[2]} {v.boneWeights[2]}");
if (v.boneNames.Count == 4)
file.WriteLine($"{v.boneNames[0]} {v.boneWeights[0]} {v.boneNames[1]} {v.boneWeights[1]} {v.boneNames[2]} {v.boneWeights[2]} {v.boneNames[3]} {v.boneWeights[3]}");
}
}
file.Close();
}
return mem.ToArray();
}
}
}

View File

@ -1,390 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using System.IO;
using Switch_Toolbox.Library.IO;
namespace FirstPlugin
{
public class GFPAK : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "Graphic Package" };
public string[] Extension { get; set; } = new string[] { "*.gfpak" };
public string Magic { get; set; } = "GFLX";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
IFileInfo = new IFileInfo();
Read(new FileReader(new MemoryStream(Data)));
Text = FileName;
ContextMenu = new ContextMenu();
MenuItem save = new MenuItem("Save");
ContextMenu.MenuItems.Add(save);
save.Click += Save;
MenuItem previewFiles = new MenuItem("Preview Window");
ContextMenu.MenuItems.Add(previewFiles);
previewFiles.Click += PreviewWindow;
}
public void Unload()
{
}
public byte[] Save()
{
MemoryStream mem = new MemoryStream();
Write(new FileWriter(mem));
return mem.ToArray();
}
private void Save(object sender, EventArgs args)
{
List<IFileFormat> formats = new List<IFileFormat>();
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(formats);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName, IFileInfo.Alignment);
}
}
private void PreviewWindow(object sender, EventArgs args)
{
PreviewFormatList previewFormatList = new PreviewFormatList();
if (previewFormatList.ShowDialog() == DialogResult.OK)
{
CallRecursive(TreeView);
PreviewEditor previewWindow = new PreviewEditor();
previewWindow.Show();
}
}
private void CallRecursive(TreeView treeView)
{
// Print each node recursively.
TreeNodeCollection nodes = treeView.Nodes;
foreach (TreeNode n in nodes)
{
PrintRecursive(n);
}
}
private void PrintRecursive(TreeNode treeNode)
{
// Print each node recursively.
foreach (TreeNode tn in treeNode.Nodes)
{
PrintRecursive(tn);
}
}
public ushort BOM;
public uint Version;
public List<FileEntry> files = new List<FileEntry>();
public List<UInt64> hashes = new List<UInt64>();
public List<HashIndex> hashIndices = new List<HashIndex>();
public int version;
public int FolderCount;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(8, Encoding.ASCII);
if (Signature != "GFLXPACK")
throw new Exception($"Invalid signature {Signature}! Expected GFLXPACK.");
version = reader.ReadInt32();
uint padding = reader.ReadUInt32();
uint FileCount = reader.ReadUInt32();
FolderCount = reader.ReadInt32();
ulong FileInfoOffset = reader.ReadUInt64();
ulong hashArrayOffset = reader.ReadUInt64();
ulong hashArrayIndexOffset = reader.ReadUInt64();
reader.Seek((long)hashArrayOffset, SeekOrigin.Begin);
for (int i = 0; i < FileCount; i++)
{
ulong hash = reader.ReadUInt64();
hashes.Add(hash);
}
reader.Seek((long)hashArrayIndexOffset, SeekOrigin.Begin);
for (int i = 0; i < FileCount; i++)
{
HashIndex hashindex = new HashIndex();
hashindex.Read(reader);
hashIndices.Add(hashindex);
}
reader.Seek((long)FileInfoOffset, SeekOrigin.Begin);
for (int i = 0; i < FileCount; i++)
{
FileEntry fileEntry = new FileEntry();
fileEntry.Read(reader);
fileEntry.Text = hashes[i].ToString();
Nodes.Add(fileEntry);
files.Add(fileEntry);
}
}
public void Write(FileWriter writer)
{
writer.WriteSignature("GFLXPACK");
writer.Write(version);
writer.Write(0);
writer.Write(files.Count);
writer.Write(FolderCount);
long FileInfoOffset = writer.Position;
writer.Write(0L);
long HashArrayOffset = writer.Position;
writer.Write(0L);
long HashIndexArrOffset = writer.Position;
writer.Write(0L);
//Now write all sections
writer.WriteUint64Offset(HashArrayOffset);
writer.Write(hashes);
writer.WriteUint64Offset(HashIndexArrOffset);
foreach (var hashIndx in hashIndices)
hashIndx.Write(writer);
writer.WriteUint64Offset(FileInfoOffset);
foreach (var fileTbl in files)
fileTbl.Write(writer);
//Save data blocks
foreach (var fileTbl in files)
{
fileTbl.WriteBlock(writer);
}
}
public class HashIndex
{
public ulong hash;
public int Index;
public uint unkown;
public void Read(FileReader reader)
{
hash = reader.ReadUInt64();
Index = reader.ReadInt32();
unkown = reader.ReadUInt32(); //Always 0xCC?
}
public void Write(FileWriter writer)
{
writer.Write(hash);
writer.Write(Index);
writer.Write(unkown);
}
}
public class FileEntry : TreeNodeCustom
{
public FileEntry()
{
ImageKey = "fileBlank";
SelectedImageKey = "fileBlank";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
}
public uint unkown;
public uint CompressionType;
public byte[] data;
private long DataOffset;
private byte[] CompressedData;
public IFileFormat FileHandler;
public void Read(FileReader reader)
{
unkown = reader.ReadUInt16(); //Usually 9?
CompressionType = reader.ReadUInt16();
uint DecompressedFileSize = reader.ReadUInt32();
uint CompressedFileSize = reader.ReadUInt32();
uint padding = reader.ReadUInt32();
ulong FileOffset = reader.ReadUInt64();
using (reader.TemporarySeek((long)FileOffset, SeekOrigin.Begin))
{
data = reader.ReadBytes((int)CompressedFileSize);
data = STLibraryCompression.Type_LZ4.Decompress(data, 0, (int)CompressedFileSize, (int)DecompressedFileSize);
string ext = SARCExt.SARC.GuessFileExtension(data);
if (ext == ".bntx")
{
ImageKey = "bntx";
SelectedImageKey = "bntx";
}
if (ext == ".byaml")
{
ImageKey = "byaml";
SelectedImageKey = "byaml";
}
if (ext == ".aamp")
{
ImageKey = "aamp";
SelectedImageKey = "aamp";
}
if (ext == ".lua")
{
}
}
}
public void Write(FileWriter writer)
{
if (FileHandler != null && FileHandler.CanSave)
{
data = FileHandler.Save();
}
CompressedData = Compress(data, CompressionType);
writer.Write((ushort)unkown);
writer.Write((ushort)CompressionType);
writer.Write(data.Length);
writer.Write(CompressedData.Length);
writer.Write(0);
DataOffset = writer.Position;
writer.Write(0L);
}
public void WriteBlock(FileWriter writer)
{
writer.WriteUint64Offset(DataOffset);
writer.Write(CompressedData);
}
public static byte[] Compress(byte[] data, uint Type)
{
if (Type == 2)
{
return STLibraryCompression.Type_LZ4.Compress(data);
}
else
throw new Exception("Unkown compression type?");
}
public override void OnClick(TreeView treeview)
{
}
public override void OnMouseLeftClick(TreeView treeView)
{
ReplaceNode(this.Parent, this, OpenFile(Name, data, this));
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.Filter = "All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
File.WriteAllBytes(sfd.FileName, data);
}
}
}
public static TreeNode OpenFile(string FileName, byte[] data, FileEntry fileEntry, bool Compressed = false, CompressionType CompType = 0)
{
Cursor.Current = Cursors.WaitCursor;
FileReader fileReader = new FileReader(data);
string Magic4 = fileReader.ReadMagic(0, 4);
string Magic2 = fileReader.ReadMagic(0, 2);
if (Magic4 == "Yaz0")
{
data = EveryFileExplorer.YAZ0.Decompress(data);
return OpenFile(FileName, data, fileEntry, true, (CompressionType)1);
}
if (Magic4 == "ZLIB")
{
data = FileReader.InflateZLIB(fileReader.getSection(64, data.Length - 64));
return OpenFile(FileName, data, fileEntry, true, (CompressionType)2);
}
fileReader.Dispose();
fileReader.Close();
foreach (IFileFormat fileFormat in FileManager.GetFileFormats())
{
if (fileFormat.Magic == Magic4 || fileFormat.Magic == Magic2)
{
fileFormat.CompressionType = CompType;
fileFormat.FileIsCompressed = Compressed;
fileFormat.Data = data;
fileFormat.Load();
fileFormat.FileName = Path.GetFileName(FileName);
fileFormat.FilePath = FileName;
fileFormat.IFileInfo = new IFileInfo();
fileFormat.IFileInfo.InArchive = true;
if (fileFormat is TreeNode)
{
((TreeNode)fileFormat).Text = fileEntry.Text;
((TreeNode)fileFormat).ImageKey = fileEntry.ImageKey;
((TreeNode)fileFormat).SelectedImageKey = fileEntry.SelectedImageKey;
return (TreeNode)fileFormat;
}
}
if (fileFormat.Magic == string.Empty)
{
foreach (string str3 in fileFormat.Extension)
{
if (str3.Remove(0, 1) == Path.GetExtension(FileName))
{
fileFormat.Data = data;
fileFormat.Load();
fileFormat.FileName = Path.GetFileName(FileName);
fileFormat.FilePath = FileName;
fileFormat.IFileInfo = new IFileInfo();
fileFormat.IFileInfo.InArchive = true;
if (fileFormat is TreeNode)
{
((TreeNode)fileFormat).Text = fileEntry.Text;
((TreeNode)fileFormat).ImageKey = fileEntry.ImageKey;
((TreeNode)fileFormat).SelectedImageKey = fileEntry.SelectedImageKey;
return (TreeNode)fileFormat;
}
}
}
}
}
return (TreeNode)null;
}
public static void ReplaceNode(TreeNode node, TreeNode replaceNode, TreeNode NewNode)
{
if (NewNode == null)
return;
int index = node.Nodes.IndexOf(replaceNode);
node.Nodes.RemoveAt(index);
node.Nodes.Insert(index, NewNode);
}
}
}

View File

@ -1,571 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using SFGraphics.GLObjects.Shaders;
using Smash_Forge.Rendering;
using GL_Core.Interfaces;
using OpenTK.Graphics.OpenGL;
using OpenTK;
using Switch_Toolbox.Library.Rendering;
using WeifenLuo.WinFormsUI.Docking;
using GL_Core;
using System.Drawing;
using Switch_Toolbox.Library.IO;
namespace FirstPlugin
{
public class KCL : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "KCL" };
public string[] Extension { get; set; } = new string[] { "*.kcl" };
public string Magic { get; set; } = "";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
IFileInfo = new IFileInfo();
Text = FileName;
Renderer = new KCLRendering();
Read(Data);
ContextMenu = new ContextMenu();
MenuItem save = new MenuItem("Save");
ContextMenu.MenuItems.Add(save);
save.Click += Save;
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
}
public void Unload()
{
}
public byte[] Save()
{
return Data;
}
public enum GameSet : ushort
{
MarioOdyssey = 0x0,
MarioKart8D = 0x1,
Splatoon2 = 0x2,
}
public enum CollisionType_MarioOdssey : ushort
{
}
public enum CollisionType_MK8D : ushort
{
Road_Default = 0,
Road_Bumpy = 2,
Road_Sand = 4,
Offroad_Sand = 6,
Road_HeavySand = 8,
Road_IcyRoad = 9,
OrangeBooster = 10,
AntiGravityPanel = 11,
Latiku = 16,
Wall5 = 17,
Wall4 = 19,
Wall = 23,
Latiku2 = 28,
Glider = 31,
SidewalkSlope = 32,
Road_Dirt = 33,
Unsolid = 56,
Water = 60,
Road_Stone = 64,
Wall1 = 81,
Wall2 = 84,
FinishLine = 93,
RedFlowerEffect = 95,
Wall3 = 113,
WhiteFlowerEffect = 127,
Road_Metal = 128,
Road_3DS_MP_Piano = 129,
Road_RoyalR_Grass = 134,
TopPillar = 135,
YoshiCuiruit_Grass = 144,
YellowFlowerEffect = 159,
Road_MetalGating = 160,
Road_3DS_MP_Xylophone = 161,
Road_3DS_MP_Vibraphone = 193,
SNES_RR_road = 227,
Offroad_Mud = 230,
Trick = 4096,
BoosterStunt = 4106,
TrickEndOfRamp = 4108,
Trick3 = 4130,
Trick6 = 4160,
Trick4 = 4224,
Trick5 = 8192,
BoostTrick = 8202,
}
public void Save(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.kcl";
sfd.FileName = Text;
sfd.DefaultExt = ".kcl";
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName, IFileInfo.Alignment);
}
}
public void Export(object sender, EventArgs args)
{
if (kcl == null)
return;
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.obj";
sfd.FileName = Text;
sfd.DefaultExt = ".obj";
if (sfd.ShowDialog() == DialogResult.OK)
{
kcl.ToOBJ().toWritableObj().WriteObj(sfd.FileName + ".obj");
}
}
public void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.obj";
if (ofd.ShowDialog() == DialogResult.OK)
{
var mod = EditorCore.Common.OBJ.Read(new MemoryStream(File.ReadAllBytes(ofd.FileName)), null);
if (mod.Faces.Count > 65535)
{
MessageBox.Show("this model has too many faces, only models with less than 65535 triangles can be converted");
return;
}
kcl = MarioKart.MK7.KCL.FromOBJ(mod);
Data = kcl.Write(Syroot.BinaryData.ByteOrder.LittleEndian);
Read(Data);
}
}
KCLRendering Renderer;
public override void OnClick(TreeView treeView)
{
LibraryGUI.Instance.LoadViewport(Viewport.Instance);
Viewport.Instance.gL_ControlModern1.MainDrawable = Renderer;
Renderer.UpdateVertexData();
}
public MarioKart.MK7.KCL kcl = null;
public void Read(byte[] file_data)
{
try
{
kcl = new MarioKart.MK7.KCL(file_data, Syroot.BinaryData.ByteOrder.LittleEndian);
}
catch
{
kcl = new MarioKart.MK7.KCL(file_data, Syroot.BinaryData.ByteOrder.BigEndian);
}
Read(kcl);
Renderer.UpdateVertexData();
}
public void Read(MarioKart.MK7.KCL kcl)
{
Nodes.Clear();
Renderer.models.Clear();
int CurModelIndx = 0;
foreach (MarioKart.MK7.KCL.KCLModel mdl in kcl.Models)
{
KCLModel kclmodel = new KCLModel();
kclmodel.Text = "Model " + CurModelIndx;
int ft = 0;
foreach (var plane in mdl.Planes)
{
var triangle = mdl.GetTriangle(plane);
var normal = triangle.Normal;
var pointA = triangle.PointA;
var pointB = triangle.PointB;
var pointC = triangle.PointC;
Vertex vtx = new Vertex();
Vertex vtx2 = new Vertex();
Vertex vtx3 = new Vertex();
vtx.pos = new Vector3(Vec3D_To_Vec3(pointA));
vtx2.pos = new Vector3(Vec3D_To_Vec3(pointB));
vtx3.pos = new Vector3(Vec3D_To_Vec3(pointC));
vtx.nrm = new Vector3(Vec3D_To_Vec3(normal));
vtx2.nrm = new Vector3(Vec3D_To_Vec3(normal));
vtx3.nrm = new Vector3(Vec3D_To_Vec3(normal));
KCLModel.Face face = new KCLModel.Face();
face.Text = triangle.Collision.ToString();
face.MaterialFlag = triangle.Collision;
var col = MarioKart.MK7.KCLColors.GetMaterialColor(plane.CollisionType);
Vector3 ColorSet = new Vector3(col.R, col.G, col.B);
vtx.col = new Vector4(ColorSet, 1);
vtx2.col = new Vector4(ColorSet, 1);
vtx3.col = new Vector4(ColorSet, 1);
kclmodel.faces.Add(ft);
kclmodel.faces.Add(ft + 1);
kclmodel.faces.Add(ft + 2);
ft += 3;
kclmodel.vertices.Add(vtx);
kclmodel.vertices.Add(vtx2);
kclmodel.vertices.Add(vtx3);
}
Renderer.models.Add(kclmodel);
Nodes.Add(kclmodel);
CurModelIndx++;
}
}
public class KCLRendering : AbstractGlDrawable
{
// gl buffer objects
int vbo_position;
int ibo_elements;
//Set the game's material list
public GameSet GameMaterialSet = GameSet.MarioKart8D;
public List<KCLModel> models = new List<KCLModel>();
public Shader shader = null;
private void GenerateBuffers()
{
GL.GenBuffers(1, out vbo_position);
GL.GenBuffers(1, out ibo_elements);
}
public void Destroy()
{
GL.DeleteBuffer(vbo_position);
GL.DeleteBuffer(ibo_elements);
}
public void UpdateVertexData()
{
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
DisplayVertex[] Vertices;
int[] Faces;
int poffset = 0;
int voffset = 0;
List<DisplayVertex> Vs = new List<DisplayVertex>();
List<int> Ds = new List<int>();
foreach (KCLModel m in models)
{
m.Offset = poffset * 4;
List<DisplayVertex> pv = m.CreateDisplayVertices();
Vs.AddRange(pv);
for (int i = 0; i < m.displayFaceSize; i++)
{
Ds.Add(m.display[i] + voffset);
}
poffset += m.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);
Viewport.Instance.UpdateViewport();
}
string FileName;
public bool EditorIsViewportActive(DockContent dock)
{
if (dock is Viewport)
{
dock.Text = FileName;
((Viewport)dock).gL_ControlModern1.MainDrawable = this;
return true;
}
return false;
}
public override void Prepare(GL_ControlModern control)
{
}
public override void Prepare(GL_ControlLegacy control)
{
}
public override void Draw(GL_ControlLegacy control)
{
}
public override void Draw(GL_ControlModern control)
{
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
if (!buffersWereInitialized)
GenerateBuffers();
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
shader = OpenTKSharedResources.shaders["KCL"];
shader.UseProgram();
shader.EnableVertexAttributes();
SetRenderSettings(shader);
Matrix4 previewScale = Utils.TransformValues(Vector3.Zero, Vector3.Zero, Runtime.previewScale);
Matrix4 camMat = previewScale * control.mtxCam * control.mtxProj;
shader.SetVector3("difLightDirection", Vector3.TransformNormal(new Vector3(0f, 0f, -1f), camMat.Inverted()).Normalized());
shader.SetVector3("difLightColor", new Vector3(1));
shader.SetVector3("ambLightColor", new Vector3(1));
shader.EnableVertexAttributes();
SetRenderSettings(shader);
shader.SetMatrix4x4("mvpMatrix", ref camMat);
foreach (KCLModel mdl in models)
{
DrawModel(mdl, shader);
}
shader.DisableVertexAttributes();
}
private void SetRenderSettings(Shader shader)
{
shader.SetBoolToInt("renderVertColor", Runtime.renderVertColor);
shader.SetInt("renderType", (int)Runtime.viewportShading);
}
private void DrawModel(KCLModel m, Shader shader, bool drawSelection = false)
{
if (m.faces.Count <= 3)
return;
SetVertexAttributes(m, shader);
if (m.Checked)
{
if ((m.IsSelected))
{
DrawModelSelection(m, shader);
}
else
{
if (Runtime.RenderModelWireframe)
{
DrawModelWireframe(m, shader);
}
if (Runtime.RenderModels)
{
GL.DrawElements(PrimitiveType.Triangles, m.displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
}
}
}
}
private static void DrawModelSelection(KCLModel p, Shader shader)
{
//This part needs to be reworked for proper outline. Currently would make model disappear
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
GL.Enable(EnableCap.StencilTest);
// use vertex color for wireframe color
shader.SetInt("colorOverride", 1);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
GL.Enable(EnableCap.LineSmooth);
GL.LineWidth(1.5f);
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
shader.SetInt("colorOverride", 0);
GL.Enable(EnableCap.DepthTest);
}
private void SetVertexAttributes(KCLModel m, Shader shader)
{
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
GL.VertexAttribPointer(shader.GetAttribLocation("vPosition"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 0);
GL.VertexAttribPointer(shader.GetAttribLocation("vNormal"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 12);
GL.VertexAttribPointer(shader.GetAttribLocation("vColor"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 24);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
}
private static void DrawModelWireframe(KCLModel p, Shader shader)
{
// use vertex color for wireframe color
shader.SetInt("colorOverride", 1);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
GL.Enable(EnableCap.LineSmooth);
GL.LineWidth(1.5f);
GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
shader.SetInt("colorOverride", 0);
}
}
//Convert KCL lib vec3 to opentk one so i can use the cross and dot methods
public static Vector3 Vec3D_To_Vec3(System.Windows.Media.Media3D.Vector3D v)
{
return new Vector3((float)v.X, (float)v.Y, (float)v.Z);
}
public struct DisplayVertex
{
// Used for rendering.
public Vector3 pos;
public Vector3 nrm;
public Vector3 col;
public static int Size = 4 * (3 + 3 + 3);
}
public class KCLModel : STGenericObject
{
public KCLModel()
{
ImageKey = "mesh";
SelectedImageKey = "mesh";
Checked = true;
}
public int[] display;
public int Offset; // For Rendering
public int strip = 0x40;
public int displayFaceSize = 0;
public class Face : TreeNode
{
public int MaterialFlag = 0;
}
public List<DisplayVertex> CreateDisplayVertices()
{
// rearrange faces
display = getDisplayFace().ToArray();
List<DisplayVertex> displayVertList = new List<DisplayVertex>();
if (faces.Count <= 3)
return displayVertList;
foreach (Vertex v in vertices)
{
DisplayVertex displayVert = new DisplayVertex()
{
pos = v.pos,
nrm = v.nrm,
col = v.col.Xyz,
};
displayVertList.Add(displayVert);
}
return displayVertList;
}
public List<int> getDisplayFace()
{
if ((strip >> 4) == 4)
{
displayFaceSize = faces.Count;
return faces;
}
else
{
List<int> f = new List<int>();
int startDirection = 1;
int p = 0;
int f1 = faces[p++];
int f2 = faces[p++];
int faceDirection = startDirection;
int f3;
do
{
f3 = faces[p++];
if (f3 == 0xFFFF)
{
f1 = faces[p++];
f2 = faces[p++];
faceDirection = startDirection;
}
else
{
faceDirection *= -1;
if ((f1 != f2) && (f2 != f3) && (f3 != f1))
{
if (faceDirection > 0)
{
f.Add(f3);
f.Add(f2);
f.Add(f1);
}
else
{
f.Add(f2);
f.Add(f3);
f.Add(f1);
}
}
f1 = f2;
f2 = f3;
}
} while (p < faces.Count);
displayFaceSize = f.Count;
return f;
}
}
}
}
}

View File

@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
namespace FirstPlugin
{
public class MSBT : IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "AAMP" };
public string[] Extension { get; set; } = new string[] { "*.aamp" };
public string Magic { get; set; } = "MsgStdBn";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
}
}

View File

@ -1,401 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Switch_Toolbox;
using System.Windows.Forms;
using SARCExt;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
namespace FirstPlugin
{
public class SARC : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "*SARC", "*SARC", "*SARC" };
public string[] Extension { get; set; } = new string[] { "*.szs", "*.pack", "*.sarc" };
public string Magic { get; set; } = "SARC";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public SarcData sarcData;
public string SarcHash;
public void Load()
{
IsActive = true;
CanSave = true;
UseEditMenu = true;
var SzsFiles = SARCExt.SARC.UnpackRamN(Data);
sarcData = new SarcData();
sarcData.HashOnly = false;
sarcData.Files = SzsFiles.Files;
sarcData.endianness = GetByteOrder(Data);
SarcHash = Utils.GenerateUniqueHashID();
IFileInfo = new IFileInfo();
FillTreeNodes(this, SzsFiles.Files, SarcHash);
Text = FileName;
ContextMenu = new ContextMenu();
MenuItem save = new MenuItem("Save");
ContextMenu.MenuItems.Add(save);
save.Click += Save;
sarcData.Files.Clear();
}
public Syroot.BinaryData.ByteOrder GetByteOrder(byte[] data)
{
using (FileReader reader = new FileReader(data))
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
reader.Seek(6);
ushort bom = reader.ReadUInt16();
reader.Close();
reader.Dispose();
if (bom == 0xFFFE)
return Syroot.BinaryData.ByteOrder.LittleEndian;
else
return Syroot.BinaryData.ByteOrder.BigEndian;
}
}
public void Unload()
{
Nodes.Clear();
}
IEnumerable<TreeNode> Collect(TreeNodeCollection nodes)
{
foreach (TreeNode node in nodes)
{
yield return node;
foreach (var child in Collect(node.Nodes))
yield return child;
}
}
public byte[] Save()
{
Console.WriteLine("Saving sarc");
sarcData.Files.Clear();
foreach (TreeNode node in Collect(Nodes))
{
if (node is SarcEntry)
{
Console.WriteLine("Saving " + node);
SaveFileEntryData((SarcEntry)node);
}
else if (node is TreeNodeFile && node != this)
{
IFileFormat fileFormat = (IFileFormat)node;
if (fileFormat != null && fileFormat.IFileInfo != null && fileFormat.IFileInfo.ArchiveHash == SarcHash)
{
sarcData.Files.Add(SetSarcPath(node, this),
STLibraryCompression.CompressFile(fileFormat.Save(), fileFormat));
}
}
}
Tuple<int, byte[]> sarc = SARCExt.SARC.PackN(sarcData);
IFileInfo.Alignment = sarc.Item1;
return sarc.Item2;
}
public static string SetSarcPath(TreeNode node, TreeNode sarcNode)
{
string nodePath = node.FullPath;
int startIndex = nodePath.IndexOf(sarcNode.Text);
if (startIndex > 0)
nodePath = nodePath.Substring(startIndex);
string slash = Path.DirectorySeparatorChar.ToString();
string slashAlt = Path.AltDirectorySeparatorChar.ToString();
string SetPath = nodePath.Replace(sarcNode.Text + slash, string.Empty).Replace(slash ?? "", slashAlt);
return !(SetPath == string.Empty) ? SetPath : node.Text;
}
private void SaveFileEntryData(SarcEntry sarc)
{
string dir = Path.GetDirectoryName(sarc.FullName);
Console.WriteLine(sarc.FullName);
if (dir == string.Empty)
sarc.FullName = sarc.Text;
else
sarc.FullName = dir + "/" + sarc.Text;
Console.WriteLine(sarc.FullName);
sarcData.Files.Add(sarc.FullName, sarc.Data);
}
public static void ReplaceNode(TreeNode node, TreeNode replaceNode, TreeNode NewNode)
{
if (NewNode == null)
return;
int index = node.Nodes.IndexOf(replaceNode);
node.Nodes.RemoveAt(index);
node.Nodes.Insert(index, NewNode);
}
private void Save(object sender, EventArgs args)
{
List<IFileFormat> formats = new List<IFileFormat>();
formats.Add(this);
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(formats);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName, IFileInfo.Alignment);
}
}
private void CallRecursive(TreeView treeView)
{
// Print each node recursively.
TreeNodeCollection nodes = treeView.Nodes;
foreach (TreeNode n in nodes)
{
PrintRecursive(n);
}
}
private void PrintRecursive(TreeNode treeNode)
{
// Print the node.
if (treeNode is SarcEntry)
{
((SarcEntry)treeNode).OnClick(treeNode.TreeView);
}
if (treeNode is IFileFormat)
{
}
// Print each node recursively.
foreach (TreeNode tn in treeNode.Nodes)
{
PrintRecursive(tn);
}
}
public class SarcEntry : TreeNodeCustom
{
public SARC sarc; //Sarc file the entry is located in
public byte[] Data;
public string sarcHash;
public SarcEntry()
{
ImageKey = "fileBlank";
SelectedImageKey = "fileBlank";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
MenuItem remove = new MenuItem("Remove");
ContextMenu.MenuItems.Add(remove);
remove.Click += Remove;
MenuItem rename = new MenuItem("Rename");
ContextMenu.MenuItems.Add(rename);
rename.Click += Rename;
}
public override void OnDoubleMouseClick(TreeView treeView)
{
TreeNode node = STFileLoader.GetNodeFileFormat(FullName, Data, true, sarcHash, this);
if (node != null)
ReplaceNode(this.Parent, this, node);
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode node = TreeView.SelectedNode;
// Determine by checking the Text property.
MessageBox.Show(node.Text);
}
public string FullName;
public IFileFormat FileHandle; //Load file instance to save later if possible
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.FileName = Text;
ofd.DefaultExt = Path.GetExtension(Text);
ofd.Filter = "All files(*.*)|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
Data = File.ReadAllBytes(ofd.FileName);
}
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = Path.GetExtension(Text);
sfd.Filter = "All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
File.WriteAllBytes(sfd.FileName, Data);
}
}
private void Remove(object sender, EventArgs args)
{
DialogResult result = MessageBox.Show($"Are your sure you want to remove {Text}? This cannot be undone!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
Parent.Nodes.Remove(this);
}
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
Text = dialog.textBox1.Text;
}
}
}
void FillTreeNodes(TreeNode root, Dictionary<string, byte[]> files, string SarcHash)
{
var rootText = root.Text;
var rootTextLength = rootText.Length;
var nodeStrings = files;
foreach (var node in nodeStrings)
{
string nodeString = node.Key;
var roots = nodeString.Split(new char[] { '/' },
StringSplitOptions.RemoveEmptyEntries);
// The initial parent is the root node
var parentNode = root;
var sb = new StringBuilder(rootText, nodeString.Length + rootTextLength);
for (int rootIndex = 0; rootIndex < roots.Length; rootIndex++)
{
// Build the node name
var parentName = roots[rootIndex];
sb.Append("/");
sb.Append(parentName);
var nodeName = sb.ToString();
// Search for the node
var index = parentNode.Nodes.IndexOfKey(nodeName);
if (index == -1)
{
// Node was not found, add it
var temp = new TreeNode(parentName, 0, 0);
if (rootIndex == roots.Length - 1)
temp = SetupFileEntry(node.Value, parentName, node.Key, SarcHash);
temp.Name = nodeName;
parentNode.Nodes.Add(temp);
parentNode = temp;
}
else
{
// Node was found, set that as parent and continue
parentNode = parentNode.Nodes[index];
}
}
}
}
List<string> BuildFinalList(List<string> paths)
{
var finalList = new List<string>();
foreach (var path in paths)
{
bool found = false;
foreach (var item in finalList)
{
if (item.StartsWith(path, StringComparison.Ordinal))
{
found = true;
break;
}
}
if (!found)
{
finalList.Add(path);
}
}
return finalList;
}
public SarcEntry SetupFileEntry(byte[] data, string name, string fullName, string SarchHash)
{
SarcEntry sarcEntry = new SarcEntry();
sarcEntry.FullName = fullName;
sarcEntry.Name = name;
sarcEntry.Text = name;
sarcEntry.sarc = this;
sarcEntry.Data = data;
sarcEntry.sarcHash = SarcHash;
Console.WriteLine(name);
string ext = Path.GetExtension(name);
string SarcEx = SARCExt.SARC.GuessFileExtension(data);
if (SarcEx == ".bfres" || ext == ".sbfres")
{
sarcEntry.ImageKey = "bfres";
sarcEntry.SelectedImageKey = "bfres";
}
if (SarcEx == ".bntx")
{
sarcEntry.ImageKey = "bntx";
sarcEntry.SelectedImageKey = "bntx";
}
if (SarcEx == ".byaml")
{
sarcEntry.ImageKey = "byaml";
sarcEntry.SelectedImageKey = "byaml";
}
if (SarcEx == ".aamp")
{
sarcEntry.ImageKey = "aamp";
sarcEntry.SelectedImageKey = "aamp";
}
return sarcEntry;
}
}
}

View File

@ -1,954 +0,0 @@
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.ComponentModel;
using System.Text;
using System.Threading.Tasks;
using Syroot.NintenTools.NSW.Bntx;
using Syroot.NintenTools.NSW.Bntx.GFX;
using System.Runtime.InteropServices;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using Switch_Toolbox.Library;
using WeifenLuo.WinFormsUI.Docking;
using Smash_Forge.Rendering;
using Switch_Toolbox.Library.Forms;
using Switch_Toolbox.Library.IO;
namespace FirstPlugin
{
public class Formats
{
public enum BNTXImageFormat
{
IMAGE_FORMAT_INVALID = 0x0,
IMAGE_FORMAT_R5_G6_B5 = 0x07,
IMAGE_FORMAT_R8 = 0x02,
IMAGE_FORMAT_R8_G8 = 0x09,
IMAGE_FORMAT_R16 = 0x0a,
IMAGE_FORMAT_R8_G8_B8_A8 = 0x0b,
IMAGE_FORMAT_R11_G11_B11_A10 = 0x0f,
IMAGE_FORMAT_BC1 = 0x1a,
IMAGE_FORMAT_BC2 = 0x1b,
IMAGE_FORMAT_BC3 = 0x1c,
IMAGE_FORMAT_BC4 = 0x1d,
IMAGE_FORMAT_BC5 = 0x1e,
IMAGE_FORMAT_BC6 = 0x1f,
IMAGE_FORMAT_BC7 = 0x20,
IMAGE_FORMAT_ASTC4x4 = 0x2d,
IMAGE_FORMAT_ASTC5x4 = 0x2e,
IMAGE_FORMAT_ASTC5x5 = 0x2f,
IMAGE_FORMAT_ASTC6x5 = 0x30,
IMAGE_FORMAT_ASTC6x6 = 0x31,
IMAGE_FORMAT_ASTC8x5 = 0x32,
IMAGE_FORMAT_ASTC8x6 = 0x33,
IMAGE_FORMAT_ASTC8x8 = 0x34,
IMAGE_FORMAT_ASTC10x5 = 0x35,
IMAGE_FORMAT_ASTC10x6 = 0x36,
IMAGE_FORMAT_ASTC10x8 = 0x37,
IMAGE_FORMAT_ASTC10x10 = 0x38,
IMAGE_FORMAT_ASTC12x10 = 0x39,
IMAGE_FORMAT_ASTC12x12 = 0x3a
};
public enum BNTXImageTypes
{
UNORM = 0x01,
SNORM = 0x02,
SRGB = 0x06,
};
public static uint blk_dims(uint format)
{
switch (format)
{
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC1:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC2:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC3:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC4:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC5:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC6:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC7:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC4x4:
return 0x44;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC5x4: return 0x54;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC5x5: return 0x55;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC6x5: return 0x65;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC6x6: return 0x66;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC8x5: return 0x85;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC8x6: return 0x86;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC8x8: return 0x88;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x5: return 0xa5;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x6: return 0xa6;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x8: return 0xa8;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x10: return 0xaa;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC12x10: return 0xca;
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC12x12: return 0xcc;
default: return 0x11;
}
}
public static uint bpps(uint format)
{
switch (format)
{
case (uint)BNTXImageFormat.IMAGE_FORMAT_R8_G8_B8_A8: return 4;
case (uint)BNTXImageFormat.IMAGE_FORMAT_R8: return 1;
case (uint)BNTXImageFormat.IMAGE_FORMAT_R5_G6_B5:
case (uint)BNTXImageFormat.IMAGE_FORMAT_R8_G8:
return 2;
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC1:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC4:
return 8;
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC2:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC3:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC5:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC6:
case (uint)BNTXImageFormat.IMAGE_FORMAT_BC7:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC5x4:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC5x5:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC6x5:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC6x6:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC8x5:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC8x6:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC8x8:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x5:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x6:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x8:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC10x10:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC12x10:
case (uint)BNTXImageFormat.IMAGE_FORMAT_ASTC12x12:
return 16;
default: return 0x00;
}
}
}
public class BNTX : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "*BNTX"};
public string[] Extension { get; set; } = new string[] { "*.bntx"};
public string Magic { get; set; } = "BNTX";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public int Alignment { get; set; } = 0;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
types.Add(typeof(MenuExt));
return types.ToArray();
}
}
class MenuExt : IFileMenuExtension
{
public ToolStripItemDark[] NewFileMenuExtensions => newFileExt;
public ToolStripItemDark[] ToolsMenuExtensions => toolExt;
public ToolStripItemDark[] TitleBarExtensions => null;
public ToolStripItemDark[] CompressionMenuExtensions => null;
public ToolStripItemDark[] ExperimentalMenuExtensions => null;
ToolStripItemDark[] toolExt = new ToolStripItemDark[1];
ToolStripItemDark[] newFileExt = new ToolStripItemDark[1];
public MenuExt()
{
toolExt[0] = new ToolStripItemDark("Extract BNTX");
toolExt[0].Click += Export;
newFileExt[0] = new ToolStripItemDark("BNTX");
newFileExt[0].Click += New;
}
private void New(object sender, EventArgs args)
{
BNTX bntx = new BNTX();
bntx.FileName = "textures.bntx";
bntx.Data = CreateNewBNTX("textures.bntx");
bntx.Load();
ObjectList.Instance.treeView1.Nodes.Add(bntx);
}
private void Export(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
foreach (string file in ofd.FileNames)
{
FileReader reader = new FileReader(ofd.FileName);
reader.Seek(16, SeekOrigin.Begin);
int offsetName = reader.ReadInt32();
reader.Seek(offsetName, SeekOrigin.Begin);
string Name = reader.ReadString(Syroot.BinaryData.BinaryStringFormat.ZeroTerminated);
Console.WriteLine(file + " " + Name);
reader.Close();
reader.Dispose();
// System.IO.File.Move(file, Name);
}
}
}
}
public Dictionary<string, TextureData> Textures;
public PropertieGridData prop;
public BntxFile BinaryTexFile;
public string FileNameText;
MenuItem save = new MenuItem("Save");
MenuItem replace = new MenuItem("Replace");
MenuItem rename = new MenuItem("Rename");
MenuItem importTex = new MenuItem("Import Texture");
MenuItem exportAll = new MenuItem("Export All Textures");
MenuItem sort = new MenuItem("Sort");
MenuItem clear = new MenuItem("Clear");
private bool hasParent;
public bool HasParent
{
get
{
hasParent = Parent != null;
replace.Enabled = hasParent;
rename.Enabled = hasParent;
return hasParent;
}
}
public bool CanReplace;
public bool AllGLInitialized
{
get
{
if (Textures.Any(item => item.Value.RenderableTex.GLInitialized == false))
return false;
else
return true;
}
}
public void Load()
{
IFileInfo = new IFileInfo();
IsActive = true;
UseEditMenu = true;
CanSave = true;
ImageKey = "bntx";
SelectedImageKey = "bntx";
FileNameText = FileName;
LoadFile(Data, Name);
PluginRuntime.bntxContainers.Add(this);
//Check if bntx is parented to determine if an archive is used
bool checkParent = HasParent;
ContextMenu = new ContextMenu();
ContextMenu.MenuItems.Add(save);
ContextMenu.MenuItems.Add(replace);
ContextMenu.MenuItems.Add(rename);
ContextMenu.MenuItems.Add(importTex);
ContextMenu.MenuItems.Add(exportAll);
ContextMenu.MenuItems.Add(sort);
ContextMenu.MenuItems.Add(clear);
save.Click += Save;
replace.Click += Import;
rename.Click += Rename;
importTex.Click += ImportTexture;
exportAll.Click += ExportAll;
sort.Click += SortTextures;
clear.Click += Clear;
}
public void Unload()
{
foreach (TextureData tex in Textures.Values)
{
tex.Surfaces.Clear();
}
Textures.Clear();
Nodes.Clear();
}
private static byte[] CreateNewBNTX(string Name)
{
MemoryStream mem = new MemoryStream();
BntxFile bntx = new BntxFile();
bntx.Target = new char[] { 'N', 'X', ' ', ' ' };
bntx.Name = Name;
bntx.Alignment = 0xC;
bntx.TargetAddressSize = 0x40;
bntx.VersionMajor = 0;
bntx.VersionMajor2 = 4;
bntx.VersionMinor = 0;
bntx.VersionMinor2 = 0;
bntx.Textures = new List<Texture>();
bntx.TextureDict = new ResDict();
bntx.RelocationTable = new RelocationTable();
bntx.Flag = 0;
bntx.Save(mem);
return mem.ToArray();
}
public void RemoveTexture(TextureData textureData)
{
Nodes.Remove(textureData);
Textures.Remove(textureData.Text);
Viewport.Instance.UpdateViewport();
}
public override void OnClick(TreeView treeView)
{
}
//Check right click to enable/disable certain context menus
public override void OnMouseRightClick(TreeView treeview)
{
bool checkParent = HasParent;
}
public void LoadFile(byte[] data, string Name = "")
{
Textures = new Dictionary<string, TextureData>();
Data = data;
BinaryTexFile = new BntxFile(new MemoryStream(Data));
Text = BinaryTexFile.Name;
prop = new PropertieGridData();
prop.Target = new string(BinaryTexFile.Target);
prop.VersionMajor = BinaryTexFile.VersionMajor;
prop.VersionMajor2 = BinaryTexFile.VersionMajor2;
prop.VersionMinor = BinaryTexFile.VersionMinor;
prop.VersionMinor2 = BinaryTexFile.VersionMinor2;
prop.VersionFull = $"{BinaryTexFile.VersionMajor}.{BinaryTexFile.VersionMajor2}.{BinaryTexFile.VersionMinor}.{BinaryTexFile.VersionMinor2}";
foreach (Texture tex in BinaryTexFile.Textures)
{
TextureData texData = new TextureData(tex, BinaryTexFile);
// texData.LoadOpenGLTexture();
Nodes.Add(texData);
Textures.Add(tex.Name, texData);
}
BinaryTexFile.Textures.Clear(); //We don't need these in memeory anymore
BinaryTexFile.TextureDict.Clear();
}
private void ImportTexture(object sender, EventArgs args)
{
ImportTexture();
}
public void ImportTexture()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Binary Texture |*.bftex|" +
"Microsoft DDS |*.dds|" +
"TGA |*.tga|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.DefaultExt = "bftex";
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
BinaryTextureImporterList importer = new BinaryTextureImporterList();
bool UseDialog = false;
foreach (string name in ofd.FileNames)
{
TextureImporterSettings setting = new TextureImporterSettings();
}
GC.Collect();
Cursor.Current = Cursors.Default;
}
}
//This function is an optional feature that will import a dummy texture if one is missing in the materials
public void ImportPlaceholderTexture(string TextureName)
{
if (Textures.ContainsKey(TextureName))
return;
if (TextureName == "Basic_Alb")
ImportBasicTextures("Basic_Alb");
else if (TextureName == "Basic_Nrm")
ImportBasicTextures("Basic_Nrm");
else if (TextureName == "Basic_Spm")
ImportBasicTextures("Basic_Spm");
else if (TextureName == "Basic_Sphere")
ImportBasicTextures("Basic_Sphere");
else if (TextureName == "Basic_Mtl")
ImportBasicTextures("Basic_Mtl");
else if (TextureName == "Basic_Rgh")
ImportBasicTextures("Basic_Rgh");
else if (TextureName == "Basic_MRA")
ImportBasicTextures("Basic_MRA");
else if (TextureName == "Basic_Bake_st0")
ImportBasicTextures("Basic_Bake_st0");
else if (TextureName == "Basic_Bake_st1")
ImportBasicTextures("Basic_Bake_st1");
else if (TextureName == "Basic_Emm")
ImportBasicTextures("Basic_Emm");
else
{
ImportPlaceholderTexture(Properties.Resources.InjectTexErrored, TextureName);
}
}
private void ImportPlaceholderTexture(byte[] data, string TextureName)
{
TextureImporterSettings importDDS = new TextureImporterSettings();
importDDS.LoadDDS(TextureName, BinaryTexFile, data);
TextureData texData = importDDS.textureData;
texData.Text = TextureName;
Nodes.Add(texData);
Textures.Add(TextureName, texData);
texData.LoadOpenGLTexture();
}
public void ImportBasicTextures(string TextureName, bool BC5Nrm = true)
{
if (Textures.ContainsKey(TextureName))
return;
if (TextureName == "Basic_Alb")
ImportPlaceholderTexture(Properties.Resources.InjectTexErrored, TextureName);
if (TextureName == "Basic_Nrm" && BC5Nrm)
ImportPlaceholderTexture(Properties.Resources.Basic_NrmBC5, TextureName);
if (TextureName == "Basic_Nrm" && BC5Nrm == false)
ImportPlaceholderTexture(Properties.Resources.Basic_Nrm, TextureName);
if (TextureName == "Basic_Spm")
ImportPlaceholderTexture(Properties.Resources.Black, TextureName);
if (TextureName == "Basic_Sphere")
ImportPlaceholderTexture(Properties.Resources.Black, TextureName);
if (TextureName == "Basic_Mtl")
ImportPlaceholderTexture(Properties.Resources.Black, TextureName);
if (TextureName == "Basic_Rgh")
ImportPlaceholderTexture(Properties.Resources.White, TextureName);
if (TextureName == "Basic_MRA")
ImportPlaceholderTexture(Properties.Resources.Black, TextureName);
if (TextureName == "Basic_Bake_st0")
ImportPlaceholderTexture(Properties.Resources.Basic_Bake_st0, TextureName);
if (TextureName == "Basic_Bake_st1")
ImportPlaceholderTexture(Properties.Resources.Basic_Bake_st1, TextureName);
}
public TextureImporterSettings LoadSettings(string name)
{
var importer = new TextureImporterSettings();
string ext = Path.GetExtension(name);
ext = ext.ToLower();
switch (ext)
{
case ".bftex":
Texture tex = new Texture();
tex.Import(name);
break;
case ".dds":
importer.LoadDDS(name, BinaryTexFile);
break;
case ".tga":
importer.LoadTGA(name, BinaryTexFile);
break;
default:
importer.LoadBitMap(name, BinaryTexFile);
break;
}
return importer;
}
public TextureData AddTexture(string name)
{
var importer = new TextureImporterSettings();
TextureData texData = null;
string ext = Path.GetExtension(name);
ext = ext.ToLower();
switch (ext)
{
case ".bftex":
Texture tex = new Texture();
tex.Import(name);
texData = new TextureData(tex, BinaryTexFile);
break;
case ".dds":
importer.LoadDDS(name, BinaryTexFile);
texData = importer.textureData;
break;
default:
importer.LoadBitMap(name, BinaryTexFile);
texData = importer.textureData;
break;
}
if (texData != null)
{
List<string> keyList = new List<string>(Textures.Keys);
texData.Text = Utils.RenameDuplicateString(keyList, texData.Text);
Nodes.Add(texData);
Textures.Add(texData.Text, texData);
}
return texData;
}
private void Clear(object sender, EventArgs args)
{
Nodes.Clear();
Textures.Clear();
GC.Collect();
}
private void ExportAll(object sender, EventArgs args)
{
List<string> Formats = new List<string>();
Formats.Add("Cafe Binary Textures (.bftex)");
Formats.Add("Microsoft DDS (.dds)");
Formats.Add("Portable Graphics Network (.png)");
Formats.Add("Joint Photographic Experts Group (.jpg)");
Formats.Add("Bitmap Image (.bmp)");
Formats.Add("Tagged Image File Format (.tiff)");
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
TextureFormatExport form = new TextureFormatExport(Formats);
if (form.ShowDialog() == DialogResult.OK)
{
foreach (TextureData tex in Nodes)
{
if (form.Index == 0)
tex.SaveBinaryTexture(folderPath + '\\' + tex.Text + ".bftex");
else if (form.Index == 1)
tex.SaveDDS(folderPath + '\\' + tex.Text + ".dds");
else if (form.Index == 2)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".png");
else if (form.Index == 3)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".jpg");
else if (form.Index == 4)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".bmp");
else if (form.Index == 5)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".tiff");
}
}
}
}
bool SortedAscending;
private void SortTextures(object sender, EventArgs args)
{
SortNodes(this);
}
public byte[] Save()
{
BinaryTexFile.Textures.Clear();
BinaryTexFile.TextureDict.Clear();
foreach (TextureData tex in Textures.Values)
{
tex.Texture.Name = tex.Text;
BinaryTexFile.Textures.Add(tex.Texture);
BinaryTexFile.TextureDict.Add(tex.Text);
}
MemoryStream mem = new MemoryStream();
BinaryTexFile.Save(mem);
return mem.ToArray();
}
public class PropertieGridData
{
[Browsable(true)]
[Category("BNTX")]
[DisplayName("Name")]
public string Name { get; set; }
[Browsable(true)]
[Category("BNTX")]
[DisplayName("Original Path")]
public string Path { get; set; }
[Browsable(true)]
[Category("BNTX")]
[DisplayName("Target")]
public string Target { get; set; }
[Browsable(true)]
[ReadOnly(true)]
[Category("Versions")]
[DisplayName("Full Version")]
public string VersionFull { get; set; }
[Browsable(true)]
[Category("Versions")]
[DisplayName("Version Major 1")]
public uint VersionMajor { get; set; }
[Browsable(true)]
[Category("Versions")]
[DisplayName("Version Major 2")]
public uint VersionMajor2 { get; set; }
[Browsable(true)]
[Category("Versions")]
[DisplayName("Version Minor 1")]
public uint VersionMinor { get; set; }
[Browsable(true)]
[Category("Versions")]
[DisplayName("Version Minor 2")]
public uint VersionMinor2 { get; set; }
}
private void Import(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
Data = File.ReadAllBytes(ofd.FileName);
LoadFile(Data);
}
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
Text = dialog.textBox1.Text;
}
}
private void Save(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.DefaultExt = "bntx";
sfd.Filter = "Supported Formats|*.bntx;";
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName);
}
}
}
public class TextureData : STGenericTexture
{
public Texture Texture;
public BntxFile bntxFile;
public bool GLInitialized = false;
public TextureData()
{
ImageKey = "Texture";
SelectedImageKey = "Texture";
}
public TextureData(Texture tex, BntxFile bntx)
{
ImageKey = "Texture";
SelectedImageKey = "Texture";
Texture = tex;
bntxFile = bntx;
Text = tex.Name;
Width = tex.Width;
Height = tex.Height;
MipmapCount = tex.MipCount;
var formats = ConvertFormat(tex.Format, tex.FormatType);
Format = formats.Item1;
FormatType = formats.Item2;
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
MenuItem replace = new MenuItem("Replace");
MenuItem remove = new MenuItem("Remove");
MenuItem rename = new MenuItem("Rename");
ContextMenu.MenuItems.Add(export);
ContextMenu.MenuItems.Add(replace);
ContextMenu.MenuItems.Add(remove);
ContextMenu.MenuItems.Add(rename);
export.Click += Export;
replace.Click += Replace;
remove.Click += Remove;
rename.Click += Rename;
string TargetString = new string(bntx.Target);
int target = 0;
if (TargetString == "NX ")
target = 1;
LoadTexture(Texture);
}
public static Tuple<SurfaceFormat, SurfaceFormatType> GetSurfaceFormat(TEX_FORMAT format, TEX_FORMAT_TYPE type)
{
var surfaceFormat = SurfaceFormat.Invalid;
var surfaceType = SurfaceFormatType.UNORM;
Enum.TryParse(format.ToString(), out surfaceFormat);
Enum.TryParse(type.ToString(), out surfaceType);
return Tuple.Create(surfaceFormat, surfaceType);
}
public static Tuple<TEX_FORMAT, TEX_FORMAT_TYPE> ConvertFormat(SurfaceFormat surfaceFormat, SurfaceFormatType surfaceType)
{
var format = TEX_FORMAT.UNKNOWN;
var type = TEX_FORMAT_TYPE.UNORM;
Enum.TryParse(surfaceFormat.ToString(), out format);
Enum.TryParse(surfaceType.ToString(), out type);
return Tuple.Create(format, type);
}
public override void OnClick(TreeView treeView)
{
UpdateBNTXEditor();
}
public void UpdateBNTXEditor()
{
if (Viewport.Instance.gL_ControlModern1 == null || Viewport.Instance.gL_ControlModern1.Visible == false)
PluginRuntime.FSHPDockState = WeifenLuo.WinFormsUI.Docking.DockState.Document;
BNTXEditor docked = (BNTXEditor)LibraryGUI.Instance.GetContentDocked(new BNTXEditor());
if (docked == null)
{
docked = new BNTXEditor();
LibraryGUI.Instance.LoadDockContent(docked, PluginRuntime.FSHPDockState);
}
docked.Text = Text;
docked.Dock = DockStyle.Fill;
docked.LoadProperty(this);
}
private void Remove(object sender, EventArgs args)
{
((BNTX)Parent).RemoveTexture(this);
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
((BNTX)Parent).Textures.Remove(Text);
Text = dialog.textBox1.Text;
((BNTX)Parent).Textures.Add(Text, this);
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Binary Texture |*.bftex|" +
"Microsoft DDS |*.dds|" +
"TGA |*.tga|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
Replace(ofd.FileName);
}
}
public void Replace(string FileName)
{
string ext = Path.GetExtension(FileName);
ext = ext.ToLower();
TextureImporterSettings setting = new TextureImporterSettings();
BinaryTextureImporterList importer = new BinaryTextureImporterList();
switch (ext)
{
case ".bftex":
Texture.Import(FileName);
break;
case ".dds":
setting.LoadDDS(FileName, bntxFile, null, this);
ApplyImportSettings(setting);
break;
default:
setting.LoadBitMap(FileName, bntxFile);
importer.LoadSetting(setting);
if (importer.ShowDialog() == DialogResult.OK)
{
ApplyImportSettings(setting);
}
break;
}
}
private void ApplyImportSettings(TextureImporterSettings setting)
{
Cursor.Current = Cursors.WaitCursor;
if (setting.GenerateMipmaps)
{
setting.DataBlockOutput.Clear();
setting.DataBlockOutput.Add(setting.GenerateMips());
}
if (setting.DataBlockOutput != null)
{
Texture = setting.FromBitMap(setting.DataBlockOutput[0], setting);
LoadOpenGLTexture();
}
else
{
MessageBox.Show("Something went wrong???");
}
Texture.Name = Text;
UpdateBfresTextureMapping();
UpdateBNTXEditor();
}
private void UpdateBfresTextureMapping()
{
foreach (GL_Core.Interfaces.AbstractGlDrawable draw in Runtime.abstractGlDrawables)
{
if (draw is BFRESRender)
{
((BFRESRender)draw).UpdateTextureMaps();
}
}
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Texture.Name;
sfd.DefaultExt = "bftex";
sfd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Binary Texture |*.bftex|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
Export(sfd.FileName);
}
}
public void Export(string FileName, bool ExportSurfaceLevel = false,
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
{
string ext = Path.GetExtension(FileName);
ext = ext.ToLower();
switch (ext)
{
case ".bftex":
SaveBinaryTexture(FileName);
break;
case ".dds":
SaveDDS(FileName);
break;
case ".astc":
SaveASTC(FileName);
break;
default:
SaveBitMap(FileName);
break;
}
}
public void LoadTexture(Texture tex, int target = 1)
{
Surfaces.Clear();
try
{
uint blk_dim = Formats.blk_dims((uint)((int)tex.Format >> 8));
uint blkWidth = blk_dim >> 4;
uint blkHeight = blk_dim & 0xF;
int linesPerBlockHeight = (1 << (int)tex.BlockHeightLog2) * 8;
uint bpp = Formats.bpps((uint)((int)tex.Format >> 8));
for (int arrayLevel = 0; arrayLevel < tex.ArrayLength; arrayLevel++)
{
int blockHeightShift = 0;
List<byte[]> mips = new List<byte[]>();
for (int mipLevel = 0; mipLevel < tex.TextureData[arrayLevel].Count; mipLevel++)
{
uint width = (uint)Math.Max(1, tex.Width >> mipLevel);
uint height = (uint)Math.Max(1, tex.Height >> mipLevel);
uint size = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight) * bpp;
if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
blockHeightShift += 1;
byte[] result = TegraX1Swizzle.deswizzle(width, height, blkWidth, blkHeight, target, bpp, (uint)tex.TileMode, (int)Math.Max(0, tex.BlockHeightLog2 - blockHeightShift), tex.TextureData[arrayLevel][mipLevel]);
//Create a copy and use that to remove uneeded data
byte[] result_ = new byte[size];
Array.Copy(result, 0, result_, 0, size);
mips.Add(result_);
}
Surfaces.Add(new Surface() { mipmaps = mips });
}
Texture = tex;
}
catch (Exception e)
{
MessageBox.Show($"Failed to swizzle texture {Text}! Exception: {e}");
}
}
internal void SaveBinaryTexture(string FileName)
{
Console.WriteLine("Test");
Texture.Export(FileName, bntxFile);
}
}
}

View File

@ -1,378 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Forms;
using Syroot.NintenTools.Bfres;
using Syroot.NintenTools.Bfres.GX2;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using Smash_Forge.Rendering;
using WeifenLuo.WinFormsUI.Docking;
using Switch_Toolbox.Library.IO;
namespace FirstPlugin
{
public class FTEXContainer : TreeNodeCustom
{
public Dictionary<string, FTEX> Textures = new Dictionary<string, FTEX>(); //To get instance of classes
public FTEXContainer()
{
Text = "Textures";
Name = "FTEX";
ContextMenu = new ContextMenu();
MenuItem importTex = new MenuItem("Import");
ContextMenu.MenuItems.Add(importTex);
importTex.Click += Import;
MenuItem exportAll = new MenuItem("Export All Textures");
ContextMenu.MenuItems.Add(exportAll);
exportAll.Click += ExportAll;
MenuItem clear = new MenuItem("Clear");
ContextMenu.MenuItems.Add(clear);
clear.Click += Clear;
}
private void Clear(object sender, EventArgs args)
{
Nodes.Clear();
Textures.Clear();
}
public void RefreshGlTexturesByName()
{
}
public void RemoveTexture(FTEX textureData)
{
Nodes.Remove(textureData);
Textures.Remove(textureData.Text);
Viewport.Instance.UpdateViewport();
}
private void Import(object sender, EventArgs args)
{
ImportTexture();
}
public void ImportTexture()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
BinaryTextureImporterList importer = new BinaryTextureImporterList();
List<TextureImporterSettings> settings = new List<TextureImporterSettings>();
foreach (string name in ofd.FileNames)
{
settings.Clear();
GC.Collect();
Cursor.Current = Cursors.Default;
}
}
}
private void ExportAll(object sender, EventArgs args)
{
List<string> Formats = new List<string>();
Formats.Add("Cafe Binary Textures (.bftex)");
Formats.Add("Microsoft DDS (.dds)");
Formats.Add("Portable Graphics Network (.png)");
Formats.Add("Joint Photographic Experts Group (.jpg)");
Formats.Add("Bitmap Image (.bmp)");
Formats.Add("Tagged Image File Format (.tiff)");
FolderSelectDialog sfd = new FolderSelectDialog();
if (sfd.ShowDialog() == DialogResult.OK)
{
string folderPath = sfd.SelectedPath;
TextureFormatExport form = new TextureFormatExport(Formats);
if (form.ShowDialog() == DialogResult.OK)
{
foreach (FTEX tex in Nodes)
{
if (form.Index == 0)
tex.SaveBinaryTexture(folderPath + '\\' + tex.Text + ".bftex");
else if (form.Index == 1)
tex.SaveDDS(folderPath + '\\' + tex.Text + ".dds");
else if (form.Index == 2)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".png");
else if (form.Index == 3)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".jpg");
else if (form.Index == 4)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".bmp");
else if (form.Index == 5)
tex.SaveBitMap(folderPath + '\\' + tex.Text + ".tiff");
}
}
}
}
}
public class FTEX : STGenericTexture
{
public int format;
public Texture texture;
public FTEX()
{
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
MenuItem remove = new MenuItem("Remove");
ContextMenu.MenuItems.Add(remove);
remove.Click += Remove;
MenuItem rename = new MenuItem("Rename");
ContextMenu.MenuItems.Add(rename);
rename.Click += Rename;
}
//For determining mip map file for botw (Tex2)
public string GetFilePath()
{
if (Parent == null)
throw new Exception("Parent is null!");
return ((BFRES)Parent.Parent).FilePath;
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
Replace(ofd.FileName);
}
}
public void Replace(string FileName)
{
string ext = System.IO.Path.GetExtension(FileName);
ext = ext.ToLower();
TextureImporterSettings setting = new TextureImporterSettings();
BinaryTextureImporterList importer = new BinaryTextureImporterList();
}
//We reuse GX2 data as it's the same thing
public Texture FromGx2Surface(GTX.GX2Surface surf, TextureImporterSettings settings)
{
Texture tex = new Texture();
tex.Name = settings.TexName;
tex.AAMode = (GX2AAMode)surf.aa;
tex.Alignment = (uint)surf.alignment;
tex.ArrayLength = 1;
tex.Data = surf.data;
tex.MipData = surf.mipData;
tex.Format = (GX2SurfaceFormat)surf.format;
tex.Dim = (GX2SurfaceDim)surf.dim;
tex.Use = (GX2SurfaceUse)surf.use;
tex.TileMode = (GX2TileMode)surf.tileMode;
tex.Swizzle = surf.swizzle;
tex.Pitch = surf.pitch;
tex.Depth = surf.depth;
tex.MipCount = surf.numMips;
tex.MipOffsets = new uint[13];
for (int i = 0; i < 13; i++)
{
if (i < surf.mipOffset.Length)
tex.MipOffsets[i] = surf.mipOffset[i];
}
tex.Height = surf.height;
tex.Width = surf.width;
tex.Regs = new uint[5];
tex.ArrayLength = 1;
var channels = SetChannelsByFormat((GX2SurfaceFormat)surf.format);
tex.CompSelR = channels[0];
tex.CompSelG = channels[1];
tex.CompSelB = channels[2];
tex.CompSelA = channels[3];
tex.UserData = new ResDict<UserData>();
return tex;
}
private void Rename(object sender, EventArgs args)
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
if (dialog.ShowDialog() == DialogResult.OK)
{
((FTEXContainer)Parent).Textures.Remove(Text);
Text = dialog.textBox1.Text;
((FTEXContainer)Parent).Textures.Add(Text, this);
}
}
private void Remove(object sender, EventArgs args)
{
((FTEXContainer)Parent).RemoveTexture(this);
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = "bftex";
sfd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Binary Texture |*.bftex|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
Export(sfd.FileName);
}
}
public void Read(Texture tex)
{
ImageKey = "Texture";
SelectedImageKey = "Texture";
Text = tex.Name;
texture = tex;
Width = tex.Width;
Height = tex.Height;
Format = ConvertFormat(tex.Format);
format = (int)tex.Format;
int swizzle = (int)tex.Swizzle;
int pitch = (int)tex.Pitch;
uint bpp = GTX.surfaceGetBitsPerPixel((uint)format) >> 3;
GTX.GX2Surface surf = new GTX.GX2Surface();
surf.bpp = bpp;
surf.height = tex.Height;
surf.width = tex.Width;
surf.aa = (uint)tex.AAMode;
surf.alignment = tex.Alignment;
surf.depth = tex.Depth;
surf.dim = (uint)tex.Dim;
surf.format = (uint)tex.Format;
surf.use = (uint)tex.Use;
surf.pitch = tex.Pitch;
surf.data = tex.Data;
surf.numMips = tex.MipCount;
surf.mipOffset = tex.MipOffsets;
surf.mipData = tex.MipData;
surf.tileMode = (uint)tex.TileMode;
surf.swizzle = tex.Swizzle;
//Determine tex2 botw files to get mip maps
string Tex1 = GetFilePath();
if (Tex1.Contains(".Tex1"))
{
string Tex2 = Tex1.Replace(".Tex1", ".Tex2");
Console.WriteLine(Tex2);
if (System.IO.File.Exists(Tex2))
{
ResFile resFile2 = new ResFile(new System.IO.MemoryStream(
EveryFileExplorer.YAZ0.Decompress(Tex2)));
if (resFile2.Textures.ContainsKey(tex.Name))
{
surf.mipData = resFile2.Textures[tex.Name].MipData;
surf.mipOffset = resFile2.Textures[tex.Name].MipOffsets;
}
}
}
if (surf.mipData == null)
surf.numMips = 1;
List<byte[]> mips = GTX.Decode(surf);
Surfaces.Add(new Surface() { mipmaps = mips });
RenderableTex.LoadOpenGLTexture(this);
}
private TEX_FORMAT ConvertFormat(GX2SurfaceFormat Format)
{
return TEX_FORMAT.UNKNOWN;
}
public static GX2CompSel[] SetChannelsByFormat(GX2SurfaceFormat Format)
{
GX2CompSel[] channels = new GX2CompSel[4];
switch (Format)
{
case GX2SurfaceFormat.T_BC5_UNorm:
case GX2SurfaceFormat.T_BC5_SNorm:
channels[0] = GX2CompSel.ChannelR;
channels[1] = GX2CompSel.ChannelG;
channels[2] = GX2CompSel.Always0;
channels[3] = GX2CompSel.Always1;
break;
case GX2SurfaceFormat.T_BC4_SNorm:
case GX2SurfaceFormat.T_BC4_UNorm:
channels[0] = GX2CompSel.ChannelR;
channels[1] = GX2CompSel.ChannelR;
channels[2] = GX2CompSel.ChannelR;
channels[3] = GX2CompSel.ChannelR;
break;
default:
channels[0] = GX2CompSel.ChannelR;
channels[1] = GX2CompSel.ChannelG;
channels[2] = GX2CompSel.ChannelB;
channels[3] = GX2CompSel.Always1;
break;
}
return channels;
}
public void Export(string FileName, bool ExportSurfaceLevel = false,
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
{
string ext = System.IO.Path.GetExtension(FileName);
ext = ext.ToLower();
switch (ext)
{
case ".bftex":
SaveBinaryTexture(FileName);
break;
case ".dds":
SaveDDS(FileName);
break;
default:
SaveBitMap(FileName);
break;
}
}
internal void SaveBinaryTexture(string FileName)
{
Console.WriteLine("Test");
// Texture.Export(FileName, bntxFile);
}
public override void OnClick(TreeView treeView)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,490 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library;
using System.Windows.Forms;
using OpenTK.Graphics.OpenGL;
namespace FirstPlugin
{
public enum BlockType : uint
{
Invalid = 0x00,
EndOfFile = 0x01,
AlignData = 0x02,
VertexShaderHeader = 0x03,
VertexShaderProgram = 0x05,
PixelShaderHeader = 0x06,
PixelShaderProgram = 0x07,
GeometryShaderHeader = 0x08,
GeometryShaderProgram = 0x09,
GeometryShaderProgram2 = 0x10,
ImageInfo = 0x11,
ImageData = 0x12,
MipData = 0x13,
ComputeShaderHeader = 0x14,
ComputeShader = 0x15,
UserBlock = 0x16,
}
public class GTXFile : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "GTX" };
public string[] Extension { get; set; } = new string[] { "*.gtx" };
public string Magic { get; set; } = "Gfx2 ";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
private GTXHeader header;
public List<byte[]> data = new List<byte[]>();
public List<byte[]> mipMaps = new List<byte[]>();
public List<TextureData> textures = new List<TextureData>();
public List<GTXDataBlock> blocks = new List<GTXDataBlock>();
public void Load()
{
CanSave = true;
Text = FileName;
ReadGx2(new FileReader(Data));
ContextMenu = new ContextMenu();
MenuItem save = new MenuItem("Save");
ContextMenu.MenuItems.Add(save);
save.Click += Save;
}
private void Save(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.DefaultExt = "gtx";
sfd.Filter = "Supported Formats|*.gtx;";
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName);
}
}
public void Unload()
{
}
public byte[] Save()
{
System.IO.MemoryStream mem = new System.IO.MemoryStream();
using (FileWriter writer = new FileWriter(mem))
{
writer.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
header.Write(writer);
uint surfBlockType;
uint dataBlockType;
uint mipBlockType;
if (header.MajorVersion == 6)
{
surfBlockType = 0x0A;
dataBlockType = 0x0B;
mipBlockType = 0x0C;
}
else if (header.MajorVersion == 7)
{
surfBlockType = 0x0B;
dataBlockType = 0x0C;
mipBlockType = 0x0D;
}
else
throw new Exception($"Unsupported GTX version {header.MajorVersion}");
writer.Seek(header.HeaderSize, System.IO.SeekOrigin.Begin);
foreach (var tex in textures)
{
tex.surface.Write(writer);
}
foreach (var block in blocks)
{
if ((uint)block.BlockType == surfBlockType)
{
block.Write(writer);
}
else
{
block.Write(writer);
}
}
}
return mem.ToArray();
}
private void ReadGx2(FileReader reader)
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
header = new GTXHeader();
header.Read(reader);
Console.WriteLine("header size " + header.HeaderSize);
uint surfBlockType;
uint dataBlockType;
uint mipBlockType;
if (header.MajorVersion == 6)
{
surfBlockType = 0x0A;
dataBlockType = 0x0B;
mipBlockType = 0x0C;
}
else if (header.MajorVersion == 7)
{
surfBlockType = 0x0B;
dataBlockType = 0x0C;
mipBlockType = 0x0D;
}
else
throw new Exception($"Unsupported GTX version {header.MajorVersion}");
if (header.GpuVersion != 2)
throw new Exception($"Unsupported GPU version {header.GpuVersion}");
reader.Position = header.HeaderSize;
bool blockB = false;
bool blockC = false;
uint ImageInfo = 0;
uint images = 0;
while (reader.Position < reader.BaseStream.Length)
{
GTXDataBlock block = new GTXDataBlock();
block.Read(reader);
blocks.Add(block);
//Here we use "if" instead of "case" statements as types vary between versions
if ((uint)block.BlockType == surfBlockType)
{
ImageInfo += 1;
blockB = true;
var surface = new SurfaceInfoParse();
surface.Read(new FileReader(block.data));
if (surface.numMips > 14)
throw new Exception($"Invalid number of mip maps {surface.numMips}!");
TextureData textureData = new TextureData();
textureData.surface = surface;
textureData.Text = "Texture" + ImageInfo;
Nodes.Add(textureData);
textures.Add(textureData);
}
else if ((uint)block.BlockType == dataBlockType)
{
images += 1;
blockC = true;
data.Add(block.data);
}
else if ((uint)block.BlockType == mipBlockType)
{
mipMaps.Add(block.data);
}
}
if (textures.Count != data.Count)
throw new Exception($"Bad size! {textures.Count} {data.Count}");
int curTex = 0;
int curMip = 0;
foreach (var node in Nodes)
{
TextureData tex = (TextureData)node;
tex.surface.data = data[curTex];
tex.surface.bpp = GTX.surfaceGetBitsPerPixel(tex.surface.format) >> 3;
Console.WriteLine();
if (tex.surface.numMips > 1 )
tex.surface.mipData = mipMaps[curMip++];
else
tex.surface.mipData = new byte[0];
Console.WriteLine("");
Console.WriteLine("// ----- GX2Surface Info ----- ");
Console.WriteLine(" dim = " + tex.surface.dim);
Console.WriteLine(" width = " + tex.surface.width);
Console.WriteLine(" height = " + tex.surface.height);
Console.WriteLine(" depth = " + tex.surface.depth);
Console.WriteLine(" numMips = " + tex.surface.numMips);
Console.WriteLine(" format = " + tex.surface.format);
Console.WriteLine(" aa = " + tex.surface.aa);
Console.WriteLine(" use = " + tex.surface.use);
Console.WriteLine(" imageSize = " + tex.surface.imageSize);
Console.WriteLine(" mipSize = " + tex.surface.mipSize);
Console.WriteLine(" tileMode = " + tex.surface.tileMode);
Console.WriteLine(" swizzle = " + tex.surface.swizzle);
Console.WriteLine(" alignment = " + tex.surface.alignment);
Console.WriteLine(" pitch = " + tex.surface.pitch);
Console.WriteLine(" bits per pixel = " + (tex.surface.bpp << 3));
Console.WriteLine(" bytes per pixel = " + tex.surface.bpp);
Console.WriteLine(" data size = " + tex.surface.data.Length);
Console.WriteLine(" mip size = " + tex.surface.mipData.Length);
Console.WriteLine(" realSize = " + tex.surface.imageSize);
List<byte[]> mips = GTX.Decode(tex.surface);
tex.Surfaces.Add(new STGenericTexture.Surface() { mipmaps = mips });
tex.RenderableTex.LoadOpenGLTexture(tex);
curTex++;
}
}
public class GTXHeader
{
readonly string Magic = "Gfx2";
public uint HeaderSize;
public uint MajorVersion;
public uint MinorVersion;
public uint GpuVersion;
public uint AlignMode;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != Magic)
throw new Exception($"Invalid signature {Signature}! Expected Gfx2.");
HeaderSize = reader.ReadUInt32();
MajorVersion = reader.ReadUInt32();
MinorVersion = reader.ReadUInt32();
GpuVersion = reader.ReadUInt32();
AlignMode = reader.ReadUInt32();
}
public void Write(FileWriter writer)
{
writer.WriteSignature(Magic);
writer.Write(HeaderSize);
writer.Write(MajorVersion);
writer.Write(MinorVersion);
writer.Write(GpuVersion);
writer.Write(AlignMode);
}
}
public class GTXDataBlock
{
readonly string Magic = "BLK{";
public uint HeaderSize;
public uint MajorVersion;
public uint MinorVersion;
public BlockType BlockType;
public uint Identifier;
public uint index;
public uint DataSize;
public byte[] data;
public void Read(FileReader reader)
{
long blockStart = reader.Position;
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != Magic)
throw new Exception($"Invalid signature {Signature}! Expected BLK.");
HeaderSize = reader.ReadUInt32();
MajorVersion = reader.ReadUInt32(); //Must be 0x01 for 6.x.x
MinorVersion = reader.ReadUInt32(); //Must be 0x00 for 6.x.x
BlockType = reader.ReadEnum<BlockType>(false);
DataSize = reader.ReadUInt32();
Identifier = reader.ReadUInt32();
index = reader.ReadUInt32();
reader.Seek(blockStart + HeaderSize, System.IO.SeekOrigin.Begin);
data = reader.ReadBytes((int)DataSize);
}
public void Write(FileWriter writer)
{
long blockStart = writer.Position;
writer.WriteSignature(Magic);
writer.Write(HeaderSize);
writer.Write(MajorVersion);
writer.Write(MinorVersion);
writer.Write(BlockType, false);
writer.Write(DataSize);
writer.Write(Identifier);
writer.Write(index);
writer.Seek(blockStart + HeaderSize, System.IO.SeekOrigin.Begin);
writer.Write(data);
}
}
public class TextureData : STGenericTexture
{
public SurfaceInfoParse surface;
public TextureData()
{
ImageKey = "Texture";
SelectedImageKey = "Texture";
ContextMenu = new ContextMenu();
MenuItem export = new MenuItem("Export");
ContextMenu.MenuItems.Add(export);
export.Click += Export;
MenuItem replace = new MenuItem("Replace");
ContextMenu.MenuItems.Add(replace);
replace.Click += Replace;
MenuItem remove = new MenuItem("Remove");
ContextMenu.MenuItems.Add(remove);
remove.Click += Remove;
}
private void Remove(object sender, EventArgs args)
{
((GTXFile)Parent).Nodes.Remove(this);
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = "bftex";
sfd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Binary Texture |*.bftex|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
Export(sfd.FileName);
}
}
public void Export(string FileName, bool ExportSurfaceLevel = false,
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
{
string ext = System.IO.Path.GetExtension(FileName);
ext = ext.ToLower();
switch (ext)
{
case ".dds":
SaveDDS(FileName);
break;
default:
SaveBitMap(FileName);
break;
}
}
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
Replace(ofd.FileName);
}
}
public void Replace(string FileName)
{
}
public override void OnClick(TreeView treeView)
{
UpdateEditor();
}
public void UpdateEditor()
{
}
}
public class SurfaceInfoParse : GTX.GX2Surface
{
public void Read(FileReader reader)
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
dim = reader.ReadUInt32();
width = reader.ReadUInt32();
height = reader.ReadUInt32();
depth = reader.ReadUInt32();
numMips = reader.ReadUInt32();
format = reader.ReadUInt32();
aa = reader.ReadUInt32();
use = reader.ReadUInt32();
imageSize = reader.ReadUInt32();
imagePtr = reader.ReadUInt32();
mipSize = reader.ReadUInt32();
mipPtr = reader.ReadUInt32();
tileMode = reader.ReadUInt32();
swizzle = reader.ReadUInt32();
alignment = reader.ReadUInt32();
pitch = reader.ReadUInt32();
mipOffset = reader.ReadUInt32s(13);
firstMip = reader.ReadUInt32();
imageCount = reader.ReadUInt32();
firstSlice = reader.ReadUInt32();
numSlices = reader.ReadUInt32();
compSel = reader.ReadBytes(4);
texRegs = reader.ReadUInt32s(5);
}
public void Write(FileWriter writer)
{
writer.Write(dim);
writer.Write(width);
writer.Write(height);
writer.Write(depth);
writer.Write(numMips);
writer.Write(format);
writer.Write(aa);
writer.Write(use);
writer.Write(imageSize);
writer.Write(imagePtr);
writer.Write(mipSize);
writer.Write(mipPtr);
writer.Write(tileMode);
writer.Write(swizzle);
writer.Write(alignment);
writer.Write(pitch);
writer.Write(mipOffset);
writer.Write(firstMip);
writer.Write(imageCount);
writer.Write(firstSlice);
writer.Write(numSlices);
writer.Write(compSel);
writer.Write(texRegs);
}
}
}
}

View File

@ -1,449 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
namespace FirstPlugin
{
public class NUTEXB : STGenericTexture, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "TEX" };
public string[] Extension { get; set; } = new string[] { "*.nutexb" };
public string Magic { get; set; } = "XET";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public enum NUTEXImageFormat : byte
{
R8G8B8A8_UNORM = 0x00,
R8G8B8A8_SRGB = 0x05,
R32G32B32A32_FLOAT = 0x34,
B8G8R8A8_UNORM = 0x50,
B8G8R8A8_SRGB = 0x55,
BC1_UNORM = 0x80,
BC1_SRGB = 0x85,
BC2_UNORM = 0x90,
BC2_SRGB = 0x95,
BC3_UNORM = 0xa0,
BC3_SRGB = 0xa5,
BC4_UNORM = 0xb0,
BC4_SNORM = 0xb5,
BC5_UNORM = 0xc0,
BC5_SNORM = 0xc5,
BC6_UFLOAT = 0xd7,
BC7_UNORM = 0xe0,
BC7_SRGB = 0xe5,
};
public static uint blk_dims(byte format)
{
switch (format)
{
case (byte)NUTEXImageFormat.BC1_UNORM:
case (byte)NUTEXImageFormat.BC1_SRGB:
case (byte)NUTEXImageFormat.BC2_UNORM:
case (byte)NUTEXImageFormat.BC2_SRGB:
case (byte)NUTEXImageFormat.BC3_UNORM:
case (byte)NUTEXImageFormat.BC3_SRGB:
case (byte)NUTEXImageFormat.BC4_UNORM:
case (byte)NUTEXImageFormat.BC4_SNORM:
case (byte)NUTEXImageFormat.BC5_UNORM:
case (byte)NUTEXImageFormat.BC5_SNORM:
case (byte)NUTEXImageFormat.BC6_UFLOAT:
case (byte)NUTEXImageFormat.BC7_UNORM:
case (byte)NUTEXImageFormat.BC7_SRGB:
return 0x44;
default: return 0x11;
}
}
public static uint bpps(byte format)
{
switch (format)
{
case (byte)NUTEXImageFormat.B8G8R8A8_UNORM:
case (byte)NUTEXImageFormat.B8G8R8A8_SRGB:
case (byte)NUTEXImageFormat.R8G8B8A8_UNORM:
case (byte)NUTEXImageFormat.R8G8B8A8_SRGB:
return 4;
case (byte)NUTEXImageFormat.BC1_UNORM:
case (byte)NUTEXImageFormat.BC1_SRGB:
case (byte)NUTEXImageFormat.BC4_UNORM:
case (byte)NUTEXImageFormat.BC4_SNORM:
return 8;
case (byte)NUTEXImageFormat.R32G32B32A32_FLOAT:
case (byte)NUTEXImageFormat.BC2_UNORM:
case (byte)NUTEXImageFormat.BC2_SRGB:
case (byte)NUTEXImageFormat.BC3_UNORM:
case (byte)NUTEXImageFormat.BC3_SRGB:
case (byte)NUTEXImageFormat.BC5_UNORM:
case (byte)NUTEXImageFormat.BC5_SNORM:
case (byte)NUTEXImageFormat.BC6_UFLOAT:
case (byte)NUTEXImageFormat.BC7_UNORM:
case (byte)NUTEXImageFormat.BC7_SRGB:
return 16;
default: return 0x00;
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
types.Add(typeof(MenuExt));
return types.ToArray();
}
}
class MenuExt : IFileMenuExtension
{
public ToolStripItemDark[] NewFileMenuExtensions => null;
public ToolStripItemDark[] ToolsMenuExtensions => newFileExt;
public ToolStripItemDark[] TitleBarExtensions => null;
public ToolStripItemDark[] CompressionMenuExtensions => null;
public ToolStripItemDark[] ExperimentalMenuExtensions => null;
ToolStripItemDark[] newFileExt = new ToolStripItemDark[1];
public MenuExt()
{
newFileExt[0] = new ToolStripItemDark("Batch Export NUTEXB");
newFileExt[0].Click += Export;
}
private void Export(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
foreach (string file in ofd.FileNames)
{
NUTEXB texture = new NUTEXB();
texture.Read(new FileReader(file));
Console.WriteLine(texture.Format.ToString("x") + " " + file + " " + texture.Text);
try
{
Bitmap bitmap = texture.GetBitmap();
if (bitmap != null)
bitmap.Save(System.IO.Path.GetFullPath(file) + texture.ArcOffset + texture.Text + ".png");
else
Console.WriteLine(" Not supported Format! " + texture.Format);
if (bitmap != null)
bitmap.Dispose();
}
catch
{
Console.WriteLine("Something went wrong??");
}
texture.Surfaces.Clear();
texture = null;
GC.Collect();
}
}
}
}
public bool BadSwizzle;
public uint Width;
public uint Height;
public uint unk;
public int unk2;
public int unk3;
public NUTEXImageFormat Format;
public List<uint[]> mipSizes = new List<uint[]>();
public int Alignment;
public byte[] ImageData;
bool IsSwizzled = true;
public string ArcOffset; //Temp for exporting in batch
private void Replace(object sender, EventArgs args)
{
OpenFileDialog ofd = new OpenFileDialog();
/* ofd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";*/
ofd.Filter = "Supported Formats|*.dds;" +
"Microsoft DDS |*.dds" +
"All files(*.*)|*.*";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
var bntxFile = new BNTX();
var tex = new TextureData();
tex.Replace(ofd.FileName);
if (Surfaces[0].mipmaps[0].Length != Surfaces[0].mipmaps[0].Length)
throw new Exception("Image must be the same size!");
if (Surfaces[0].mipmaps.Count != tex.Surfaces[0].mipmaps.Count)
throw new Exception("Map map count must be the same!");
if (Width != tex.Texture.Width || Height != tex.Texture.Height)
throw new Exception("Image size must be the same!");
ImageData = tex.Texture.TextureData[0][0];
Surfaces = tex.Surfaces;
Width = tex.Texture.Width;
Height = tex.Texture.Height;
UpdateEditor();
}
}
private void Export(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = Text;
sfd.DefaultExt = "png";
sfd.Filter = "Supported Formats|*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
Export(sfd.FileName);
}
}
private void Save(object sender, EventArgs args)
{
List<IFileFormat> formats = new List<IFileFormat>();
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(formats);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName);
}
}
public void Export(string FileName, bool ExportSurfaceLevel = false,
bool ExportMipMapLevel = false, int SurfaceLevel = 0, int MipLevel = 0)
{
string ext = System.IO.Path.GetExtension(FileName);
ext = ext.ToLower();
switch (ext)
{
case ".dds":
SaveDDS(FileName);
break;
default:
SaveBitMap(FileName);
break;
}
}
public void Read(FileReader reader)
{
ImageKey = "Texture";
SelectedImageKey = "Texture";
long pos = reader.BaseStream.Length;
string magic = reader.ReadMagic((int)pos - 7, 3);//Check magic first!
if (magic != "XET")
throw new Exception($"Invalid magic! Expected XET but got {magic}");
reader.Seek(pos - 112, System.IO.SeekOrigin.Begin); //Subtract size where the name occurs
byte padding = reader.ReadByte();
Text = reader.ReadString(Syroot.BinaryData.BinaryStringFormat.ZeroTerminated);
reader.Seek(pos - 48, System.IO.SeekOrigin.Begin); //Subtract size of header
uint padding2 = reader.ReadUInt32();
Width = reader.ReadUInt32();
Height = reader.ReadUInt32();
unk3 = reader.ReadInt32();
Format = reader.ReadEnum<NUTEXImageFormat>(true);
unk = reader.ReadByte(); //Related to pixel size??
ushort padding3 = reader.ReadUInt16();
unk2 = reader.ReadInt32();
uint mipCount = reader.ReadUInt32();
Alignment = reader.ReadInt32();
uint ArrayCount = reader.ReadUInt32(); //6 for cubemaps
int imagesize = reader.ReadInt32();
reader.Seek(imagesize, System.IO.SeekOrigin.Begin); //Get mipmap sizes
for (int arrayLevel = 0; arrayLevel < ArrayCount; arrayLevel++)
{
long mipPos = reader.Position;
uint[] mips = reader.ReadUInt32s((int)mipCount);
mipSizes.Add(mips);
//Each mip section is 0x40 size for each array
//Seek to next one
reader.Seek(mipPos + 0x40, System.IO.SeekOrigin.Begin);
}
reader.Seek(0, System.IO.SeekOrigin.Begin);
ImageData = reader.ReadBytes(imagesize);
LoadTexture();
}
public void Write(FileWriter writer)
{
int arrayCount = mipSizes.Count;
writer.Write(ImageData); //Write textue block first
long headerStart = writer.Position;
foreach (var mips in mipSizes)
{
long MipStart = writer.Position;
writer.Write(mips); //Write textue block first
writer.Seek(MipStart + 0x40, System.IO.SeekOrigin.Begin);
}
long stringPos = writer.Position;
writer.Write((byte)0x20);
writer.WriteString(Text);
writer.Seek(stringPos + 0x40, System.IO.SeekOrigin.Begin);
writer.Seek(4); //padding
writer.Write(Width);
writer.Write(Height);
writer.Write(unk3);
writer.Write((byte)Format);
writer.Write((byte)unk);
writer.Seek(2); //padding
writer.Write(unk2);
writer.Write(mipSizes.Count);
writer.Write(Alignment);
writer.Write(arrayCount);
writer.Write(ImageData.Length);
writer.WriteSignature(" XET");
writer.Write(131073);
}
public override void OnClick(TreeView treeView)
{
}
public void UpdateEditor()
{
}
public void LoadTexture(int target = 1)
{
Surfaces.Clear();
uint blk_dim = blk_dims((byte)Format);
uint blkWidth = blk_dim >> 4;
uint blkHeight = blk_dim & 0xF;
uint blockHeight = TegraX1Swizzle.GetBlockHeight(TegraX1Swizzle.DIV_ROUND_UP(Height, blkHeight));
uint BlockHeightLog2 = (uint)Convert.ToString(blockHeight, 2).Length - 1;
uint tileMode = 0;
int linesPerBlockHeight = (1 << (int)BlockHeightLog2) * 8;
uint bpp = bpps((byte)Format);
for (int arrayLevel = 0; arrayLevel < mipSizes.Count; arrayLevel++)
{
int blockHeightShift = 0;
uint mipOffset = 0;
List<byte[]> mips = new List<byte[]>();
for (int mipLevel = 0; mipLevel < mipSizes[arrayLevel].Length; mipLevel++)
{
//Get the size from the size array
int MipSize = (int)mipSizes[arrayLevel][mipLevel];
//Align the size
if (mipLevel == 0)
if (MipSize % Alignment != 0) MipSize = MipSize + (Alignment - (MipSize % Alignment));
uint width = (uint)Math.Max(1, Width >> mipLevel);
uint height = (uint)Math.Max(1, Height >> mipLevel);
uint size = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight) * bpp;
if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
blockHeightShift += 1;
Console.WriteLine($"{blk_dim.ToString("x")} {bpp} {width} {height} {linesPerBlockHeight} {blkWidth} {blkHeight} {size} { ImageData.Length}");
try
{
byte[] result = TegraX1Swizzle.deswizzle(width, height, blkWidth, blkHeight, target, bpp, tileMode, (int)Math.Max(0, BlockHeightLog2 - blockHeightShift), ImageData);
//Create a copy and use that to remove uneeded data
byte[] result_ = new byte[size];
Array.Copy(result, mipOffset, result_, 0, size);
mips.Add(result_);
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show($"Failed to swizzle texture {Text}!");
Console.WriteLine(e);
BadSwizzle = true;
break;
}
mipOffset += (uint)MipSize;
break;
}
Surfaces.Add(new Surface() { mipmaps = mips });
}
}
MenuItem save = new MenuItem("Save");
MenuItem export = new MenuItem("Export");
MenuItem replace = new MenuItem("Replace");
public void Load()
{
IsActive = true;
Text = FileName;
Read(new FileReader(Data));
ImageKey = "Texture";
SelectedImageKey = "Texture";
ContextMenu = new ContextMenu();
ContextMenu.MenuItems.Add(save);
ContextMenu.MenuItems.Add(export);
ContextMenu.MenuItems.Add(replace);
save.Click += Save;
replace.Click += Replace;
export.Click += Export;
}
public void Unload()
{
}
public byte[] Save()
{
System.IO.MemoryStream mem = new System.IO.MemoryStream();
Write(new FileWriter(mem));
return mem.ToArray();
}
}
}

View File

@ -1,159 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FirstPlugin
{
public class TegraX1Swizzle
{
public struct Surface
{
public sbyte dim;
public int depth;
public ushort numMips;
public uint format;
public int imageSize;
public sbyte tileMode;
public ushort swizzle;
public int alignment;
public int sizeRange;
public List<byte[]> data;
public int[] mipOffset;
public int width
{
set;
get;
}
public int height
{
set;
get;
}
}
/*---------------------------------------
*
* Code ported from AboodXD's BNTX Extractor https://github.com/aboood40091/BNTX-Extractor/blob/master/swizzle.py
*
*---------------------------------------*/
public static uint GetBlockHeight(uint height)
{
uint blockHeight = pow2_round_up(height / 8);
if (blockHeight > 16)
blockHeight = 16;
return blockHeight;
}
public static uint DIV_ROUND_UP(uint n, uint d)
{
return (n + d - 1) / d;
}
public static uint round_up(uint x, uint y)
{
return ((x - 1) | (y - 1)) + 1;
}
public static uint pow2_round_up(uint x)
{
x -= 1;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
return x + 1;
}
public static byte[] _swizzle(uint width, uint height, uint blkWidth, uint blkHeight, int roundPitch, uint bpp, uint tileMode, int blockHeightLog2, byte[] data, int toSwizzle)
{
uint block_height = (uint)(1 << blockHeightLog2);
// Console.WriteLine($"Swizzle {width} {height} {blkWidth} {blkHeight} {roundPitch} {bpp} {tileMode} {blockHeightLog2} {data.Length} {toSwizzle}");
width = DIV_ROUND_UP(width, blkWidth);
height = DIV_ROUND_UP(height, blkHeight);
uint pitch;
uint surfSize;
if (tileMode == 1)
{
pitch = width * bpp;
if (roundPitch == 1)
pitch = round_up(pitch, 32);
surfSize = pitch * height;
}
else
{
pitch = round_up(width * bpp, 64);
surfSize = pitch * round_up(height, block_height * 8);
}
byte[] result = new byte[surfSize];
for (uint y = 0; y < height; y++)
{
for (uint x = 0; x < width; x++)
{
uint pos;
uint pos_;
if (tileMode == 1)
pos = y * pitch + x * bpp;
else
pos = getAddrBlockLinear(x, y, width, bpp, 0, block_height);
pos_ = (y * width + x) * bpp;
if (pos + bpp <= surfSize)
{
if (toSwizzle == 0)
Array.Copy(data, pos, result, pos_, bpp);
else
Array.Copy(data, pos_, result, pos, bpp);
}
}
}
return result;
}
public static byte[] deswizzle(uint width, uint height, uint blkWidth, uint blkHeight, int roundPitch, uint bpp, uint tileMode, int size_range, byte[] data)
{
return _swizzle(width, height, blkWidth, blkHeight, roundPitch, bpp, tileMode, size_range, data, 0);
}
public static byte[] swizzle(uint width, uint height, uint blkWidth, uint blkHeight, int roundPitch, uint bpp, uint tileMode, int size_range, byte[] data)
{
return _swizzle(width, height, blkWidth, blkHeight, roundPitch, bpp, tileMode, size_range, data, 1);
}
static uint getAddrBlockLinear(uint x, uint y, uint width, uint bytes_per_pixel, uint base_address, uint block_height)
{
/*
From Tega X1 TRM
*/
uint image_width_in_gobs = DIV_ROUND_UP(width * bytes_per_pixel, 64);
uint GOB_address = (base_address
+ (y / (8 * block_height)) * 512 * block_height * image_width_in_gobs
+ (x * bytes_per_pixel / 64) * 512 * block_height
+ (y % (8 * block_height) / 8) * 512);
x *= bytes_per_pixel;
uint Address = (GOB_address + ((x % 64) / 32) * 256 + ((y % 8) / 2) * 64
+ ((x % 32) / 16) * 32 + (y % 2) * 16 + (x % 16));
return Address;
}
}
}

View File

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FirstPlugin
{
class TexConv
{
}
}

View File

@ -1,313 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;
using Switch_Toolbox;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.IO;
namespace FirstPlugin
{
public class XTX : TreeNodeFile, IFileFormat
{
public bool CanSave { get; set; } = false;
public bool FileIsEdited { get; set; } = false;
public bool FileIsCompressed { get; set; } = false;
public string[] Description { get; set; } = new string[] { "XTX" };
public string[] Extension { get; set; } = new string[] { "*.xtx", "*.z" };
public string Magic { get; set; } = "DFvN ";
public CompressionType CompressionType { get; set; } = CompressionType.None;
public byte[] Data { get; set; }
public string FileName { get; set; }
public bool IsActive { get; set; } = false;
public bool UseEditMenu { get; set; } = false;
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public void Load()
{
IsActive = true;
Text = FileName;
LoadFile(Data);
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
public class XTXFormats
{
public enum XTXImageFormat : uint
{
NVN_FORMAT_RGBA8 = 0x00000025,
NVN_FORMAT_RGBA8_SRGB = 0x00000038,
NVN_FORMAT_RGB10A2 = 0x0000003d,
NVN_FORMAT_RGB565 = 0x0000003c,
NVN_FORMAT_RGB5A1 = 0x0000003b,
NVN_FORMAT_RGBA4 = 0x00000039,
NVN_FORMAT_R8 = 0x00000001,
NVN_FORMAT_RG8 = 0x0000000d,
DXT1 = 0x00000042,
DXT3 = 0x00000043,
DXT5 = 0x00000044,
BC4U = 0x00000049,
BC4S = 0x0000004a,
BC5U = 0x0000004b,
BC5S = 0x0000004c,
};
public static uint blk_dims(uint format)
{
switch (format)
{
case (uint)XTXImageFormat.DXT1:
case (uint)XTXImageFormat.DXT3:
case (uint)XTXImageFormat.DXT5:
case (uint)XTXImageFormat.BC4U:
case (uint)XTXImageFormat.BC4S:
case (uint)XTXImageFormat.BC5U:
case (uint)XTXImageFormat.BC5S:
case 0x2d:
return 0x44;
default: return 0x11;
}
}
public static uint bpps(uint format)
{
switch (format)
{
case (uint)XTXImageFormat.NVN_FORMAT_R8:
return 1;
case (uint)XTXImageFormat.NVN_FORMAT_RGBA8:
case (uint)XTXImageFormat.NVN_FORMAT_RGBA8_SRGB:
case (uint)XTXImageFormat.NVN_FORMAT_RGB10A2:
return 4;
case (uint)XTXImageFormat.NVN_FORMAT_RGB565:
case (uint)XTXImageFormat.NVN_FORMAT_RGB5A1:
case (uint)XTXImageFormat.NVN_FORMAT_RGBA4:
case (uint)XTXImageFormat.NVN_FORMAT_RG8:
return 2;
case (uint)XTXImageFormat.DXT1:
case (uint)XTXImageFormat.BC4S:
case (uint)XTXImageFormat.BC4U:
return 8;
case (uint)XTXImageFormat.DXT3:
case (uint)XTXImageFormat.DXT5:
case (uint)XTXImageFormat.BC5U:
case (uint)XTXImageFormat.BC5S:
return 16;
default: return 0x00;
}
}
}
public uint HeaderSize { get; set; }
public uint MajorVersion { get; set; }
public uint MinorVersion { get; set; }
public BlockHeader blockHeader { get; set; }
private const int texHeadBlkType = 2;
private const int dataBlkType = 3;
public void LoadFile(byte[] data)
{
FileReader reader = new FileReader(new MemoryStream(data));
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "DFvN")
throw new Exception($"Invalid signature {Signature}! Expected DFvN.");
HeaderSize = reader.ReadUInt32();
MajorVersion = reader.ReadUInt32();
MinorVersion = reader.ReadUInt32();
blockHeader = new BlockHeader();
blockHeader.Read(reader);
}
public override void OnClick(TreeView treeview)
{
UpdateEditor();
}
public void UpdateEditor()
{
if (Viewport.Instance.gL_ControlModern1.Visible == false)
PluginRuntime.FSHPDockState = WeifenLuo.WinFormsUI.Docking.DockState.Document;
XTXEditor docked = (XTXEditor)LibraryGUI.Instance.GetContentDocked(new XTXEditor());
if (docked == null)
{
docked = new XTXEditor();
LibraryGUI.Instance.LoadDockContent(docked, PluginRuntime.FSHPDockState);
}
docked.Text = Text;
docked.Dock = DockStyle.Fill;
docked.LoadProperty(blockHeader.textureInfo);
}
public class BlockHeader
{
public uint BlockSize { get; set; }
public UInt64 DataSize { get; set; }
public uint BlockType { get; set; }
public uint GlobalBlockIndex { get; set; }
public uint IncBlockTypeIndex { get; set; }
public TextureInfo textureInfo { get; set; }
public long DataOffset;
public void Read(FileReader reader)
{
string Signature = reader.ReadString(4, Encoding.ASCII);
if (Signature != "HBvN")
throw new Exception($"Invalid signature {Signature}! Expected HBvN.");
BlockSize = reader.ReadUInt32();
DataSize = reader.ReadUInt64();
DataOffset = reader.ReadInt64();
BlockType = reader.ReadUInt32();
GlobalBlockIndex = reader.ReadUInt32();
IncBlockTypeIndex = reader.ReadUInt32();
if (BlockType == texHeadBlkType)
{
textureInfo = new TextureInfo();
textureInfo.Read(reader);
}
if (BlockType == dataBlkType)
{
}
}
}
public class TextureInfo : STGenericTexture
{
public UInt64 DataSize { get; set; }
public uint Alignment { get; set; }
public uint Depth { get; set; }
public uint Target { get; set; }
public XTXFormats.XTXImageFormat Format { get; set; }
public uint MipCount { get; set; }
public uint SliceSize { get; set; }
public uint[] MipOffsets { get; set; }
public BlockHeader DataBlockHeader { get; set; }
public byte[] ImageData;
public void Read(FileReader reader)
{
DataSize = reader.ReadUInt64();
Alignment = reader.ReadUInt32();
Width = reader.ReadUInt32();
Height = reader.ReadUInt32();
Depth = reader.ReadUInt32();
Target = reader.ReadUInt32();
Format = reader.ReadEnum<XTXFormats.XTXImageFormat>(true);
MipCount = reader.ReadUInt32();
SliceSize = reader.ReadUInt32();
long offPos = reader.Position;
MipOffsets = reader.ReadUInt32s((int)MipCount);
reader.Seek(offPos + 68, SeekOrigin.Begin);
byte[] Layout = reader.ReadBytes(8);
byte Sparse = reader.ReadByte();
reader.Seek(3);
long DataBlockOff = reader.Position;
DataBlockHeader = new BlockHeader();
DataBlockHeader.Read(reader);
reader.Seek(DataBlockOff + DataBlockHeader.DataOffset, SeekOrigin.Begin);
long datastart = reader.Position;
ImageData = reader.ReadBytes((int)DataSize);
if (ImageData.Length == 0)
throw new System.Exception("Empty data size!");
reader.Seek(DataBlockOff + DataBlockHeader.DataOffset + (long)DataBlockHeader.DataSize, SeekOrigin.Begin);
BlockHeader EndBlockHeader = new BlockHeader();
EndBlockHeader.Read(reader);
}
public void LoadTexture()
{
Surfaces.Clear();
Console.WriteLine(Format);
uint blk_dim = XTXFormats.blk_dims((uint)((int)Format >> 8));
uint blkWidth = blk_dim >> 4;
uint blkHeight = blk_dim & 0xF;
uint blockHeight = TegraX1Swizzle.GetBlockHeight(TegraX1Swizzle.DIV_ROUND_UP(Height, blkHeight));
uint BlockHeightLog2 = (uint)Convert.ToString(blockHeight, 2).Length - 1;
int linesPerBlockHeight = (1 << (int)BlockHeightLog2) * 8;
int TileMode = 0;
uint bpp = XTXFormats.bpps((uint)Format);
List<byte[]> mips = new List<byte[]>();
int blockHeightShift = 0;
for (int mipLevel = 0; mipLevel < MipOffsets.Length; mipLevel++)
{
uint width = (uint)Math.Max(1, Width >> mipLevel);
uint height = (uint)Math.Max(1, Height >> mipLevel);
// uint size = width * height * bpp;
uint size = TegraX1Swizzle.DIV_ROUND_UP(width, blkWidth) * TegraX1Swizzle.DIV_ROUND_UP(height, blkHeight) * bpp;
byte[] Output = new byte[size];
uint mipOffset;
if (mipLevel != 0)
{
mipOffset = (MipOffsets[mipLevel - 1]);
if (mipLevel == 1)
mipOffset -= (uint)size;
Array.Copy(ImageData, mipOffset, Output, 0, size);
}
else
Output = ImageData;
byte[] output = new byte[size];
Console.WriteLine(mipLevel + " " + size);
if (TegraX1Swizzle.pow2_round_up(TegraX1Swizzle.DIV_ROUND_UP(height, blkWidth)) < linesPerBlockHeight)
blockHeightShift += 1;
byte[] result = TegraX1Swizzle.deswizzle(width, height, blkWidth, blkHeight, (int)Target, bpp, (uint)TileMode, (int)Math.Max(0, BlockHeightLog2 - blockHeightShift), Output);
//Create a copy and use that to remove uneeded data
byte[] result_ = new byte[size];
Array.Copy(result, 0, result_, 0, size);
mips.Add(result_);
}
Surfaces.Add(new Surface() { mipmaps = mips });
}
}
}
}

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
</Weavers>

View File

@ -1,667 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Drawing;
using System.Threading.Tasks;
using Syroot.NintenTools.NSW.Bfres;
using Syroot.NintenTools.NSW.Bfres.Helpers;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System.Windows.Forms;
using Smash_Forge.Rendering;
using SFGraphics.GLObjects.Shaders;
using GL_Core;
using GL_Core.Interfaces;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using WeifenLuo.WinFormsUI.Docking;
using Switch_Toolbox.Library.IO;
using Switch_Toolbox.Library.Forms;
using ResU = Syroot.NintenTools.Bfres;
using Bfres.Structs;
namespace FirstPlugin
{
public class BFRESRender : AbstractGlDrawable
{
// gl buffer objects
int vbo_position;
int ibo_elements;
public Shader shader = null;
public List<FMDL> models = new List<FMDL>();
public BFRES ResFileNode;
public BFRESRender()
{
}
public void DisposeFile()
{
Destroy();
ResFileNode.Nodes.Clear();
ResFileNode.Remove();
}
private void GenerateBuffers()
{
GL.GenBuffers(1, out vbo_position);
GL.GenBuffers(1, out ibo_elements);
}
public void LoadFile(ResU.ResFile resFileU)
{
ResFileNode.Load(resFileU);
BfresWiiU.Read(this, resFileU, ResFileNode);
UpdateVertexData();
UpdateTextureMaps();
}
public void LoadFile(ResFile resFile)
{
ResFileNode.Load(resFile);
BfresSwitch.Read(this, resFile, ResFileNode);
UpdateVertexData();
UpdateTextureMaps();
}
public void Destroy()
{
GL.DeleteBuffer(vbo_position);
GL.DeleteBuffer(ibo_elements);
}
#region Rendering
bool RanOnce = false;
public override void Prepare(GL_ControlModern control)
{
}
public override void Prepare(GL_ControlLegacy control)
{
}
private void DrawBoundingBoxes()
{
foreach (FMDL mdl in models)
{
foreach (FSHP m in mdl.shapes)
{
if (m.IsSelected)
GL.Color4(Color.GhostWhite);
else
GL.Color4(Color.OrangeRed);
foreach (FSHP.BoundingBox box in m.boundingBoxes)
{
RenderTools.DrawRectangularPrism(box.Center, box.Extend.X, box.Extend.Y, box.Extend.Z, true);
}
}
}
}
public override void Draw(GL_ControlLegacy control)
{
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
if (!buffersWereInitialized)
GenerateBuffers();
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
// if (Runtime.renderBoundingBoxes)
// DrawBoundingBoxes();
if (Runtime.viewportShading != Runtime.ViewportShading.Default)
shader = OpenTKSharedResources.shaders["BFRES_Debug"];
else
shader = OpenTKSharedResources.shaders["BFRES"];
shader.UseProgram();
if (RanOnce == false)
{
// ShaderTools.SaveErrorLogs();
RanOnce = true;
}
Matrix4 camMat = control.mtxCam * control.mtxProj;
shader.SetVector3("difLightDirection", Vector3.TransformNormal(new Vector3(0f, 0f, -1f), camMat.Inverted()).Normalized());
shader.EnableVertexAttributes();
SetRenderSettings(shader);
shader.SetMatrix4x4("mvpMatrix", ref camMat);
foreach (FMDL mdl in models)
{
if (mdl.Checked)
{
foreach (FSHP shp in mdl.shapes)
{
DrawModel(shp, mdl, shader);
}
}
}
shader.DisableVertexAttributes();
GL.UseProgram(0);
GL.Disable(EnableCap.DepthTest);
GL.Enable(EnableCap.DepthTest);
}
public override void Draw(GL_ControlModern control)
{
bool buffersWereInitialized = ibo_elements != 0 && vbo_position != 0;
if (!buffersWereInitialized)
GenerateBuffers();
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
// if (Runtime.renderBoundingBoxes)
// DrawBoundingBoxes();
if (Runtime.viewportShading != Runtime.ViewportShading.Default)
shader = OpenTKSharedResources.shaders["BFRES_Debug"];
else
shader = OpenTKSharedResources.shaders["BFRES"];
shader.UseProgram();
if (RanOnce == false)
{
// ShaderTools.SaveErrorLogs();
RanOnce = true;
}
Matrix4 previewScale = Utils.TransformValues(Vector3.Zero, Vector3.Zero, Runtime.previewScale);
Matrix4 camMat = previewScale * control.mtxCam * control.mtxProj;
shader.SetVector3("difLightDirection", Vector3.TransformNormal(new Vector3(0f, 0f, -1f), camMat.Inverted()).Normalized());
shader.EnableVertexAttributes();
SetRenderSettings(shader);
shader.SetMatrix4x4("mvpMatrix", ref camMat);
GL.Enable(EnableCap.AlphaTest);
GL.AlphaFunc(AlphaFunction.Gequal, 0.1f);
foreach (FMDL mdl in models)
{
foreach (FSHP shp in mdl.shapes)
{
DrawModel(shp, mdl, shader);
}
}
shader.DisableVertexAttributes();
GL.UseProgram(0);
GL.Disable(EnableCap.DepthTest);
GL.Enable(EnableCap.DepthTest);
}
private void SetRenderSettings(Shader shader)
{
shader.SetBoolToInt("renderVertColor", Runtime.renderVertColor);
shader.SetBoolToInt("renderTevColors", Runtime.renderTevColors);
shader.SetBoolToInt("renderMatColors", Runtime.renderMatColors);
shader.SetInt("renderType", (int)Runtime.viewportShading);
shader.SetBoolToInt("useNormalMap", Runtime.useNormalMap);
shader.SetInt("uvChannel", (int)Runtime.uvChannel);
shader.SetBoolToInt("renderR", Runtime.renderR);
shader.SetBoolToInt("renderG", Runtime.renderG);
shader.SetBoolToInt("renderB", Runtime.renderB);
shader.SetBoolToInt("renderAlpha", Runtime.renderAlpha);
shader.SetInt("isTransparent", 1);
}
private static void SetDefaultTextureAttributes(FMAT mat, Shader shader)
{
shader.SetBoolToInt("HasDiffuse", mat.HasDiffuseMap);
shader.SetBoolToInt("HasDiffuseLayer", mat.HasDiffuseLayer);
shader.SetBoolToInt("HasNormalMap", mat.HasNormalMap);
shader.SetBoolToInt("HasEmissionMap", mat.HasEmissionMap);
shader.SetBoolToInt("HasLightMap", mat.HasLightMap);
shader.SetBoolToInt("HasShadowMap", mat.HasShadowMap);
shader.SetBoolToInt("HasSpecularMap", mat.HasSpecularMap);
shader.SetBoolToInt("HasTeamColorMap", mat.HasTeamColorMap);
shader.SetBoolToInt("HasSphereMap", mat.HasSphereMap);
shader.SetBoolToInt("HasSubSurfaceScatteringMap", mat.HasSubSurfaceScatteringMap);
//Unused atm untill I do PBR shader
shader.SetBoolToInt("HasMetalnessMap", mat.HasMetalnessMap);
shader.SetBoolToInt("HasRoughnessMap", mat.HasRoughnessMap);
shader.SetBoolToInt("HasMRA", mat.HasMRA);
}
private static void SetBoneUniforms(Shader shader, FMDL fmdl)
{
for (int i = 0; i < fmdl.Skeleton.Node_Array.Length; i++)
{
/* Matrix3x4 transform3x4 = fmdl.Skeleton.matrices[fmdl.Skeleton.Node_Array[i]];
Matrix4 transform = new Matrix4(transform3x4.Row0, transform3x4.Row1,
transform3x4.Row2, new Vector4(0, 0, 0, 1));*/
Matrix4 transform = fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].invert * fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].transform;
GL.UniformMatrix4(GL.GetUniformLocation(shader.Id, String.Format("bones[{0}]", i)), false, ref transform);
}
}
private static void SetTextureUniforms(FMAT mat, FSHP m, Shader shader)
{
SetDefaultTextureAttributes(mat, shader);
GL.ActiveTexture(TextureUnit.Texture0);
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.Id);
shader.SetTexture("UVTestPattern", RenderTools.uvTestPattern, 10);
GL.Uniform1(shader.GetAttribLocation("normalMap"), 0);
GL.Uniform1(shader.GetAttribLocation("BakeShadowMap"), 0);
// PBR IBL
// shader.SetTexture("irradianceMap", RenderTools.diffusePbr, 18);
// shader.SetTexture("specularIbl", RenderTools.specularPbr, 19);
foreach (MatTexture matex in mat.TextureMaps)
{
if (matex.Type == MatTexture.TextureType.Diffuse)
TextureUniform(shader, mat, mat.HasDiffuseMap, "DiffuseMap", matex);
else if (matex.Type == MatTexture.TextureType.Normal)
TextureUniform(shader, mat, mat.HasNormalMap, "NormalMap", matex);
else if (matex.Type == MatTexture.TextureType.Emission)
TextureUniform(shader, mat, mat.HasEmissionMap, "EmissionMap", matex);
else if (matex.Type == MatTexture.TextureType.Specular)
TextureUniform(shader, mat, mat.HasSpecularMap, "SpecularMap", matex);
else if (matex.Type == MatTexture.TextureType.Shadow)
TextureUniform(shader, mat, mat.HasShadowMap, "BakeShadowMap", matex);
else if (matex.Type == MatTexture.TextureType.Light)
TextureUniform(shader, mat, mat.HasLightMap, "BakeLightMap", matex);
else if (matex.Type == MatTexture.TextureType.Metalness)
TextureUniform(shader, mat, mat.HasMetalnessMap, "MetalnessMap", matex);
else if (matex.Type == MatTexture.TextureType.Roughness)
TextureUniform(shader, mat, mat.HasRoughnessMap, "RoughnessMap", matex);
else if (matex.Type == MatTexture.TextureType.TeamColor)
TextureUniform(shader, mat, mat.HasTeamColorMap, "TeamColorMap", matex);
else if (matex.Type == MatTexture.TextureType.Transparency)
TextureUniform(shader, mat, mat.HasTransparencyMap, "TransparencyMap", matex);
else if (matex.Type == MatTexture.TextureType.DiffuseLayer2)
TextureUniform(shader, mat, mat.HasDiffuseLayer, "DiffuseLayer", matex);
else if (matex.Type == MatTexture.TextureType.SphereMap)
TextureUniform(shader, mat, mat.HasSphereMap, "SphereMap", matex);
else if (matex.Type == MatTexture.TextureType.SubSurfaceScattering)
TextureUniform(shader, mat, mat.HasSubSurfaceScatteringMap, "SubSurfaceScatteringMap", matex);
else if (matex.Type == MatTexture.TextureType.MRA)
TextureUniform(shader, mat, mat.HasMRA, "MRA", matex);
}
}
private static void TextureUniform(Shader shader, FMAT mat, bool hasTex, string name, MatTexture mattex)
{
// Bind the texture and create the uniform if the material has the right textures.
if (hasTex)
{
GL.Uniform1(shader.GetUniformLocation(name), BindTexture(mattex, mat.GetResFileU() != null));
}
}
public static int BindTexture(MatTexture tex, bool IsWiiU)
{
GL.ActiveTexture(TextureUnit.Texture0 + tex.hash + 1);
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.Id);
if (IsWiiU)
{
foreach (var ftexContainer in PluginRuntime.ftexContainers)
{
if (ftexContainer.Textures.ContainsKey(tex.Name))
{
BindGLTexture(tex, ftexContainer.Textures[tex.Name].RenderableTex.display);
}
}
}
else
{
foreach (var bntx in PluginRuntime.bntxContainers)
{
if (bntx.Textures.ContainsKey(tex.Name))
{
BindGLTexture(tex, bntx.Textures[tex.Name].RenderableTex.display);
}
}
}
return tex.hash + 1;
}
private static void BindGLTexture(MatTexture tex, int texid)
{
// GL.ActiveTexture(TextureUnit.Texture0 + texid);
GL.BindTexture(TextureTarget.Texture2D, texid);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)MatTexture.wrapmode[tex.wrapModeS]);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)MatTexture.wrapmode[tex.wrapModeT]);
GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, 0.0f);
}
private void DrawModel(FSHP m, FMDL mdl, Shader shader, bool drawSelection = false)
{
if (m.lodMeshes[m.DisplayLODIndex].faces.Count <= 3)
return;
SetUniforms(m.GetMaterial(), shader, m, m.DisplayId);
SetTextureUniforms(m.GetMaterial(), m, shader);
SetBoneUniforms(shader, mdl);
SetVertexAttributes(m, shader);
ApplyTransformFix(mdl, m, shader);
if (m.Checked && m.Parent.Parent.Checked)
{
if ((m.IsSelected))
{
DrawModelSelection(m, shader);
}
else
{
if (Runtime.RenderModelWireframe)
{
DrawModelWireframe(m, shader);
}
if (Runtime.RenderModels)
{
PrimitiveType primitiveType = PrimitiveType.Triangles;
switch (m.lodMeshes[m.DisplayLODIndex].PrimitiveType)
{
case STPolygonType.Line:
primitiveType = PrimitiveType.Lines;
break;
case STPolygonType.LineStrip:
primitiveType = PrimitiveType.LineStrip;
break;
case STPolygonType.Point:
primitiveType = PrimitiveType.Points;
break;
case STPolygonType.Triangle:
primitiveType = PrimitiveType.Triangles;
break;
}
GL.DrawElements(primitiveType, m.lodMeshes[m.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
}
}
}
}
private static void ApplyTransformFix(FMDL fmdl, FSHP m, Shader shader)
{
shader.SetInt("NoSkinning", 0);
shader.SetInt("RigidSkinning", 0);
//Some objects will have no weights or indices. These will weigh to the bone index in the shape section.
shader.SetInt("SingleBoneIndex", m.boneIndx);
if (m.VertexSkinCount == 1)
{
shader.SetInt("RigidSkinning", 1);
}
if (m.VertexSkinCount == 0)
{
Matrix4 transform = fmdl.Skeleton.bones[m.boneIndx].invert * fmdl.Skeleton.bones[m.boneIndx].transform;
shader.SetMatrix4x4("singleBoneBindTransform", ref transform);
shader.SetInt("NoSkinning", 1);
}
}
public void UpdateVertexData()
{
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
DisplayVertex[] Vertices;
int[] Faces;
int poffset = 0;
int voffset = 0;
List<DisplayVertex> Vs = new List<DisplayVertex>();
List<int> Ds = new List<int>();
foreach (FMDL mdl in models)
{
foreach (FSHP m in mdl.shapes)
{
m.Offset = poffset * 4;
List<DisplayVertex> pv = m.CreateDisplayVertices();
Vs.AddRange(pv);
for (int i = 0; i < m.lodMeshes[m.DisplayLODIndex].displayFaceSize; i++)
{
Ds.Add(m.display[i] + voffset);
}
poffset += m.lodMeshes[m.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);
Viewport.Instance.UpdateViewport();
}
public void UpdateSingleMaterialTextureMaps(FMAT mat)
{
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
foreach (BNTX bntx in PluginRuntime.bntxContainers)
{
foreach (var t in mat.TextureMaps)
{
if (bntx.Textures.ContainsKey(t.Name))
{
if (!bntx.Textures[t.Name].GLInitialized)
bntx.Textures[t.Name].LoadOpenGLTexture();
}
}
}
Viewport.Instance.UpdateViewport();
}
public void UpdateTextureMaps()
{
if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Unitialized)
return;
foreach (BNTX bntx in PluginRuntime.bntxContainers)
{
if (!bntx.AllGLInitialized)
{
foreach (var tex in bntx.Textures)
{
if (!tex.Value.GLInitialized)
tex.Value.LoadOpenGLTexture();
}
}
}
foreach (FTEXContainer ftexCont in PluginRuntime.ftexContainers)
{
foreach (var tex in ftexCont.Textures)
{
tex.Value.LoadOpenGLTexture();
}
}
Viewport.Instance.UpdateViewport();
}
private static void SetUniforms(FMAT mat, Shader shader, FSHP m, int id)
{
shader.SetVector4("gsys_bake_st0", new Vector4(1, 1, 0, 0));
shader.SetVector4("gsys_bake_st1", new Vector4(1, 1, 0, 0));
shader.SetVector4("tev_color0", new Vector4(1, 1, 0, 0));
shader.SetVector4("tev_color1", new Vector4(1, 1, 0, 0));
shader.SetVector4("mat_color0", new Vector4(1, 1, 0, 0));
shader.SetVector4("mat_color1", new Vector4(1, 1, 0, 0));
shader.SetVector4("const_color0", new Vector4(1, 1, 1, 1));
shader.SetVector4("base_color_mul_color", new Vector4(1, 1, 1, 1));
shader.SetInt("enableCellShading", 0);
bool HasTans = m.vertexAttributes.Any(x => x.Name == "_t0");
shader.SetBoolToInt("hasTangents", HasTans);
SetUniformData(mat, shader, "gsys_bake_st0");
SetUniformData(mat, shader, "gsys_bake_st1");
SetUniformData(mat, shader, "const_color0");
SetUniformData(mat, shader, "tev_color0");
SetUniformData(mat, shader, "tev_color1");
SetUniformData(mat, shader, "mat_color0");
SetUniformData(mat, shader, "mat_color1");
}
private static void SetUniformData(FMAT mat, Shader shader, string propertyName)
{
if (mat.shaderassign.options.ContainsKey(propertyName))
{
float value = float.Parse(mat.shaderassign.options[propertyName]);
shader.SetFloat(propertyName, value);
}
if (mat.matparam.ContainsKey(propertyName))
{
if (mat.matparam[propertyName].Type == ShaderParamType.Float)
{
if (mat.anims.ContainsKey(propertyName))
mat.matparam[propertyName].ValueFloat[0] = mat.anims[propertyName][0];
shader.SetFloat(propertyName, mat.matparam[propertyName].ValueFloat[0]);
}
if (mat.matparam[propertyName].Type == ShaderParamType.Float2)
{
if (mat.anims.ContainsKey(propertyName))
{
mat.matparam[propertyName].ValueFloat = new float[2] {
mat.anims[propertyName][0], mat.anims[propertyName][1]};
}
shader.SetVector2(propertyName, Utils.ToVec2(mat.matparam[propertyName].ValueFloat));
}
if (mat.matparam[propertyName].Type == ShaderParamType.Float3)
{
if (mat.anims.ContainsKey(propertyName))
{
mat.matparam[propertyName].ValueFloat = new float[3] {
mat.anims[propertyName][0],
mat.anims[propertyName][1],
mat.anims[propertyName][2]};
}
shader.SetVector3(propertyName, Utils.ToVec3(mat.matparam[propertyName].ValueFloat));
}
if (mat.matparam[propertyName].Type == ShaderParamType.Float4)
{
if (mat.anims.ContainsKey(propertyName))
{
mat.matparam[propertyName].ValueFloat = new float[4] {
mat.anims[propertyName][0], mat.anims[propertyName][1],
mat.anims[propertyName][2], mat.anims[propertyName][3]};
}
shader.SetVector4(propertyName, Utils.ToVec4(mat.matparam[propertyName].ValueFloat));
}
if (mat.matparam[propertyName].Type == ShaderParamType.TexSrt)
{
// Vector 2 Scale
// 1 roation float
// Vector2 translate
TexSrt texSRT = mat.matparam[propertyName].ValueTexSrt;
shader.SetVector2("SRT_Scale", Utils.ToVec2(texSRT.Scaling));
shader.SetFloat("SRT_Rotate", texSRT.Rotation);
shader.SetVector2("SRT_Translate", Utils.ToVec2(texSRT.Translation));
}
}
}
private void SetVertexAttributes(FSHP m, Shader shader)
{
GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
GL.VertexAttribPointer(shader.GetAttribLocation("vPosition"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 0);
GL.VertexAttribPointer(shader.GetAttribLocation("vNormal"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 12);
GL.VertexAttribPointer(shader.GetAttribLocation("vTangent"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 24);
GL.VertexAttribPointer(shader.GetAttribLocation("vBitangent"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 36);
GL.VertexAttribPointer(shader.GetAttribLocation("vUV0"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 48);
GL.VertexAttribPointer(shader.GetAttribLocation("vColor"), 4, VertexAttribPointerType.Float, false, DisplayVertex.Size, 56);
GL.VertexAttribIPointer(shader.GetAttribLocation("vBone"), 4, VertexAttribIntegerType.Int, DisplayVertex.Size, new IntPtr(72));
GL.VertexAttribPointer(shader.GetAttribLocation("vWeight"), 4, VertexAttribPointerType.Float, false, DisplayVertex.Size, 88);
GL.VertexAttribPointer(shader.GetAttribLocation("vUV1"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 104);
GL.VertexAttribPointer(shader.GetAttribLocation("vUV2"), 2, VertexAttribPointerType.Float, false, DisplayVertex.Size, 112);
GL.VertexAttribPointer(shader.GetAttribLocation("vPosition2"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 124);
GL.VertexAttribPointer(shader.GetAttribLocation("vPosition3"), 3, VertexAttribPointerType.Float, false, DisplayVertex.Size, 136);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
}
private static void DrawModelWireframe(STGenericObject p, Shader shader)
{
// use vertex color for wireframe color
shader.SetInt("colorOverride", 1);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
GL.Enable(EnableCap.LineSmooth);
GL.LineWidth(1.5f);
GL.DrawElements(PrimitiveType.Triangles, p.lodMeshes[p.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
shader.SetInt("colorOverride", 0);
}
private static void DrawModelSelection(STGenericObject p, Shader shader)
{
//This part needs to be reworked for proper outline. Currently would make model disappear
/* GL.Enable(EnableCap.DepthTest);
GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
GL.StencilMask(0x00);
GL.StencilFunc(StencilFunction.Always, 1, 0xFF); // all fragments should update the stencil buffer
GL.StencilMask(0xFF); // enable writing to the stencil buffer
GL.DrawElements(PrimitiveType.Triangles, p.lodMeshes[p.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
GL.StencilFunc(StencilFunction.Notequal, 1, 0xFF);
GL.StencilMask(0x00); // enable writing to the stencil buffer
GL.Disable(EnableCap.DepthTest);
shader.SetInt("colorOverride", 1);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
GL.LineWidth(2.0f);
GL.DrawElements(PrimitiveType.Triangles, p.lodMeshes[p.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
shader.SetInt("colorOverride", 0);
GL.StencilMask(0xFF);
GL.Enable(EnableCap.DepthTest);*/
// Override the model color with white in the shader.
shader.SetInt("colorOverride", 1);
GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
GL.Enable(EnableCap.LineSmooth);
GL.LineWidth(1.3f);
GL.DrawElements(PrimitiveType.Triangles, p.lodMeshes[p.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
shader.SetInt("colorOverride", 0);
GL.DrawElements(PrimitiveType.Triangles, p.lodMeshes[p.DisplayLODIndex].displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
}
#endregion
}
}

View File

@ -1,64 +0,0 @@
namespace FirstPlugin
{
partial class PreviewEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dockPanel1 = new Switch_Toolbox.Library.Forms.DockPanelCustom();
this.SuspendLayout();
//
// dockPanel1
//
this.dockPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dockPanel1.DockBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
this.dockPanel1.Location = new System.Drawing.Point(0, 0);
this.dockPanel1.Name = "dockPanel1";
this.dockPanel1.Padding = new System.Windows.Forms.Padding(6);
this.dockPanel1.ShowAutoHideContentOnHover = false;
this.dockPanel1.Size = new System.Drawing.Size(800, 450);
this.dockPanel1.TabIndex = 0;
//
// PreviewEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.dockPanel1);
this.IsMdiContainer = true;
this.Name = "PreviewEditor";
this.Text = "PreviewEditor";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.PreviewEditor_FormClosed);
this.ResumeLayout(false);
}
#endregion
private Switch_Toolbox.Library.Forms.DockPanelCustom dockPanel1;
}
}

View File

@ -1,74 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Switch_Toolbox.Library;
using GL_Core.Public_Interfaces;
using GL_Core;
namespace FirstPlugin
{
public partial class PreviewEditor : Form
{
GL_ControlModern gL_ControlModern;
GL_ControlLegacy GL_ControlLegacy;
TextureViewer textureViewer;
public PreviewEditor()
{
InitializeComponent();
textureViewer = new TextureViewer();
textureViewer.LoadTextures();
textureViewer.Show(dockPanel1, DockState.DockLeft);
DockContent dockedViewport = new DockContent();
SetupViewport(dockedViewport);
dockedViewport.Show(dockPanel1, DockState.Document);
}
private void SetupViewport(DockContent dockContent)
{
if (!Runtime.UseLegacyGL)
{
gL_ControlModern = new GL_Core.GL_ControlModern();
gL_ControlModern.Dock = DockStyle.Fill;
gL_ControlModern.Visible = true;
dockContent.Controls.Add(gL_ControlModern);
}
else
{
GL_ControlLegacy = new GL_Core.GL_ControlLegacy();
GL_ControlLegacy.Dock = DockStyle.Fill;
GL_ControlLegacy.Visible = true;
dockContent.Controls.Add(GL_ControlLegacy);
}
}
private void PreviewEditor_FormClosed(object sender, FormClosedEventArgs e)
{
PluginRuntime.bntxContainers.Clear();
Runtime.abstractGlDrawables.Clear();
if (gL_ControlModern != null)
gL_ControlModern.Dispose();
if (GL_ControlLegacy != null)
GL_ControlLegacy.Dispose();
if (textureViewer != null)
{
textureViewer.Close();
}
textureViewer = null;
gL_ControlModern = null;
GL_ControlLegacy = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,58 +0,0 @@
namespace FirstPlugin
{
partial class TextureOpenEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.bntxEditor1 = new BNTXEditor();
this.SuspendLayout();
//
// bntxEditor1
//
this.bntxEditor1.Dock = System.Windows.Forms.DockStyle.Fill;
this.bntxEditor1.Location = new System.Drawing.Point(0, 0);
this.bntxEditor1.Name = "bntxEditor1";
this.bntxEditor1.Size = new System.Drawing.Size(522, 567);
this.bntxEditor1.TabIndex = 0;
//
// TextureOpenEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(522, 567);
this.Controls.Add(this.bntxEditor1);
this.Name = "TextureOpenEditor";
this.Text = "TextureOpenEditor";
this.ResumeLayout(false);
}
#endregion
private BNTXEditor bntxEditor1;
}
}

View File

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
namespace FirstPlugin
{
public partial class TextureOpenEditor : Form
{
public TextureOpenEditor()
{
InitializeComponent();
}
public void LoadTexture(STGenericTexture tex)
{
RenderableTex renderedTex = tex.RenderableTex;
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,95 +0,0 @@
namespace FirstPlugin
{
partial class TextureViewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.textureListView = new System.Windows.Forms.ListView();
this.textureContextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textureContextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// textureListView
//
this.textureListView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.textureListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.textureListView.ForeColor = System.Drawing.Color.White;
this.textureListView.Location = new System.Drawing.Point(0, 0);
this.textureListView.Name = "textureListView";
this.textureListView.Size = new System.Drawing.Size(432, 450);
this.textureListView.TabIndex = 0;
this.textureListView.UseCompatibleStateImageBehavior = false;
this.textureListView.SelectedIndexChanged += new System.EventHandler(this.textureListView_SelectedIndexChanged);
this.textureListView.DoubleClick += new System.EventHandler(this.textureListView_DoubleClick);
this.textureListView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.textureListView_MouseClick);
//
// textureContextMenuStrip1
//
this.textureContextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportToolStripMenuItem,
this.replaceToolStripMenuItem});
this.textureContextMenuStrip1.Name = "textureContextMenuStrip1";
this.textureContextMenuStrip1.Size = new System.Drawing.Size(116, 48);
//
// exportToolStripMenuItem
//
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.exportToolStripMenuItem.Text = "Export";
this.exportToolStripMenuItem.Click += new System.EventHandler(this.exportToolStripMenuItem_Click);
//
// replaceToolStripMenuItem
//
this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem";
this.replaceToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.replaceToolStripMenuItem.Text = "Replace";
this.replaceToolStripMenuItem.Click += new System.EventHandler(this.replaceToolStripMenuItem_Click);
//
// TextureViewer
//
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.ClientSize = new System.Drawing.Size(432, 450);
this.Controls.Add(this.textureListView);
this.Name = "TextureViewer";
this.Text = "TextureViewer";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.TextureViewer_FormClosed);
this.textureContextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListView textureListView;
private System.Windows.Forms.ContextMenuStrip textureContextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem exportToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem;
}
}

View File

@ -1,168 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
namespace FirstPlugin
{
public partial class TextureViewer : DockContentST
{
public ImageList textureImageList;
public TextureData SelectedTex;
public TextureViewer()
{
InitializeComponent();
textureImageList = new ImageList()
{
ColorDepth = ColorDepth.Depth32Bit,
ImageSize = new Size(70, 70),
};
}
public void ClearForm()
{
textureImageList.Images.Clear();
textureListView.Items.Clear();
textureImageList = null;
}
public void LoadTextures()
{
textureImageList.Images.Clear();
textureListView.Items.Clear();
textureListView.LargeImageList = textureImageList;
textureListView.FullRowSelect = true;
int CurTex = 0;
foreach (BNTX bntx in PluginRuntime.bntxContainers)
{
foreach (TextureData item in bntx.Textures.Values)
{
ListViewItem it = new ListViewItem();
it.Text = item.Text;
it.ImageIndex = CurTex++;
textureListView.Items.Add(it);
TextureData tex = bntx.Textures[item.Text];
tex.LoadOpenGLTexture();
RenderableTex renderedTex = tex.RenderableTex;
Bitmap temp = RenderableTex.GLTextureToBitmap(renderedTex, renderedTex.display);
textureImageList.Images.Add(tex.Text, temp);
var dummy = textureImageList.Handle;
temp.Dispose();
}
}
}
private void textureListView_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void textureListView_DoubleClick(object sender, EventArgs e)
{
foreach (BNTX bntx in PluginRuntime.bntxContainers)
{
if (bntx.Textures.ContainsKey(textureListView.SelectedItems[0].Text))
{
TextureData tex = bntx.Textures[textureListView.SelectedItems[0].Text];
TextureOpenEditor editor = OpenTextureEditor();
editor.Show();
editor.LoadTexture(tex);
}
}
}
private TextureOpenEditor OpenTextureEditor()
{
FormCollection fc = Application.OpenForms;
foreach (Form frm in fc)
{
if (frm is TextureOpenEditor)
{
return (TextureOpenEditor)frm;
}
}
return new TextureOpenEditor();
}
private void TextureViewer_FormClosed(object sender, FormClosedEventArgs e)
{
MessageBox.Show("Closing textue viewer");
ClearForm();
}
private void textureListView_MouseClick(object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Right:
{
foreach (BNTX bntx in PluginRuntime.bntxContainers)
{
if (bntx.Textures.ContainsKey(textureListView.SelectedItems[0].Text))
{
SelectedTex = bntx.Textures[textureListView.SelectedItems[0].Text];
Point p = new Point(e.X, e.Y);
textureContextMenuStrip1.Show(textureListView, p);
}
}
}
break;
}
}
private void exportToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = SelectedTex.Text;
sfd.DefaultExt = "bftex";
sfd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Binary Texture |*.bftex|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
if (sfd.ShowDialog() == DialogResult.OK)
{
SelectedTex.Export(sfd.FileName);
}
}
private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bftex;*.dds; *.png;*.tga;*.jpg;*.tiff|" +
"Binary Texture |*.bftex|" +
"Microsoft DDS |*.dds|" +
"Portable Network Graphics |*.png|" +
"Joint Photographic Experts Group |*.jpg|" +
"Bitmap Image |*.bmp|" +
"Tagged Image File Format |*.tiff|" +
"All files(*.*)|*.*";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
SelectedTex.Replace(ofd.FileName);
}
}
}
}

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="textureContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Bfres.Structs;
namespace FirstPlugin
{
public partial class BfresBoneEditor : UserControl
{
public BfresBoneEditor()
{
InitializeComponent();
foreach (var type in Enum.GetValues(typeof(STBone.BoneRotationType)).Cast<STBone.BoneRotationType>())
rotModeCB.Items.Add(type);
rotMeasureCB.SelectedIndex = 1;
}
BfresBone activeBone;
public void LoadBone(BfresBone bone)
{
activeBone = bone;
if (bone.Parent == null)
parentUD.Value = bone.parentIndex;
else
parentUD.Value = -1;
billboardIDUD.Value = bone.BillboardIndex;
rotModeCB.SelectedIndex = (int)bone.boneRotationType;
chkboxVisible.Checked = bone.IsVisible;
textBoxName.Text = bone.Text;
transXUD.Value = (decimal)bone.position[0];
transYUD.Value = (decimal)bone.position[1];
transZUD.Value = (decimal)bone.position[2];
rotUDX.Value = (decimal)bone.rotation[0];
rotUDY.Value = (decimal)bone.rotation[1];
rotUDZ.Value = (decimal)bone.rotation[2];
scaleUDX.Value = (decimal)bone.scale[0];
scaleUDY.Value = (decimal)bone.scale[1];
scaleUDZ.Value = (decimal)bone.scale[2];
}
private void rotMeasureCB_SelectedIndexChanged(object sender, EventArgs e)
{
if (activeBone == null)
return;
if (rotMeasureCB.SelectedIndex == 0)
{
rotUDX.Value = (decimal)OpenTK.MathHelper.RadiansToDegrees(activeBone.rotation[0]);
rotUDY.Value = (decimal)OpenTK.MathHelper.RadiansToDegrees(activeBone.rotation[1]);
rotUDZ.Value = (decimal)OpenTK.MathHelper.RadiansToDegrees(activeBone.rotation[2]);
}
else if (rotMeasureCB.SelectedIndex == 1)
{
rotUDX.Value = (decimal)activeBone.rotation[0];
rotUDY.Value = (decimal)activeBone.rotation[1];
rotUDZ.Value = (decimal)activeBone.rotation[2];
}
}
private void valueUD_ValueChanged(object sender, EventArgs e)
{
Viewport.Instance.UpdateViewport();
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,653 +0,0 @@
namespace FirstPlugin
{
partial class BfresLODMeshEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.meshListView = new System.Windows.Forms.ListView();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.button3 = new System.Windows.Forms.Button();
this.label15 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.centXUD = new Switch_Toolbox.Library.Forms.NumericUpDownFloat();
this.label3 = new System.Windows.Forms.Label();
this.centYUD = new Switch_Toolbox.Library.Forms.NumericUpDownFloat();
this.label4 = new System.Windows.Forms.Label();
this.centZUD = new Switch_Toolbox.Library.Forms.NumericUpDownFloat();
this.label5 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.extXUD = new Switch_Toolbox.Library.Forms.NumericUpDownFloat();
this.label8 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.extYUD = new Switch_Toolbox.Library.Forms.NumericUpDownFloat();
this.extZUD = new Switch_Toolbox.Library.Forms.NumericUpDownFloat();
this.label7 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.label14 = new System.Windows.Forms.Label();
this.subMeshListView = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.formatCB = new System.Windows.Forms.ComboBox();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.faceTypeCB = new System.Windows.Forms.ComboBox();
this.panel4 = new System.Windows.Forms.Panel();
this.button4 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.radiusUD = new Switch_Toolbox.Library.Forms.NumericUpDownFloat();
this.button5 = new System.Windows.Forms.Button();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.centXUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.centYUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.centZUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.extXUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.extYUD)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.extZUD)).BeginInit();
this.panel1.SuspendLayout();
this.panel4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.radiusUD)).BeginInit();
this.SuspendLayout();
//
// meshListView
//
this.meshListView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(42)))), ((int)(((byte)(42)))), ((int)(((byte)(42)))));
this.meshListView.ForeColor = System.Drawing.Color.White;
this.meshListView.Location = new System.Drawing.Point(2, 2);
this.meshListView.Name = "meshListView";
this.meshListView.Size = new System.Drawing.Size(207, 305);
this.meshListView.TabIndex = 0;
this.meshListView.UseCompatibleStateImageBehavior = false;
this.meshListView.View = System.Windows.Forms.View.List;
this.meshListView.SelectedIndexChanged += new System.EventHandler(this.meshListView_SelectedIndexChanged);
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.ForeColor = System.Drawing.Color.White;
this.button1.Location = new System.Drawing.Point(2, 313);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Remove";
this.button1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.ForeColor = System.Drawing.Color.White;
this.button2.Location = new System.Drawing.Point(134, 313);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "Add";
this.button2.UseVisualStyleBackColor = true;
//
// panel2
//
this.panel2.Controls.Add(this.panel3);
this.panel2.Controls.Add(this.label2);
this.panel2.Controls.Add(this.centXUD);
this.panel2.Controls.Add(this.label3);
this.panel2.Controls.Add(this.centYUD);
this.panel2.Controls.Add(this.label4);
this.panel2.Controls.Add(this.centZUD);
this.panel2.Controls.Add(this.label5);
this.panel2.Controls.Add(this.label9);
this.panel2.Controls.Add(this.extXUD);
this.panel2.Controls.Add(this.label8);
this.panel2.Controls.Add(this.label6);
this.panel2.Controls.Add(this.extYUD);
this.panel2.Controls.Add(this.extZUD);
this.panel2.Controls.Add(this.label7);
this.panel2.ForeColor = System.Drawing.Color.White;
this.panel2.Location = new System.Drawing.Point(215, 212);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(515, 95);
this.panel2.TabIndex = 26;
//
// panel3
//
this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.panel3.Controls.Add(this.button3);
this.panel3.Controls.Add(this.label15);
this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
this.panel3.Location = new System.Drawing.Point(0, 0);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(515, 22);
this.panel3.TabIndex = 23;
//
// button3
//
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.button3.Image = global::FirstPlugin.Properties.Resources.arrowMinimize_;
this.button3.Location = new System.Drawing.Point(0, 0);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(28, 22);
this.button3.TabIndex = 1;
this.button3.TextAlign = System.Drawing.ContentAlignment.BottomRight;
this.button3.UseVisualStyleBackColor = true;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(56, 6);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(57, 13);
this.label15.TabIndex = 0;
this.label15.Text = "Boundings";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Center:";
//
// centXUD
//
this.centXUD.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.centXUD.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.centXUD.DecimalPlaces = 5;
this.centXUD.ForeColor = System.Drawing.Color.White;
this.centXUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.centXUD.Location = new System.Drawing.Point(88, 41);
this.centXUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.centXUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.centXUD.Name = "centXUD";
this.centXUD.Size = new System.Drawing.Size(120, 16);
this.centXUD.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Red;
this.label3.Location = new System.Drawing.Point(69, 43);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(14, 13);
this.label3.TabIndex = 4;
this.label3.Text = "X";
//
// centYUD
//
this.centYUD.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.centYUD.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.centYUD.DecimalPlaces = 5;
this.centYUD.ForeColor = System.Drawing.Color.White;
this.centYUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.centYUD.Location = new System.Drawing.Point(234, 41);
this.centYUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.centYUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.centYUD.Name = "centYUD";
this.centYUD.Size = new System.Drawing.Size(120, 16);
this.centYUD.TabIndex = 5;
//
// label4
//
this.label4.AutoSize = true;
this.label4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.label4.Location = new System.Drawing.Point(214, 43);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(14, 13);
this.label4.TabIndex = 6;
this.label4.Text = "Y";
//
// centZUD
//
this.centZUD.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.centZUD.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.centZUD.DecimalPlaces = 5;
this.centZUD.ForeColor = System.Drawing.Color.White;
this.centZUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.centZUD.Location = new System.Drawing.Point(385, 41);
this.centZUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.centZUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.centZUD.Name = "centZUD";
this.centZUD.Size = new System.Drawing.Size(120, 16);
this.centZUD.TabIndex = 7;
//
// label5
//
this.label5.AutoSize = true;
this.label5.BackColor = System.Drawing.Color.Blue;
this.label5.Location = new System.Drawing.Point(365, 43);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(14, 13);
this.label5.TabIndex = 8;
this.label5.Text = "Z";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(11, 64);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(40, 13);
this.label9.TabIndex = 9;
this.label9.Text = "Extent:";
//
// extXUD
//
this.extXUD.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.extXUD.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.extXUD.DecimalPlaces = 5;
this.extXUD.ForeColor = System.Drawing.Color.White;
this.extXUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.extXUD.Location = new System.Drawing.Point(89, 65);
this.extXUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.extXUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.extXUD.Name = "extXUD";
this.extXUD.Size = new System.Drawing.Size(120, 16);
this.extXUD.TabIndex = 10;
//
// label8
//
this.label8.AutoSize = true;
this.label8.BackColor = System.Drawing.Color.Red;
this.label8.Location = new System.Drawing.Point(69, 67);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(14, 13);
this.label8.TabIndex = 11;
this.label8.Text = "X";
//
// label6
//
this.label6.AutoSize = true;
this.label6.BackColor = System.Drawing.Color.Blue;
this.label6.Location = new System.Drawing.Point(366, 67);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(14, 13);
this.label6.TabIndex = 15;
this.label6.Text = "Z";
//
// extYUD
//
this.extYUD.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.extYUD.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.extYUD.DecimalPlaces = 5;
this.extYUD.ForeColor = System.Drawing.Color.White;
this.extYUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.extYUD.Location = new System.Drawing.Point(235, 65);
this.extYUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.extYUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.extYUD.Name = "extYUD";
this.extYUD.Size = new System.Drawing.Size(120, 16);
this.extYUD.TabIndex = 12;
//
// extZUD
//
this.extZUD.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.extZUD.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.extZUD.DecimalPlaces = 5;
this.extZUD.ForeColor = System.Drawing.Color.White;
this.extZUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.extZUD.Location = new System.Drawing.Point(386, 65);
this.extZUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.extZUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.extZUD.Name = "extZUD";
this.extZUD.Size = new System.Drawing.Size(120, 16);
this.extZUD.TabIndex = 14;
//
// label7
//
this.label7.AutoSize = true;
this.label7.BackColor = System.Drawing.Color.Lime;
this.label7.Location = new System.Drawing.Point(215, 67);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(14, 13);
this.label7.TabIndex = 13;
this.label7.Text = "Y";
//
// panel1
//
this.panel1.Controls.Add(this.label14);
this.panel1.Controls.Add(this.subMeshListView);
this.panel1.Controls.Add(this.formatCB);
this.panel1.Controls.Add(this.label13);
this.panel1.Controls.Add(this.label12);
this.panel1.Controls.Add(this.label11);
this.panel1.Controls.Add(this.faceTypeCB);
this.panel1.Controls.Add(this.panel4);
this.panel1.Controls.Add(this.label10);
this.panel1.Controls.Add(this.radiusUD);
this.panel1.ForeColor = System.Drawing.Color.White;
this.panel1.Location = new System.Drawing.Point(215, 2);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(515, 204);
this.panel1.TabIndex = 27;
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(238, 40);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(69, 13);
this.label14.TabIndex = 30;
this.label14.Text = "Sub Meshes:";
//
// subMeshListView
//
this.subMeshListView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(42)))), ((int)(((byte)(42)))), ((int)(((byte)(42)))));
this.subMeshListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.subMeshListView.ForeColor = System.Drawing.Color.White;
this.subMeshListView.Location = new System.Drawing.Point(332, 28);
this.subMeshListView.Name = "subMeshListView";
this.subMeshListView.Size = new System.Drawing.Size(180, 194);
this.subMeshListView.TabIndex = 29;
this.subMeshListView.UseCompatibleStateImageBehavior = false;
this.subMeshListView.View = System.Windows.Forms.View.Details;
this.subMeshListView.SelectedIndexChanged += new System.EventHandler(this.subMeshListView_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "Offset";
this.columnHeader1.Width = 93;
//
// columnHeader2
//
this.columnHeader2.Text = "Count";
this.columnHeader2.Width = 81;
//
// formatCB
//
this.formatCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.formatCB.FormattingEnabled = true;
this.formatCB.Location = new System.Drawing.Point(74, 63);
this.formatCB.Name = "formatCB";
this.formatCB.Size = new System.Drawing.Size(121, 21);
this.formatCB.TabIndex = 28;
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(11, 66);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(42, 13);
this.label13.TabIndex = 27;
this.label13.Text = "Format:";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(11, 40);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(65, 13);
this.label12.TabIndex = 26;
this.label12.Text = "Face Count:";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(11, 95);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(61, 13);
this.label11.TabIndex = 25;
this.label11.Text = "Face Type:";
//
// faceTypeCB
//
this.faceTypeCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.faceTypeCB.FormattingEnabled = true;
this.faceTypeCB.Location = new System.Drawing.Point(75, 92);
this.faceTypeCB.Name = "faceTypeCB";
this.faceTypeCB.Size = new System.Drawing.Size(121, 21);
this.faceTypeCB.TabIndex = 24;
//
// panel4
//
this.panel4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.panel4.Controls.Add(this.button4);
this.panel4.Controls.Add(this.label1);
this.panel4.Dock = System.Windows.Forms.DockStyle.Top;
this.panel4.Location = new System.Drawing.Point(0, 0);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(515, 22);
this.panel4.TabIndex = 23;
//
// button4
//
this.button4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.button4.Image = global::FirstPlugin.Properties.Resources.arrowMinimize_;
this.button4.Location = new System.Drawing.Point(0, 0);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(28, 22);
this.button4.TabIndex = 1;
this.button4.TextAlign = System.Drawing.ContentAlignment.BottomRight;
this.button4.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(56, 6);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(58, 13);
this.label1.TabIndex = 0;
this.label1.Text = "LOD Mesh";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(11, 132);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(88, 13);
this.label10.TabIndex = 2;
this.label10.Text = "Bounding Radius";
//
// radiusUD
//
this.radiusUD.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.radiusUD.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.radiusUD.DecimalPlaces = 5;
this.radiusUD.ForeColor = System.Drawing.Color.White;
this.radiusUD.Increment = new decimal(new int[] {
5,
0,
0,
196608});
this.radiusUD.Location = new System.Drawing.Point(105, 133);
this.radiusUD.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.radiusUD.Minimum = new decimal(new int[] {
100000000,
0,
0,
-2147483648});
this.radiusUD.Name = "radiusUD";
this.radiusUD.Size = new System.Drawing.Size(120, 16);
this.radiusUD.TabIndex = 3;
//
// button5
//
this.button5.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button5.ForeColor = System.Drawing.Color.White;
this.button5.Location = new System.Drawing.Point(644, 313);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 28;
this.button5.Text = "Ok";
this.button5.UseVisualStyleBackColor = true;
//
// BfresLODMeshEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.ClientSize = new System.Drawing.Size(731, 341);
this.Controls.Add(this.button5);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.meshListView);
this.Name = "BfresLODMeshEditor";
this.Text = "LOD Meshes";
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.centXUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.centYUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.centZUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.extXUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.extYUD)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.extZUD)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel4.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.radiusUD)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListView meshListView;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label2;
private Switch_Toolbox.Library.Forms.NumericUpDownFloat centXUD;
private System.Windows.Forms.Label label3;
private Switch_Toolbox.Library.Forms.NumericUpDownFloat centYUD;
private System.Windows.Forms.Label label4;
private Switch_Toolbox.Library.Forms.NumericUpDownFloat centZUD;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label9;
private Switch_Toolbox.Library.Forms.NumericUpDownFloat extXUD;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label6;
private Switch_Toolbox.Library.Forms.NumericUpDownFloat extYUD;
private Switch_Toolbox.Library.Forms.NumericUpDownFloat extZUD;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.ListView subMeshListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ComboBox formatCB;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.ComboBox faceTypeCB;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label10;
private Switch_Toolbox.Library.Forms.NumericUpDownFloat radiusUD;
private System.Windows.Forms.Button button5;
}
}

View File

@ -1,79 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Bfres.Structs;
namespace FirstPlugin
{
public partial class BfresLODMeshEditor : Form
{
public BfresLODMeshEditor()
{
InitializeComponent();
}
FSHP ActiveShape;
public void LoadLODS(FSHP fshp)
{
meshListView.Items.Clear();
subMeshListView.Items.Clear();
subMeshListView.FullRowSelect = true;
meshListView.FullRowSelect = true;
ActiveShape = fshp;
for (int i = 0; i < fshp.lodMeshes.Count; i++)
{
meshListView.Items.Add($"mesh {i}");
}
}
private void meshListView_SelectedIndexChanged(object sender, EventArgs e)
{
if (meshListView.SelectedItems.Count > 0)
{
var lod = ActiveShape.lodMeshes[meshListView.SelectedIndices[0]];
radiusUD.Value = (decimal)ActiveShape.boundingRadius[meshListView.SelectedIndices[0]];
subMeshListView.Items.Clear();
for (int i = 0; i < lod.subMeshes.Count; i++)
{
ListViewItem item = new ListViewItem();
item.Text = lod.subMeshes[i].offset.ToString();
item.SubItems.Add(lod.subMeshes[i].size.ToString());
subMeshListView.Items.Add(item);
}
if (subMeshListView.Items.Count > 0)
{
subMeshListView.Items[0].Selected = true;
subMeshListView.Select();
}
}
}
private void subMeshListView_SelectedIndexChanged(object sender, EventArgs e)
{
if (subMeshListView.SelectedItems.Count > 0)
{
int MshIndx = meshListView.SelectedIndices[0];
int SubIndx = subMeshListView.SelectedIndices[0];
var center = ActiveShape.boundingBoxes[MshIndx + SubIndx].Center;
var extend = ActiveShape.boundingBoxes[MshIndx + SubIndx].Extend;
centXUD.Value = (decimal)center.X;
centYUD.Value = (decimal)center.Y;
centZUD.Value = (decimal)center.Z;
extXUD.Value = (decimal)extend.X;
extYUD.Value = (decimal)extend.Y;
extZUD.Value = (decimal)extend.Z;
}
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,461 +0,0 @@
namespace FirstPlugin
{
partial class FMATEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.visualStudioTabControl1 = new VisualStudioTabControl.VisualStudioTabControl();
this.generalTab = new System.Windows.Forms.TabPage();
this.chkboxVisible = new System.Windows.Forms.CheckBox();
this.label3 = new System.Windows.Forms.Label();
this.textBoxShaderModel = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.textBoxShaderArchive = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.textBoxMaterialName = new System.Windows.Forms.TextBox();
this.textureMapTab = new System.Windows.Forms.TabPage();
this.btnSamplerEditor = new System.Windows.Forms.Button();
this.textureRefListView = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.materialParamTab = new System.Windows.Forms.TabPage();
this.btnReplaceParams = new System.Windows.Forms.Button();
this.btnExportParams = new System.Windows.Forms.Button();
this.listView1 = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.renderInfoTab = new System.Windows.Forms.TabPage();
this.renderInfoListView = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.shaderAssignTab = new System.Windows.Forms.TabPage();
this.shaderOptionsListView = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.visualStudioTabControl1.SuspendLayout();
this.generalTab.SuspendLayout();
this.textureMapTab.SuspendLayout();
this.materialParamTab.SuspendLayout();
this.renderInfoTab.SuspendLayout();
this.shaderAssignTab.SuspendLayout();
this.SuspendLayout();
//
// visualStudioTabControl1
//
this.visualStudioTabControl1.ActiveColor = System.Drawing.Color.Gray;
this.visualStudioTabControl1.AllowDrop = true;
this.visualStudioTabControl1.BackTabColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.visualStudioTabControl1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.visualStudioTabControl1.ClosingButtonColor = System.Drawing.Color.WhiteSmoke;
this.visualStudioTabControl1.ClosingMessage = null;
this.visualStudioTabControl1.Controls.Add(this.generalTab);
this.visualStudioTabControl1.Controls.Add(this.textureMapTab);
this.visualStudioTabControl1.Controls.Add(this.materialParamTab);
this.visualStudioTabControl1.Controls.Add(this.renderInfoTab);
this.visualStudioTabControl1.Controls.Add(this.shaderAssignTab);
this.visualStudioTabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.visualStudioTabControl1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.visualStudioTabControl1.HeaderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48)))));
this.visualStudioTabControl1.HorizontalLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.visualStudioTabControl1.ItemSize = new System.Drawing.Size(240, 14);
this.visualStudioTabControl1.Location = new System.Drawing.Point(0, 0);
this.visualStudioTabControl1.Name = "visualStudioTabControl1";
this.visualStudioTabControl1.Padding = new System.Drawing.Point(2, 20);
this.visualStudioTabControl1.SelectedIndex = 0;
this.visualStudioTabControl1.SelectedTextColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.visualStudioTabControl1.ShowClosingButton = false;
this.visualStudioTabControl1.ShowClosingMessage = false;
this.visualStudioTabControl1.Size = new System.Drawing.Size(610, 548);
this.visualStudioTabControl1.SizeMode = System.Windows.Forms.TabSizeMode.FillToRight;
this.visualStudioTabControl1.TabIndex = 1;
this.visualStudioTabControl1.TextColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
//
// generalTab
//
this.generalTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.generalTab.Controls.Add(this.chkboxVisible);
this.generalTab.Controls.Add(this.label3);
this.generalTab.Controls.Add(this.textBoxShaderModel);
this.generalTab.Controls.Add(this.label2);
this.generalTab.Controls.Add(this.textBoxShaderArchive);
this.generalTab.Controls.Add(this.label1);
this.generalTab.Controls.Add(this.textBoxMaterialName);
this.generalTab.Location = new System.Drawing.Point(4, 18);
this.generalTab.Name = "generalTab";
this.generalTab.Padding = new System.Windows.Forms.Padding(3);
this.generalTab.Size = new System.Drawing.Size(602, 526);
this.generalTab.TabIndex = 0;
this.generalTab.Text = "General";
//
// chkboxVisible
//
this.chkboxVisible.AutoSize = true;
this.chkboxVisible.Checked = true;
this.chkboxVisible.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkboxVisible.Location = new System.Drawing.Point(19, 19);
this.chkboxVisible.Name = "chkboxVisible";
this.chkboxVisible.Size = new System.Drawing.Size(65, 19);
this.chkboxVisible.TabIndex = 36;
this.chkboxVisible.Text = "Enable";
this.chkboxVisible.UseVisualStyleBackColor = true;
this.chkboxVisible.CheckedChanged += new System.EventHandler(this.chkboxVisible_CheckedChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(16, 123);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(85, 15);
this.label3.TabIndex = 5;
this.label3.Text = "Shader Model";
//
// textBoxShaderModel
//
this.textBoxShaderModel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.textBoxShaderModel.ForeColor = System.Drawing.Color.White;
this.textBoxShaderModel.Location = new System.Drawing.Point(107, 120);
this.textBoxShaderModel.Name = "textBoxShaderModel";
this.textBoxShaderModel.Size = new System.Drawing.Size(257, 21);
this.textBoxShaderModel.TabIndex = 4;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(16, 89);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(89, 15);
this.label2.TabIndex = 3;
this.label2.Text = "Shader Archive";
//
// textBoxShaderArchive
//
this.textBoxShaderArchive.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.textBoxShaderArchive.ForeColor = System.Drawing.Color.White;
this.textBoxShaderArchive.Location = new System.Drawing.Point(107, 86);
this.textBoxShaderArchive.Name = "textBoxShaderArchive";
this.textBoxShaderArchive.Size = new System.Drawing.Size(257, 21);
this.textBoxShaderArchive.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 55);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Name";
//
// textBoxMaterialName
//
this.textBoxMaterialName.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.textBoxMaterialName.ForeColor = System.Drawing.Color.White;
this.textBoxMaterialName.Location = new System.Drawing.Point(107, 52);
this.textBoxMaterialName.Name = "textBoxMaterialName";
this.textBoxMaterialName.Size = new System.Drawing.Size(257, 21);
this.textBoxMaterialName.TabIndex = 0;
//
// textureMapTab
//
this.textureMapTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.textureMapTab.Controls.Add(this.btnSamplerEditor);
this.textureMapTab.Controls.Add(this.textureRefListView);
this.textureMapTab.Location = new System.Drawing.Point(4, 18);
this.textureMapTab.Name = "textureMapTab";
this.textureMapTab.Padding = new System.Windows.Forms.Padding(3);
this.textureMapTab.Size = new System.Drawing.Size(602, 526);
this.textureMapTab.TabIndex = 1;
this.textureMapTab.Text = "Texture Mapping";
this.textureMapTab.DoubleClick += new System.EventHandler(this.textureMapTab_DoubleClick);
//
// btnSamplerEditor
//
this.btnSamplerEditor.Enabled = false;
this.btnSamplerEditor.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSamplerEditor.Location = new System.Drawing.Point(6, 7);
this.btnSamplerEditor.Name = "btnSamplerEditor";
this.btnSamplerEditor.Size = new System.Drawing.Size(157, 23);
this.btnSamplerEditor.TabIndex = 2;
this.btnSamplerEditor.Text = "Sampler Editor";
this.btnSamplerEditor.UseVisualStyleBackColor = true;
this.btnSamplerEditor.Click += new System.EventHandler(this.btnSamplerEditor_Click);
//
// textureRefListView
//
this.textureRefListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textureRefListView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.textureRefListView.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textureRefListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3});
this.textureRefListView.ForeColor = System.Drawing.Color.White;
this.textureRefListView.Location = new System.Drawing.Point(3, 36);
this.textureRefListView.Name = "textureRefListView";
this.textureRefListView.OwnerDraw = true;
this.textureRefListView.Size = new System.Drawing.Size(596, 487);
this.textureRefListView.TabIndex = 1;
this.textureRefListView.UseCompatibleStateImageBehavior = false;
this.textureRefListView.View = System.Windows.Forms.View.Details;
this.textureRefListView.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.textureRefListView_DrawColumnHeader);
this.textureRefListView.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this.textureRefListView_DrawItem);
this.textureRefListView.SelectedIndexChanged += new System.EventHandler(this.textureRefListView_SelectedIndexChanged);
this.textureRefListView.DoubleClick += new System.EventHandler(this.textureRefListView_DoubleClick);
//
// columnHeader1
//
this.columnHeader1.Text = "Texture";
this.columnHeader1.Width = 410;
//
// columnHeader2
//
this.columnHeader2.Text = "Sampler";
this.columnHeader2.Width = 100;
//
// columnHeader3
//
this.columnHeader3.Text = "Frag Sampler";
this.columnHeader3.Width = 155;
//
// materialParamTab
//
this.materialParamTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.materialParamTab.Controls.Add(this.btnReplaceParams);
this.materialParamTab.Controls.Add(this.btnExportParams);
this.materialParamTab.Controls.Add(this.listView1);
this.materialParamTab.Location = new System.Drawing.Point(4, 18);
this.materialParamTab.Name = "materialParamTab";
this.materialParamTab.Padding = new System.Windows.Forms.Padding(3);
this.materialParamTab.Size = new System.Drawing.Size(602, 526);
this.materialParamTab.TabIndex = 2;
this.materialParamTab.Text = "Material Params";
//
// btnReplaceParams
//
this.btnReplaceParams.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnReplaceParams.Location = new System.Drawing.Point(87, 6);
this.btnReplaceParams.Name = "btnReplaceParams";
this.btnReplaceParams.Size = new System.Drawing.Size(75, 23);
this.btnReplaceParams.TabIndex = 7;
this.btnReplaceParams.Text = "Replace";
this.btnReplaceParams.UseVisualStyleBackColor = true;
this.btnReplaceParams.Click += new System.EventHandler(this.btnReplaceParams_Click);
//
// btnExportParams
//
this.btnExportParams.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnExportParams.Location = new System.Drawing.Point(6, 6);
this.btnExportParams.Name = "btnExportParams";
this.btnExportParams.Size = new System.Drawing.Size(75, 23);
this.btnExportParams.TabIndex = 6;
this.btnExportParams.Text = "Export";
this.btnExportParams.UseVisualStyleBackColor = true;
this.btnExportParams.Click += new System.EventHandler(this.btnExportParams_Click);
//
// listView1
//
this.listView1.AllowColumnReorder = true;
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader4,
this.columnHeader6,
this.columnHeader5});
this.listView1.ForeColor = System.Drawing.Color.White;
this.listView1.Location = new System.Drawing.Point(3, 34);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(596, 489);
this.listView1.TabIndex = 4;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
//
// columnHeader4
//
this.columnHeader4.Text = "Name";
this.columnHeader4.Width = 140;
//
// columnHeader6
//
this.columnHeader6.Text = "Value";
this.columnHeader6.Width = 90;
//
// columnHeader5
//
this.columnHeader5.Text = "Color";
this.columnHeader5.Width = 75;
//
// renderInfoTab
//
this.renderInfoTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.renderInfoTab.Controls.Add(this.renderInfoListView);
this.renderInfoTab.Location = new System.Drawing.Point(4, 18);
this.renderInfoTab.Name = "renderInfoTab";
this.renderInfoTab.Padding = new System.Windows.Forms.Padding(3);
this.renderInfoTab.Size = new System.Drawing.Size(602, 526);
this.renderInfoTab.TabIndex = 3;
this.renderInfoTab.Text = "Render Info";
//
// renderInfoListView
//
this.renderInfoListView.AllowColumnReorder = true;
this.renderInfoListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.renderInfoListView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.renderInfoListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader7,
this.columnHeader8,
this.columnHeader9});
this.renderInfoListView.ForeColor = System.Drawing.Color.White;
this.renderInfoListView.Location = new System.Drawing.Point(6, 16);
this.renderInfoListView.MultiSelect = false;
this.renderInfoListView.Name = "renderInfoListView";
this.renderInfoListView.Size = new System.Drawing.Size(596, 486);
this.renderInfoListView.TabIndex = 5;
this.renderInfoListView.UseCompatibleStateImageBehavior = false;
this.renderInfoListView.View = System.Windows.Forms.View.Details;
this.renderInfoListView.DoubleClick += new System.EventHandler(this.renderInfoListView_DoubleClick);
//
// columnHeader7
//
this.columnHeader7.Text = "Name";
this.columnHeader7.Width = 267;
//
// columnHeader8
//
this.columnHeader8.Text = "Value";
this.columnHeader8.Width = 169;
//
// columnHeader9
//
this.columnHeader9.Text = "Format";
this.columnHeader9.Width = 75;
//
// shaderAssignTab
//
this.shaderAssignTab.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(28)))), ((int)(((byte)(28)))));
this.shaderAssignTab.Controls.Add(this.shaderOptionsListView);
this.shaderAssignTab.Location = new System.Drawing.Point(4, 18);
this.shaderAssignTab.Name = "shaderAssignTab";
this.shaderAssignTab.Padding = new System.Windows.Forms.Padding(3);
this.shaderAssignTab.Size = new System.Drawing.Size(602, 526);
this.shaderAssignTab.TabIndex = 4;
this.shaderAssignTab.Text = "Shader Options";
//
// shaderOptionsListView
//
this.shaderOptionsListView.AllowColumnReorder = true;
this.shaderOptionsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.shaderOptionsListView.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.shaderOptionsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader10,
this.columnHeader11});
this.shaderOptionsListView.ForeColor = System.Drawing.Color.White;
this.shaderOptionsListView.Location = new System.Drawing.Point(3, 19);
this.shaderOptionsListView.MultiSelect = false;
this.shaderOptionsListView.Name = "shaderOptionsListView";
this.shaderOptionsListView.Size = new System.Drawing.Size(596, 486);
this.shaderOptionsListView.TabIndex = 6;
this.shaderOptionsListView.UseCompatibleStateImageBehavior = false;
this.shaderOptionsListView.View = System.Windows.Forms.View.Details;
this.shaderOptionsListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.shaderOptionsListView_ColumnClick);
this.shaderOptionsListView.DoubleClick += new System.EventHandler(this.shaderOptionsListView_DoubleClick);
//
// columnHeader10
//
this.columnHeader10.Text = "Name";
this.columnHeader10.Width = 267;
//
// columnHeader11
//
this.columnHeader11.Text = "Value";
this.columnHeader11.Width = 169;
//
// FMATEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.Controls.Add(this.visualStudioTabControl1);
this.ForeColor = System.Drawing.Color.White;
this.Name = "FMATEditor";
this.Size = new System.Drawing.Size(610, 548);
this.visualStudioTabControl1.ResumeLayout(false);
this.generalTab.ResumeLayout(false);
this.generalTab.PerformLayout();
this.textureMapTab.ResumeLayout(false);
this.materialParamTab.ResumeLayout(false);
this.renderInfoTab.ResumeLayout(false);
this.shaderAssignTab.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private VisualStudioTabControl.VisualStudioTabControl visualStudioTabControl1;
private System.Windows.Forms.TabPage generalTab;
private System.Windows.Forms.TabPage textureMapTab;
private Switch_Toolbox.Library.Forms.ListViewCustom textureRefListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader3;
private System.Windows.Forms.TabPage materialParamTab;
private System.Windows.Forms.TabPage renderInfoTab;
private System.Windows.Forms.TabPage shaderAssignTab;
private Switch_Toolbox.Library.Forms.ListViewCustom listView1;
private System.Windows.Forms.ColumnHeader columnHeader4;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.ColumnHeader columnHeader5;
private Switch_Toolbox.Library.Forms.ListViewCustom renderInfoListView;
private System.Windows.Forms.ColumnHeader columnHeader7;
private System.Windows.Forms.ColumnHeader columnHeader8;
private System.Windows.Forms.ColumnHeader columnHeader9;
private System.Windows.Forms.Button btnReplaceParams;
private System.Windows.Forms.Button btnExportParams;
private Switch_Toolbox.Library.Forms.ListViewCustom shaderOptionsListView;
private System.Windows.Forms.ColumnHeader columnHeader10;
private System.Windows.Forms.ColumnHeader columnHeader11;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBoxShaderModel;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBoxShaderArchive;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBoxMaterialName;
private System.Windows.Forms.CheckBox chkboxVisible;
private System.Windows.Forms.Button btnSamplerEditor;
}
}

View File

@ -1,577 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using Syroot.NintenTools.NSW.Bfres;
using OpenTK;
using Switch_Toolbox.Library;
using Bfres.Structs;
namespace FirstPlugin
{
public partial class FMATEditor : UserControl
{
public FMAT material;
public ImageList textureImageList;
public string SelectedMatParam = "";
public ImageList il = new ImageList();
public FMATEditor()
{
InitializeComponent();
textureImageList = new ImageList()
{
ColorDepth = ColorDepth.Depth32Bit,
ImageSize = new Size(70, 70),
};
if (!Runtime.IsDebugMode)
{
textBoxShaderArchive.ReadOnly = true;
textBoxShaderModel.ReadOnly = true;
}
shaderOptionsListView.ListViewItemSorter = new Sorter();
}
private void listView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
}
public void LoadMaterial(FMAT mat)
{
material = mat;
textBoxMaterialName.Text = material.Text;
SetActiveGameByShader(material.shaderassign.ShaderArchive, material.shaderassign.ShaderModel);
chkboxVisible.Checked = mat.Enabled;
FillForm();
}
private void SetActiveGameByShader(string ShaderName, string ShaderMdlName)
{
textBoxShaderArchive.Text = ShaderName;
textBoxShaderModel.Text = ShaderMdlName;
}
public void FillForm()
{
InitializeTextureListView(material);
InitializeRenderInfoList(material);
InitializeShaderParamList(material);
InitializeShaderOptionList(material);
}
private string SetValueToString(object values)
{
if (values is float[])
return string.Join(" , ", values as float[]);
else if (values is bool[])
return string.Join(" , ", values as bool[]);
else if (values is int[])
return string.Join(" , ", values as int[]);
else if (values is uint[])
return string.Join(" , ", values as uint[]);
else
return "";
}
private void InitializeShaderOptionList(FMAT material)
{
shaderOptionsListView.Items.Clear();
foreach (var option in material.shaderassign.options)
{
shaderOptionsListView.Items.Add(option.Key).SubItems.Add(option.Value);
}
}
private void InitializeShaderParamList(FMAT material)
{
listView1.Items.Clear();
int CurParam = 0;
foreach (var prm in material.matparam.Values)
{
string DisplayValue = "";
var item = new ListViewItem(prm.Name);
Color SetColor = Color.FromArgb(40, 40, 40);
Vector4 col = new Vector4();
bool IsColor = prm.Name.Contains("Color") ||
prm.Name.Contains("color") ||
prm.Name.Contains("konst0") ||
prm.Name.Contains("konst1") ||
prm.Name.Contains("konst2") ||
prm.Name.Contains("konst3");
switch (prm.Type)
{
case ShaderParamType.Float:
case ShaderParamType.Float2:
case ShaderParamType.Float2x2:
case ShaderParamType.Float2x3:
case ShaderParamType.Float2x4:
case ShaderParamType.Float3x2:
case ShaderParamType.Float3x3:
case ShaderParamType.Float3x4:
case ShaderParamType.Float4x2:
case ShaderParamType.Float4x3:
case ShaderParamType.Float4x4:
DisplayValue = SetValueToString(prm.ValueFloat);
break;
case ShaderParamType.Float3:
DisplayValue = SetValueToString(prm.ValueFloat);
col = new Vector4(prm.ValueFloat[0], prm.ValueFloat[1], prm.ValueFloat[2], 1);
break;
case ShaderParamType.Float4:
DisplayValue = SetValueToString(prm.ValueFloat);
col = new Vector4(prm.ValueFloat[0], prm.ValueFloat[1], prm.ValueFloat[2], prm.ValueFloat[3]);
break;
}
if (IsColor)
{
int someIntX = (int)Math.Ceiling(col.X * 255);
int someIntY = (int)Math.Ceiling(col.Y * 255);
int someIntZ = (int)Math.Ceiling(col.Z * 255);
int someIntW = (int)Math.Ceiling(col.W * 255);
if (someIntX <= 255 && someIntY <= 255 && someIntZ <= 255 && someIntW <= 255)
{
Console.WriteLine($"{prm.Name} R {someIntX} G {someIntY} B {someIntZ}");
SetColor = Color.FromArgb(
255,
someIntX,
someIntY,
someIntZ
);
}
}
item.UseItemStyleForSubItems = false;
item.SubItems.Add(DisplayValue);
item.SubItems.Add("");
item.SubItems[2].BackColor = SetColor;
listView1.View = View.Details;
listView1.Items.Add(item);
CurParam++;
}
il.ImageSize = new Size(10, 10);
listView1.SmallImageList = il;
listView1.FullRowSelect = true;
}
public void InitializeTextureListView(FMAT material)
{
textureRefListView.Items.Clear();
textureRefListView.SmallImageList = textureImageList;
textureRefListView.FullRowSelect = true;
foreach (MatTexture tex in material.TextureMaps)
{
ListViewItem item = new ListViewItem();
item.Text = tex.Name;
item.SubItems.Add(tex.SamplerName);
if (material.shaderassign.samplers.ContainsValue(tex.SamplerName))
{
var FragSampler = material.shaderassign.samplers.FirstOrDefault(x => x.Value == tex.SamplerName).Key;
item.SubItems.Add(FragSampler.ToString());
}
textureRefListView.Items.Add(item);
}
textureImageList.Images.Clear();
int CurTex = 0;
if (PluginRuntime.bntxContainers.Count == 0 &&
PluginRuntime.ftexContainers.Count == 0)
{
foreach (ListViewItem item in textureRefListView.Items)
{
AddBlankTexture(item, item.Text, CurTex++);
}
}
bool FoundTexture = false;
foreach (ListViewItem item in textureRefListView.Items)
{
foreach (BNTX bntx in PluginRuntime.bntxContainers)
{
if (bntx.Textures.ContainsKey(item.Text))
{
FoundTexture = true;
TextureData tex = bntx.Textures[item.Text];
Bitmap temp = tex.GetBitmap();
textureImageList.Images.Add(tex.Text, temp);
item.ImageIndex = CurTex++;
var dummy = textureImageList.Handle;
temp.Dispose();
}
}
foreach (FTEXContainer ftexCont in PluginRuntime.ftexContainers)
{
if (ftexCont.Textures.ContainsKey(item.Text))
{
FoundTexture = true;
FTEX tex = ftexCont.Textures[item.Text];
Bitmap temp = tex.GetBitmap();
textureImageList.Images.Add(tex.Text, temp);
item.ImageIndex = CurTex++;
var dummy = textureImageList.Handle;
temp.Dispose();
}
}
if (FoundTexture == false)
{
AddBlankTexture(item, item.Text, CurTex++);
}
}
}
private void AddBlankTexture(ListViewItem item, string Name, int ImageIndex)
{
Bitmap temp = new Bitmap(Properties.Resources.TextureError);
textureImageList.Images.Add(Name, temp);
item.ImageIndex = ImageIndex;
var dummy = textureImageList.Handle;
temp.Dispose();
}
private void InitializeRenderInfoList(FMAT material)
{
renderInfoListView.Items.Clear();
foreach (var rnd in material.renderinfo)
{
ListViewItem item = new ListViewItem();
item.Text = rnd.Name;
string Value = "";
switch (rnd.Type)
{
case RenderInfoType.Int32:
Value = string.Join(",", rnd.ValueInt);
break;
case RenderInfoType.Single:
Value = string.Join(",", rnd.ValueFloat);
break;
case RenderInfoType.String:
Value = string.Join(",", rnd.ValueString);
break;
}
item.SubItems.Add(Value);
item.SubItems.Add(rnd.Type.ToString());
renderInfoListView.Items.Add(item);
}
renderInfoListView.FullRowSelect = true;
}
private void textureRefListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawDefault = true;
if ((e.ItemIndex % 2) == 1)
{
e.Item.BackColor = Color.FromArgb(50, 50, 50);
e.Item.UseItemStyleForSubItems = true;
}
}
private void FSHPEditor_DockStateChanged(object sender, EventArgs e)
{
DockContent doc = sender as DockContent;
if (doc != null)
{
PluginRuntime.FSHPDockState = doc.DockState;
Console.WriteLine(doc.DockState);
Console.WriteLine(doc);
if (doc.DockState != DockState.Unknown)
Config.Save();
}
}
private void textureMapTab_DoubleClick(object sender, EventArgs e)
{
}
private void textureRefListView_DoubleClick(object sender, EventArgs e)
{
Console.WriteLine("click");
int index = textureRefListView.SelectedIndices[0];
Texture_Selector tex = new Texture_Selector();
tex.LoadTexture(material.GetResFileU() != null);
if (tex.ShowDialog() == DialogResult.OK)
{
material.TextureMaps[index].Name = tex.GetSelectedTexture();
InitializeTextureListView(material);
material.UpdateTextureMaps();
}
}
private void textureRefListView_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
using (SolidBrush backBrush = new SolidBrush(Color.FromArgb(50, 50, 50)))
{
e.Graphics.FillRectangle(backBrush, e.Bounds);
}
using (SolidBrush foreBrush = new SolidBrush(Color.FromArgb(255, 255, 255)))
{
e.Graphics.DrawString(e.Header.Text, e.Font, foreBrush, e.Bounds);
}
}
private void listView1_DoubleClick(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
{
if (material.matparam.ContainsKey(listView1.SelectedItems[0].Text))
{
int index = listView1.SelectedIndices[0];
SetParamDialog paramDialog = new SetParamDialog();
paramDialog.LoadParam(material.matparam[listView1.SelectedItems[0].Text]);
if (paramDialog.ShowDialog() == DialogResult.OK)
{
paramDialog.SetValues();
InitializeShaderParamList(material);
listView1.Items[index].Selected = true;
}
}
}
}
private void smallToolStripMenuItem_Click(object sender, EventArgs e)
{
/*Font normalfont = new Font("Microsoft Sans Serif", 10f);
foreach (ListViewItem lvi in listView1.Items) lvi.Font = normalfont;
foreach (ListViewItem lvi in listView1.Items) lvi.SubItems[0].Font = normalfont;
SetHeight(listView1, 11);*/
}
private void SetHeight(ListView listView, int height)
{
ImageList imgList = new ImageList();
imgList.ImageSize = new Size(1, height);
listView.SmallImageList = imgList;
}
private void mediumToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void largeToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void renderInfoListView_DoubleClick(object sender, EventArgs e)
{
int ActiveInfoIndex = renderInfoListView.SelectedIndices[0];
if (renderInfoListView.SelectedItems.Count > 0)
{
foreach (var info in material.renderinfo)
{
if (info.Name == renderInfoListView.SelectedItems[0].Text)
{
RenderInfoValueEditor editor = new RenderInfoValueEditor();
editor.LoadValues(info);
if (editor.ShowDialog() == DialogResult.OK)
{
info.ValueFloat = editor.valueFloats.ToArray();
info.ValueString = editor.valueStrings.ToArray();
info.ValueInt = editor.valueInts.ToArray();
ListViewItem item = new ListViewItem();
item.Text = info.Name;
string Value = "";
switch (info.Type)
{
case RenderInfoType.Int32:
Value = string.Join(",", info.ValueInt);
break;
case RenderInfoType.Single:
Value = string.Join(",", info.ValueFloat);
break;
case RenderInfoType.String:
Value = string.Join(",", info.ValueString);
break;
}
item.SubItems.Add(Value);
item.SubItems.Add(info.Type.ToString());
// renderInfoListView.Items[ActiveInfoIndex] = item;
// InitializeRenderInfoList(material);
}
}
}
}
}
private void btnExportParams_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Material Params|*.xml;";
sfd.DefaultExt = ".xml";
sfd.FileName = material.Text + ".MatParams";
if (sfd.ShowDialog() == DialogResult.OK)
{
FMAT2XML.Save(material, sfd.FileName, true);
}
}
private void btnReplaceParams_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Material Params|*.xml;";
ofd.DefaultExt = ".xml";
ofd.FileName = material.Text + ".MatParams";
if (ofd.ShowDialog() == DialogResult.OK)
{
FMAT2XML.Read(material, ofd.FileName, true);
}
}
private void shaderOptionsListView_DoubleClick(object sender, EventArgs e)
{
int ActiveIndex = shaderOptionsListView.SelectedIndices[0];
if (shaderOptionsListView.SelectedItems.Count > 0)
{
string Key = shaderOptionsListView.SelectedItems[0].Text;
string Value = shaderOptionsListView.SelectedItems[0].SubItems[1].Text;
BfresShaderOptionsEditor edtior = new BfresShaderOptionsEditor();
edtior.LoadOption(Key, Value);
if (edtior.ShowDialog() == DialogResult.OK)
{
material.shaderassign.options[shaderOptionsListView.SelectedItems[0].Text] = edtior.textBoxValue.Text;
InitializeShaderOptionList(material);
shaderOptionsListView.Items[ActiveIndex].Selected = true;
shaderOptionsListView.Select();
}
}
}
private void chkboxVisible_CheckedChanged(object sender, EventArgs e)
{
material.Enabled = chkboxVisible.Checked;
}
private void btnSamplerEditor_Click(object sender, EventArgs e)
{
if (textureRefListView.SelectedItems.Count <= 0)
return;
SamplerEditor samplerEditor = new SamplerEditor();
foreach (MatTexture tex in material.TextureMaps)
{
if (tex.Name == textureRefListView.SelectedItems[0].Text)
{
samplerEditor.LoadSampler(tex);
}
}
if (samplerEditor.ShowDialog() == DialogResult.OK)
{
}
}
private void textureRefListView_SelectedIndexChanged(object sender, EventArgs e)
{
if (textureRefListView.SelectedItems.Count > 0)
btnSamplerEditor.Enabled = true;
else
btnSamplerEditor.Enabled = false;
}
private void shaderOptionsListView_ColumnClick(object sender, ColumnClickEventArgs e)
{
Sorter s = (Sorter)shaderOptionsListView.ListViewItemSorter;
s.Column = e.Column;
if (s.Order == SortOrder.Ascending)
{
s.Order = SortOrder.Descending;
}
else
{
s.Order = SortOrder.Ascending;
}
shaderOptionsListView.Sort();
}
class Sorter : System.Collections.IComparer
{
public int Column = 0;
public System.Windows.Forms.SortOrder Order = SortOrder.Ascending;
public int Compare(object x, object y) // IComparer Member
{
if (!(x is ListViewItem))
return (0);
if (!(y is ListViewItem))
return (0);
ListViewItem l1 = (ListViewItem)x;
ListViewItem l2 = (ListViewItem)y;
if (l1.ListView.Columns[Column].Tag == null)
{
l1.ListView.Columns[Column].Tag = "Text";
}
if (l1.ListView.Columns[Column].Tag.ToString() == "Numeric")
{
float fl1 = float.Parse(l1.SubItems[Column].Text);
float fl2 = float.Parse(l2.SubItems[Column].Text);
if (Order == SortOrder.Ascending)
{
return fl1.CompareTo(fl2);
}
else
{
return fl2.CompareTo(fl1);
}
}
else
{
string str1 = l1.SubItems[Column].Text;
string str2 = l2.SubItems[Column].Text;
if (Order == SortOrder.Ascending)
{
return str1.CompareTo(str2);
}
else
{
return str2.CompareTo(str1);
}
}
}
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,797 +0,0 @@
namespace FirstPlugin
{
partial class BfresModelImportSettings
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.comboBoxFormatPositions = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.comboBoxFormatNormals = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.label5 = new System.Windows.Forms.Label();
this.comboBoxFormatUvs = new System.Windows.Forms.ComboBox();
this.label6 = new System.Windows.Forms.Label();
this.panel4 = new System.Windows.Forms.Panel();
this.label7 = new System.Windows.Forms.Label();
this.comboBoxFormatVertexColors = new System.Windows.Forms.ComboBox();
this.label8 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.label9 = new System.Windows.Forms.Label();
this.comboBoxFormatTangents = new System.Windows.Forms.ComboBox();
this.label10 = new System.Windows.Forms.Label();
this.panel6 = new System.Windows.Forms.Panel();
this.label11 = new System.Windows.Forms.Label();
this.comboBoxFormatBitans = new System.Windows.Forms.ComboBox();
this.label12 = new System.Windows.Forms.Label();
this.panel7 = new System.Windows.Forms.Panel();
this.comboBoxFormatIndices = new System.Windows.Forms.ComboBox();
this.label15 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.comboBoxFormatWeights = new System.Windows.Forms.ComboBox();
this.label14 = new System.Windows.Forms.Label();
this.chkBoxFlipUvsY = new System.Windows.Forms.CheckBox();
this.chkBoxImportBones = new System.Windows.Forms.CheckBox();
this.panel8 = new System.Windows.Forms.Panel();
this.chkBoxRotNegative90Y = new System.Windows.Forms.CheckBox();
this.useMaterialLabel = new System.Windows.Forms.Label();
this.textBoxMaterialPath = new System.Windows.Forms.TextBox();
this.chkBoxEnableWeightIndices = new System.Windows.Forms.CheckBox();
this.chkBoxEnableBitans = new System.Windows.Forms.CheckBox();
this.chkBoxEnableTans = new System.Windows.Forms.CheckBox();
this.chkBoxEnableVertColors = new System.Windows.Forms.CheckBox();
this.chkBoxEnableUVs = new System.Windows.Forms.CheckBox();
this.chkBoxEnableNormals = new System.Windows.Forms.CheckBox();
this.chkBoxEnablePositions = new System.Windows.Forms.CheckBox();
this.chkBoxRecalcNormals = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.chkBoxTransformMatrix = new System.Windows.Forms.CheckBox();
this.chkBoxRot90Y = new System.Windows.Forms.CheckBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.checkBox9 = new System.Windows.Forms.CheckBox();
this.panel9 = new System.Windows.Forms.Panel();
this.comboBoxFormatFaces = new System.Windows.Forms.ComboBox();
this.label18 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tabPageAdvanced = new System.Windows.Forms.TabPage();
this.chkBoxParamDefaults = new System.Windows.Forms.CheckBox();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
this.panel5.SuspendLayout();
this.panel6.SuspendLayout();
this.panel7.SuspendLayout();
this.panel8.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.panel9.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabPageAdvanced.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.comboBoxFormatPositions);
this.panel1.Controls.Add(this.label1);
this.panel1.Location = new System.Drawing.Point(6, 6);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(215, 66);
this.panel1.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 7);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(49, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Positions";
//
// comboBoxFormatPositions
//
this.comboBoxFormatPositions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatPositions.FormattingEnabled = true;
this.comboBoxFormatPositions.Location = new System.Drawing.Point(50, 37);
this.comboBoxFormatPositions.Name = "comboBoxFormatPositions";
this.comboBoxFormatPositions.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatPositions.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(5, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(39, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Format";
//
// panel2
//
this.panel2.Controls.Add(this.label3);
this.panel2.Controls.Add(this.comboBoxFormatNormals);
this.panel2.Controls.Add(this.label4);
this.panel2.Location = new System.Drawing.Point(3, 78);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(218, 64);
this.panel2.TabIndex = 4;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 7);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(45, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Normals";
//
// comboBoxFormatNormals
//
this.comboBoxFormatNormals.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatNormals.FormattingEnabled = true;
this.comboBoxFormatNormals.Location = new System.Drawing.Point(53, 34);
this.comboBoxFormatNormals.Name = "comboBoxFormatNormals";
this.comboBoxFormatNormals.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatNormals.TabIndex = 1;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(8, 37);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(39, 13);
this.label4.TabIndex = 0;
this.label4.Text = "Format";
//
// panel3
//
this.panel3.Controls.Add(this.label5);
this.panel3.Controls.Add(this.comboBoxFormatUvs);
this.panel3.Controls.Add(this.label6);
this.panel3.Location = new System.Drawing.Point(3, 149);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(218, 60);
this.panel3.TabIndex = 5;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(3, 7);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(27, 13);
this.label5.TabIndex = 2;
this.label5.Text = "UVs";
//
// comboBoxFormatUvs
//
this.comboBoxFormatUvs.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatUvs.FormattingEnabled = true;
this.comboBoxFormatUvs.Location = new System.Drawing.Point(53, 26);
this.comboBoxFormatUvs.Name = "comboBoxFormatUvs";
this.comboBoxFormatUvs.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatUvs.TabIndex = 1;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(8, 29);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(39, 13);
this.label6.TabIndex = 0;
this.label6.Text = "Format";
//
// panel4
//
this.panel4.Controls.Add(this.label7);
this.panel4.Controls.Add(this.comboBoxFormatVertexColors);
this.panel4.Controls.Add(this.label8);
this.panel4.Location = new System.Drawing.Point(3, 215);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(218, 70);
this.panel4.TabIndex = 6;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(3, 7);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(64, 13);
this.label7.TabIndex = 2;
this.label7.Text = "Verte Colors";
//
// comboBoxFormatVertexColors
//
this.comboBoxFormatVertexColors.Cursor = System.Windows.Forms.Cursors.Arrow;
this.comboBoxFormatVertexColors.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatVertexColors.FormattingEnabled = true;
this.comboBoxFormatVertexColors.Location = new System.Drawing.Point(53, 33);
this.comboBoxFormatVertexColors.Name = "comboBoxFormatVertexColors";
this.comboBoxFormatVertexColors.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatVertexColors.TabIndex = 1;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(8, 36);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(39, 13);
this.label8.TabIndex = 0;
this.label8.Text = "Format";
//
// panel5
//
this.panel5.Controls.Add(this.label9);
this.panel5.Controls.Add(this.comboBoxFormatTangents);
this.panel5.Controls.Add(this.label10);
this.panel5.Location = new System.Drawing.Point(227, 6);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(280, 66);
this.panel5.TabIndex = 7;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(3, 7);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(52, 13);
this.label9.TabIndex = 2;
this.label9.Text = "Tangents";
//
// comboBoxFormatTangents
//
this.comboBoxFormatTangents.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatTangents.FormattingEnabled = true;
this.comboBoxFormatTangents.Location = new System.Drawing.Point(60, 37);
this.comboBoxFormatTangents.Name = "comboBoxFormatTangents";
this.comboBoxFormatTangents.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatTangents.TabIndex = 1;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(11, 40);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(39, 13);
this.label10.TabIndex = 0;
this.label10.Text = "Format";
//
// panel6
//
this.panel6.Controls.Add(this.label11);
this.panel6.Controls.Add(this.comboBoxFormatBitans);
this.panel6.Controls.Add(this.label12);
this.panel6.Location = new System.Drawing.Point(227, 78);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(280, 64);
this.panel6.TabIndex = 8;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(3, 7);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(57, 13);
this.label11.TabIndex = 2;
this.label11.Text = "Bitangents";
//
// comboBoxFormatBitans
//
this.comboBoxFormatBitans.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatBitans.FormattingEnabled = true;
this.comboBoxFormatBitans.Location = new System.Drawing.Point(51, 34);
this.comboBoxFormatBitans.Name = "comboBoxFormatBitans";
this.comboBoxFormatBitans.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatBitans.TabIndex = 1;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(6, 37);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(39, 13);
this.label12.TabIndex = 0;
this.label12.Text = "Format";
//
// panel7
//
this.panel7.Controls.Add(this.comboBoxFormatIndices);
this.panel7.Controls.Add(this.label15);
this.panel7.Controls.Add(this.label13);
this.panel7.Controls.Add(this.comboBoxFormatWeights);
this.panel7.Controls.Add(this.label14);
this.panel7.Location = new System.Drawing.Point(227, 148);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(280, 96);
this.panel7.TabIndex = 9;
//
// comboBoxFormatIndices
//
this.comboBoxFormatIndices.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatIndices.FormattingEnabled = true;
this.comboBoxFormatIndices.Location = new System.Drawing.Point(92, 60);
this.comboBoxFormatIndices.Name = "comboBoxFormatIndices";
this.comboBoxFormatIndices.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatIndices.TabIndex = 5;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(2, 63);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(82, 13);
this.label15.TabIndex = 4;
this.label15.Text = "Format (Indices)";
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(3, 7);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(85, 13);
this.label13.TabIndex = 2;
this.label13.Text = "Indices/Weights";
this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// comboBoxFormatWeights
//
this.comboBoxFormatWeights.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatWeights.FormattingEnabled = true;
this.comboBoxFormatWeights.Location = new System.Drawing.Point(92, 30);
this.comboBoxFormatWeights.Name = "comboBoxFormatWeights";
this.comboBoxFormatWeights.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatWeights.TabIndex = 1;
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(2, 33);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(87, 13);
this.label14.TabIndex = 0;
this.label14.Text = "Format (Weights)";
//
// chkBoxFlipUvsY
//
this.chkBoxFlipUvsY.AutoSize = true;
this.chkBoxFlipUvsY.Location = new System.Drawing.Point(3, 39);
this.chkBoxFlipUvsY.Name = "chkBoxFlipUvsY";
this.chkBoxFlipUvsY.Size = new System.Drawing.Size(65, 17);
this.chkBoxFlipUvsY.TabIndex = 4;
this.chkBoxFlipUvsY.Text = "Flip UVs";
this.chkBoxFlipUvsY.UseVisualStyleBackColor = true;
this.chkBoxFlipUvsY.CheckedChanged += new System.EventHandler(this.chkBoxSettings_CheckedChanged);
//
// chkBoxImportBones
//
this.chkBoxImportBones.AutoSize = true;
this.chkBoxImportBones.Location = new System.Drawing.Point(3, 62);
this.chkBoxImportBones.Name = "chkBoxImportBones";
this.chkBoxImportBones.Size = new System.Drawing.Size(88, 17);
this.chkBoxImportBones.TabIndex = 10;
this.chkBoxImportBones.Text = "Import Bones";
this.chkBoxImportBones.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkBoxImportBones.UseVisualStyleBackColor = true;
this.chkBoxImportBones.CheckedChanged += new System.EventHandler(this.chkBoxSettings_CheckedChanged);
//
// panel8
//
this.panel8.Controls.Add(this.chkBoxParamDefaults);
this.panel8.Controls.Add(this.chkBoxRotNegative90Y);
this.panel8.Controls.Add(this.useMaterialLabel);
this.panel8.Controls.Add(this.textBoxMaterialPath);
this.panel8.Controls.Add(this.chkBoxEnableWeightIndices);
this.panel8.Controls.Add(this.chkBoxEnableBitans);
this.panel8.Controls.Add(this.chkBoxEnableTans);
this.panel8.Controls.Add(this.chkBoxEnableVertColors);
this.panel8.Controls.Add(this.chkBoxEnableUVs);
this.panel8.Controls.Add(this.chkBoxEnableNormals);
this.panel8.Controls.Add(this.chkBoxEnablePositions);
this.panel8.Controls.Add(this.chkBoxRecalcNormals);
this.panel8.Controls.Add(this.button1);
this.panel8.Controls.Add(this.chkBoxTransformMatrix);
this.panel8.Controls.Add(this.chkBoxRot90Y);
this.panel8.Controls.Add(this.pictureBox1);
this.panel8.Controls.Add(this.checkBox9);
this.panel8.Controls.Add(this.chkBoxFlipUvsY);
this.panel8.Controls.Add(this.chkBoxImportBones);
this.panel8.Location = new System.Drawing.Point(8, 6);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(498, 322);
this.panel8.TabIndex = 11;
//
// chkBoxRotNegative90Y
//
this.chkBoxRotNegative90Y.AutoSize = true;
this.chkBoxRotNegative90Y.Location = new System.Drawing.Point(3, 108);
this.chkBoxRotNegative90Y.Name = "chkBoxRotNegative90Y";
this.chkBoxRotNegative90Y.Size = new System.Drawing.Size(117, 17);
this.chkBoxRotNegative90Y.TabIndex = 29;
this.chkBoxRotNegative90Y.Text = "Rotate -90 degrees";
this.chkBoxRotNegative90Y.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkBoxRotNegative90Y.UseVisualStyleBackColor = true;
//
// useMaterialLabel
//
this.useMaterialLabel.AutoSize = true;
this.useMaterialLabel.Location = new System.Drawing.Point(3, 209);
this.useMaterialLabel.Name = "useMaterialLabel";
this.useMaterialLabel.Size = new System.Drawing.Size(68, 13);
this.useMaterialLabel.TabIndex = 28;
this.useMaterialLabel.Text = "Use material:";
//
// textBoxMaterialPath
//
this.textBoxMaterialPath.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.textBoxMaterialPath.ForeColor = System.Drawing.Color.White;
this.textBoxMaterialPath.Location = new System.Drawing.Point(3, 225);
this.textBoxMaterialPath.Name = "textBoxMaterialPath";
this.textBoxMaterialPath.ReadOnly = true;
this.textBoxMaterialPath.Size = new System.Drawing.Size(162, 20);
this.textBoxMaterialPath.TabIndex = 27;
this.textBoxMaterialPath.Click += new System.EventHandler(this.textBox1_Click);
this.textBoxMaterialPath.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// chkBoxEnableWeightIndices
//
this.chkBoxEnableWeightIndices.AutoSize = true;
this.chkBoxEnableWeightIndices.Location = new System.Drawing.Point(240, 154);
this.chkBoxEnableWeightIndices.Name = "chkBoxEnableWeightIndices";
this.chkBoxEnableWeightIndices.Size = new System.Drawing.Size(140, 17);
this.chkBoxEnableWeightIndices.TabIndex = 25;
this.chkBoxEnableWeightIndices.Text = "Enable Indices/Weights";
this.chkBoxEnableWeightIndices.UseVisualStyleBackColor = true;
//
// chkBoxEnableBitans
//
this.chkBoxEnableBitans.AutoSize = true;
this.chkBoxEnableBitans.Location = new System.Drawing.Point(240, 131);
this.chkBoxEnableBitans.Name = "chkBoxEnableBitans";
this.chkBoxEnableBitans.Size = new System.Drawing.Size(112, 17);
this.chkBoxEnableBitans.TabIndex = 24;
this.chkBoxEnableBitans.Text = "Enable Bitangents";
this.chkBoxEnableBitans.UseVisualStyleBackColor = true;
//
// chkBoxEnableTans
//
this.chkBoxEnableTans.AutoSize = true;
this.chkBoxEnableTans.Location = new System.Drawing.Point(240, 108);
this.chkBoxEnableTans.Name = "chkBoxEnableTans";
this.chkBoxEnableTans.Size = new System.Drawing.Size(107, 17);
this.chkBoxEnableTans.TabIndex = 23;
this.chkBoxEnableTans.Text = "Enable Tangents";
this.chkBoxEnableTans.UseVisualStyleBackColor = true;
this.chkBoxEnableTans.CheckedChanged += new System.EventHandler(this.chkBoxEnableAttribute_CheckedChanged);
//
// chkBoxEnableVertColors
//
this.chkBoxEnableVertColors.AutoSize = true;
this.chkBoxEnableVertColors.Location = new System.Drawing.Point(240, 85);
this.chkBoxEnableVertColors.Name = "chkBoxEnableVertColors";
this.chkBoxEnableVertColors.Size = new System.Drawing.Size(124, 17);
this.chkBoxEnableVertColors.TabIndex = 22;
this.chkBoxEnableVertColors.Text = "Enable Vertex Colors";
this.chkBoxEnableVertColors.UseVisualStyleBackColor = true;
this.chkBoxEnableVertColors.CheckedChanged += new System.EventHandler(this.chkBoxEnableAttribute_CheckedChanged);
//
// chkBoxEnableUVs
//
this.chkBoxEnableUVs.AutoSize = true;
this.chkBoxEnableUVs.Location = new System.Drawing.Point(240, 62);
this.chkBoxEnableUVs.Name = "chkBoxEnableUVs";
this.chkBoxEnableUVs.Size = new System.Drawing.Size(82, 17);
this.chkBoxEnableUVs.TabIndex = 21;
this.chkBoxEnableUVs.Text = "Enable UVs";
this.chkBoxEnableUVs.UseVisualStyleBackColor = true;
this.chkBoxEnableUVs.CheckedChanged += new System.EventHandler(this.chkBoxEnableAttribute_CheckedChanged);
//
// chkBoxEnableNormals
//
this.chkBoxEnableNormals.AutoSize = true;
this.chkBoxEnableNormals.Location = new System.Drawing.Point(240, 39);
this.chkBoxEnableNormals.Name = "chkBoxEnableNormals";
this.chkBoxEnableNormals.Size = new System.Drawing.Size(100, 17);
this.chkBoxEnableNormals.TabIndex = 20;
this.chkBoxEnableNormals.Text = "Enable Normals";
this.chkBoxEnableNormals.UseVisualStyleBackColor = true;
this.chkBoxEnableNormals.CheckedChanged += new System.EventHandler(this.chkBoxEnableAttribute_CheckedChanged);
//
// chkBoxEnablePositions
//
this.chkBoxEnablePositions.AutoSize = true;
this.chkBoxEnablePositions.Enabled = false;
this.chkBoxEnablePositions.Location = new System.Drawing.Point(240, 16);
this.chkBoxEnablePositions.Name = "chkBoxEnablePositions";
this.chkBoxEnablePositions.Size = new System.Drawing.Size(104, 17);
this.chkBoxEnablePositions.TabIndex = 19;
this.chkBoxEnablePositions.Text = "Enable Positions";
this.chkBoxEnablePositions.UseVisualStyleBackColor = true;
this.chkBoxEnablePositions.CheckedChanged += new System.EventHandler(this.chkBoxEnableAttribute_CheckedChanged);
//
// chkBoxRecalcNormals
//
this.chkBoxRecalcNormals.AutoSize = true;
this.chkBoxRecalcNormals.Location = new System.Drawing.Point(3, 154);
this.chkBoxRecalcNormals.Name = "chkBoxRecalcNormals";
this.chkBoxRecalcNormals.Size = new System.Drawing.Size(124, 17);
this.chkBoxRecalcNormals.TabIndex = 18;
this.chkBoxRecalcNormals.Text = "Recalculate Normals";
this.chkBoxRecalcNormals.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkBoxRecalcNormals.UseVisualStyleBackColor = true;
this.chkBoxRecalcNormals.CheckedChanged += new System.EventHandler(this.chkBoxSettings_CheckedChanged);
//
// button1
//
this.button1.Cursor = System.Windows.Forms.Cursors.Default;
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Location = new System.Drawing.Point(420, 296);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 17;
this.button1.Text = "Save";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// chkBoxTransformMatrix
//
this.chkBoxTransformMatrix.AutoSize = true;
this.chkBoxTransformMatrix.Location = new System.Drawing.Point(3, 131);
this.chkBoxTransformMatrix.Name = "chkBoxTransformMatrix";
this.chkBoxTransformMatrix.Size = new System.Drawing.Size(104, 17);
this.chkBoxTransformMatrix.TabIndex = 14;
this.chkBoxTransformMatrix.Text = "Transform Matrix";
this.chkBoxTransformMatrix.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkBoxTransformMatrix.UseVisualStyleBackColor = true;
this.chkBoxTransformMatrix.CheckedChanged += new System.EventHandler(this.chkBoxSettings_CheckedChanged);
//
// chkBoxRot90Y
//
this.chkBoxRot90Y.AutoSize = true;
this.chkBoxRot90Y.Location = new System.Drawing.Point(3, 85);
this.chkBoxRot90Y.Name = "chkBoxRot90Y";
this.chkBoxRot90Y.Size = new System.Drawing.Size(114, 17);
this.chkBoxRot90Y.TabIndex = 13;
this.chkBoxRot90Y.Text = "Rotate 90 degrees";
this.chkBoxRot90Y.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.chkBoxRot90Y.UseVisualStyleBackColor = true;
this.chkBoxRot90Y.CheckedChanged += new System.EventHandler(this.chkBoxSettings_CheckedChanged);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.White;
this.pictureBox1.Location = new System.Drawing.Point(3, 180);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(17, 17);
this.pictureBox1.TabIndex = 12;
this.pictureBox1.TabStop = false;
//
// checkBox9
//
this.checkBox9.AutoSize = true;
this.checkBox9.Location = new System.Drawing.Point(25, 181);
this.checkBox9.Name = "checkBox9";
this.checkBox9.Size = new System.Drawing.Size(130, 17);
this.checkBox9.TabIndex = 11;
this.checkBox9.Text = "Overwrite Vertex color";
this.checkBox9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.checkBox9.UseVisualStyleBackColor = true;
//
// panel9
//
this.panel9.Controls.Add(this.comboBoxFormatFaces);
this.panel9.Controls.Add(this.label18);
this.panel9.Controls.Add(this.label17);
this.panel9.Location = new System.Drawing.Point(227, 248);
this.panel9.Name = "panel9";
this.panel9.Size = new System.Drawing.Size(280, 37);
this.panel9.TabIndex = 16;
//
// comboBoxFormatFaces
//
this.comboBoxFormatFaces.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFormatFaces.FormattingEnabled = true;
this.comboBoxFormatFaces.Location = new System.Drawing.Point(102, 7);
this.comboBoxFormatFaces.Name = "comboBoxFormatFaces";
this.comboBoxFormatFaces.Size = new System.Drawing.Size(157, 21);
this.comboBoxFormatFaces.TabIndex = 5;
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(57, 11);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(39, 13);
this.label18.TabIndex = 4;
this.label18.Text = "Format";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(11, 11);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(36, 13);
this.label17.TabIndex = 15;
this.label17.Text = "Faces";
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPageAdvanced);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(520, 360);
this.tabControl1.TabIndex = 18;
//
// tabPage2
//
this.tabPage2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.tabPage2.Controls.Add(this.panel8);
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(512, 334);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Model Settings";
//
// tabPageAdvanced
//
this.tabPageAdvanced.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.tabPageAdvanced.Controls.Add(this.panel1);
this.tabPageAdvanced.Controls.Add(this.panel9);
this.tabPageAdvanced.Controls.Add(this.panel2);
this.tabPageAdvanced.Controls.Add(this.panel4);
this.tabPageAdvanced.Controls.Add(this.panel7);
this.tabPageAdvanced.Controls.Add(this.panel3);
this.tabPageAdvanced.Controls.Add(this.panel6);
this.tabPageAdvanced.Controls.Add(this.panel5);
this.tabPageAdvanced.ForeColor = System.Drawing.Color.White;
this.tabPageAdvanced.Location = new System.Drawing.Point(4, 22);
this.tabPageAdvanced.Name = "tabPageAdvanced";
this.tabPageAdvanced.Padding = new System.Windows.Forms.Padding(3);
this.tabPageAdvanced.Size = new System.Drawing.Size(512, 334);
this.tabPageAdvanced.TabIndex = 0;
this.tabPageAdvanced.Text = "Advanced Settings";
//
// chkBoxParamDefaults
//
this.chkBoxParamDefaults.AutoSize = true;
this.chkBoxParamDefaults.Location = new System.Drawing.Point(3, 16);
this.chkBoxParamDefaults.Name = "chkBoxParamDefaults";
this.chkBoxParamDefaults.Size = new System.Drawing.Size(117, 17);
this.chkBoxParamDefaults.TabIndex = 30;
this.chkBoxParamDefaults.Text = "Set Param Defaults";
this.chkBoxParamDefaults.UseVisualStyleBackColor = true;
this.chkBoxParamDefaults.CheckedChanged += new System.EventHandler(this.chkBoxSettings_CheckedChanged);
//
// BfresModelImportSettings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(520, 360);
this.Controls.Add(this.tabControl1);
this.ForeColor = System.Drawing.Color.White;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "BfresModelImportSettings";
this.Text = "Import Settings";
this.Load += new System.EventHandler(this.BfresModelImportSettings_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel4.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel6.ResumeLayout(false);
this.panel6.PerformLayout();
this.panel7.ResumeLayout(false);
this.panel7.PerformLayout();
this.panel8.ResumeLayout(false);
this.panel8.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.panel9.ResumeLayout(false);
this.panel9.PerformLayout();
this.tabControl1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPageAdvanced.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBoxFormatPositions;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comboBoxFormatNormals;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox comboBoxFormatUvs;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.ComboBox comboBoxFormatVertexColors;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.ComboBox comboBoxFormatTangents;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.ComboBox comboBoxFormatBitans;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Panel panel7;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.ComboBox comboBoxFormatWeights;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.ComboBox comboBoxFormatIndices;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.CheckBox chkBoxFlipUvsY;
private System.Windows.Forms.CheckBox chkBoxImportBones;
private System.Windows.Forms.Panel panel8;
private System.Windows.Forms.CheckBox chkBoxTransformMatrix;
private System.Windows.Forms.CheckBox chkBoxRot90Y;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.CheckBox checkBox9;
private System.Windows.Forms.Panel panel9;
private System.Windows.Forms.ComboBox comboBoxFormatFaces;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabPage tabPageAdvanced;
private System.Windows.Forms.CheckBox chkBoxRecalcNormals;
private System.Windows.Forms.CheckBox chkBoxEnableWeightIndices;
private System.Windows.Forms.CheckBox chkBoxEnableBitans;
private System.Windows.Forms.CheckBox chkBoxEnableTans;
private System.Windows.Forms.CheckBox chkBoxEnableVertColors;
private System.Windows.Forms.CheckBox chkBoxEnableUVs;
private System.Windows.Forms.CheckBox chkBoxEnableNormals;
private System.Windows.Forms.CheckBox chkBoxEnablePositions;
private System.Windows.Forms.Label useMaterialLabel;
private System.Windows.Forms.TextBox textBoxMaterialPath;
private System.Windows.Forms.CheckBox chkBoxRotNegative90Y;
private System.Windows.Forms.CheckBox chkBoxParamDefaults;
}
}

View File

@ -1,353 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Syroot.NintenTools.NSW.Bfres.GFX;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
using Bfres.Structs;
namespace FirstPlugin
{
public partial class BfresModelImportSettings : Form
{
public BfresModelImportSettings()
{
InitializeComponent();
ExternalMaterialPath = PluginRuntime.ExternalFMATPath;
if (System.IO.File.Exists(PluginRuntime.ExternalFMATPath))
textBoxMaterialPath.Text = System.IO.Path.GetFileName(PluginRuntime.ExternalFMATPath);
else
{
textBoxMaterialPath.BackColor = System.Drawing.Color.DarkRed;
textBoxMaterialPath.Text = "(Select Material!)";
ExternalMaterialPath = "";
}
}
public bool EnablePositions;
public bool EnableNormals;
public bool EnableUV0;
public bool EnableUV1;
public bool EnableUV2;
public bool EnableTangents;
public bool EnableBitangents;
public bool EnableWeights;
public bool EnableIndices;
public bool EnableVertexColors;
public bool FlipUVsVertical;
public bool FlipUVsHorizontal;
public bool ImportBones;
public bool Rotate90DegreesY;
public bool Rotate90DegreesX;
public bool Rotate90DegreesNegativeY;
public bool Rotate90DegreesNegativeX;
public bool RecalculateNormals;
public string ExternalMaterialPath;
public bool SetDefaultParamData;
public void DisableMaterialEdits()
{
textBoxMaterialPath.Visible = false;
useMaterialLabel.Visible = false;
}
public void SetModelAttributes(STGenericObject obj)
{
chkBoxEnablePositions.Enabled = true;
chkBoxEnablePositions.Checked = obj.HasPos;
chkBoxEnableNormals.Checked = obj.HasNrm;
chkBoxEnableUVs.Checked = obj.HasUv0;
chkBoxEnableTans.Checked = obj.HasUv0;
chkBoxEnableBitans.Checked = obj.HasUv0;
chkBoxEnableWeightIndices.Checked = obj.HasWeights;
chkBoxEnableVertColors.Checked = obj.HasVertColors;
chkBoxParamDefaults.Checked = true;
chkBoxTransformMatrix.Checked = true;
if (!obj.HasPos)
DisableAttribute(chkBoxEnablePositions, comboBoxFormatPositions);
if (!obj.HasNrm)
DisableAttribute(chkBoxEnableNormals, comboBoxFormatPositions);
if (!obj.HasUv0)
DisableAttribute(chkBoxEnableUVs, comboBoxFormatUvs);
//Note. Bitans/tans uses uvs to generate
if (!obj.HasUv0)
DisableAttribute(chkBoxEnableTans, comboBoxFormatTangents);
if (!obj.HasUv0)
DisableAttribute(chkBoxEnableBitans, comboBoxFormatBitans);
if (!obj.HasWeights && !obj.HasIndices)
{
DisableAttribute(chkBoxEnableWeightIndices, comboBoxFormatWeights);
DisableAttribute(chkBoxEnableWeightIndices, comboBoxFormatIndices);
}
if (!obj.HasVertColors)
DisableAttribute(chkBoxEnableVertColors, comboBoxFormatVertexColors);
EnableUV1 = obj.HasUv1;
EnableUV2 = obj.HasUv2;
}
public List<FSHP.VertexAttribute> CreateNewAttributes()
{
List<FSHP.VertexAttribute> attribute = new List<FSHP.VertexAttribute>();
if (EnablePositions)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_p0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatPositions));
attribute.Add(att);
}
if (EnableNormals)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_n0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatNormals));
attribute.Add(att);
}
if (EnableVertexColors)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_c0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatVertexColors));
attribute.Add(att);
}
if (EnableUV0)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_u0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatUvs));
attribute.Add(att);
}
if (EnableUV1 && EnableUV0)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_u1";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatUvs));
attribute.Add(att);
}
if (EnableUV2 && EnableUV0)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_u2";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatUvs));
attribute.Add(att);
}
if (EnableTangents)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_t0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatTangents));
attribute.Add(att);
}
if (EnableBitangents)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_b0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatBitans));
attribute.Add(att);
}
if (EnableWeights)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_w0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatWeights));
attribute.Add(att);
}
if (EnableIndices)
{
FSHP.VertexAttribute att = new FSHP.VertexAttribute();
att.Name = "_i0";
att.Format = SetAttribFormat(GetCmboxString(comboBoxFormatIndices));
attribute.Add(att);
}
return attribute;
}
private string GetCmboxString(ComboBox comboBox)
{
return comboBox.GetItemText(comboBox.SelectedItem);
}
private void DisableAttribute(CheckBox checkBox, ComboBox comboBox)
{
}
//Based on Wexos Toolbox since I'm not sure what formats to use for each attribute
//Thanks Wexos!
private void BfresModelImportSettings_Load(object sender, EventArgs e)
{
comboBoxFormatPositions.Items.Add("Format_32_32_32_Single");
comboBoxFormatPositions.Items.Add("Format_16_16_16_16_Single");
comboBoxFormatPositions.Items.Add("Format_16_16_16_16_SNorm");
comboBoxFormatPositions.Items.Add("Format_10_10_10_2_SNorm");
comboBoxFormatPositions.Items.Add("Format_8_8_8_8_SNorm");
comboBoxFormatPositions.SelectedIndex = 0;
comboBoxFormatNormals.Items.Add("Format_32_32_32_Single");
comboBoxFormatNormals.Items.Add("Format_16_16_16_16_Single");
comboBoxFormatNormals.Items.Add("Format_16_16_16_16_SNorm");
comboBoxFormatNormals.Items.Add("Format_10_10_10_2_SNorm");
comboBoxFormatNormals.Items.Add("Format_8_8_8_8_SNorm");
comboBoxFormatNormals.SelectedIndex = 3;
comboBoxFormatIndices.Items.Add("Format_32_32_32_32_UInt");
comboBoxFormatIndices.Items.Add("Format_16_16_16_16_UInt");
comboBoxFormatIndices.Items.Add("Format_8_8_8_8_UInt");
comboBoxFormatIndices.Items.Add("Format_32_32_UInt");
comboBoxFormatIndices.Items.Add("Format_16_16_UInt");
comboBoxFormatIndices.Items.Add("Format_8_8_UInt");
comboBoxFormatIndices.Items.Add("Format_32_UInt");
comboBoxFormatIndices.Items.Add("Format_16_UInt");
comboBoxFormatIndices.Items.Add("Format_8_UInt");
comboBoxFormatIndices.SelectedIndex = 2;
comboBoxFormatWeights.Items.Add("Format_32_32_32_32_Single");
comboBoxFormatWeights.Items.Add("Format_16_16_16_16_UNorm");
comboBoxFormatWeights.Items.Add("Format_8_8_8_8_UNorm");
comboBoxFormatWeights.Items.Add("Format_32_32_Single");
comboBoxFormatWeights.Items.Add("Format_16_16_Single");
comboBoxFormatWeights.Items.Add("Format_16_16_UNorm");
comboBoxFormatWeights.Items.Add("Format_8_8_UNorm");
comboBoxFormatWeights.Items.Add("Format_8_UNorm");
comboBoxFormatWeights.SelectedIndex = 2;
comboBoxFormatTangents.Items.Add("Format_32_32_32_32_Single");
comboBoxFormatTangents.Items.Add("Format_16_16_16_16_Single");
comboBoxFormatTangents.Items.Add("Format_16_16_16_16_SNorm");
comboBoxFormatTangents.Items.Add("Format_10_10_10_2_SNorm");
comboBoxFormatTangents.Items.Add("Format_8_8_8_8_SNorm");
comboBoxFormatTangents.SelectedIndex = 4;
comboBoxFormatBitans.Items.Add("Format_32_32_32_32_Single");
comboBoxFormatBitans.Items.Add("Format_16_16_16_16_Single");
comboBoxFormatBitans.Items.Add("Format_16_16_16_16_SNorm");
comboBoxFormatBitans.Items.Add("Format_10_10_10_2_SNorm");
comboBoxFormatBitans.Items.Add("Format_8_8_8_8_SNorm");
comboBoxFormatBitans.SelectedIndex = 4;
comboBoxFormatUvs.Items.Add("Format_32_32_Single");
comboBoxFormatUvs.Items.Add("Format_16_16_Single");
comboBoxFormatUvs.Items.Add("Format_16_16_SNorm");
comboBoxFormatUvs.Items.Add("Format_8_8_SNorm");
comboBoxFormatUvs.Items.Add("Format_8_8_UNorm");
comboBoxFormatUvs.SelectedIndex = 1;
comboBoxFormatVertexColors.Items.Add("Format_32_32_Single");
comboBoxFormatVertexColors.Items.Add("Format_16_16_Single");
comboBoxFormatVertexColors.Items.Add("Format_16_16_SNorm");
comboBoxFormatVertexColors.Items.Add("Format_10_10_10_2_SNorm");
comboBoxFormatVertexColors.Items.Add("Format_8_8_SNorm");
comboBoxFormatVertexColors.SelectedIndex = 3;
comboBoxFormatFaces.Items.Add("UInt16");
comboBoxFormatFaces.Items.Add("UInt32");
comboBoxFormatFaces.SelectedIndex = 0;
}
private void chkBoxEnableAttribute_CheckedChanged(object sender, EventArgs e)
{
EnablePositions = chkBoxEnablePositions.Checked;
EnableNormals = chkBoxEnableNormals.Checked;
EnableUV0 = chkBoxEnableUVs.Checked;
EnableTangents = chkBoxEnableTans.Checked;
EnableBitangents = chkBoxEnableBitans.Checked;
EnableWeights = chkBoxEnableWeightIndices.Checked;
EnableIndices = chkBoxEnableWeightIndices.Checked;
EnableVertexColors = chkBoxEnableVertColors.Checked;
}
private void chkBoxSettings_CheckedChanged(object sender, EventArgs e)
{
FlipUVsVertical = chkBoxFlipUvsY.Checked;
Rotate90DegreesY = chkBoxRot90Y.Checked;
Rotate90DegreesNegativeY = chkBoxRotNegative90Y.Checked;
RecalculateNormals = chkBoxRecalcNormals.Checked;
SetDefaultParamData = chkBoxParamDefaults.Checked;
}
private AttribFormat SetAttribFormat(string Format)
{
switch (Format)
{
case "Format_32_32_32_Single":
return AttribFormat.Format_32_32_32_Single;
case "Format_16_16_16_16_Single":
return AttribFormat.Format_16_16_16_16_Single;
case "Format_16_16_16_16_SNorm":
return AttribFormat.Format_16_16_16_16_SNorm;
case "Format_10_10_10_2_SNorm":
return AttribFormat.Format_10_10_10_2_SNorm;
case "Format_8_8_8_8_SNorm":
return AttribFormat.Format_8_8_8_8_SNorm;
case "Format_8_8_UNorm":
return AttribFormat.Format_8_8_UNorm;
case "Format_32_32_32_32_UInt":
return AttribFormat.Format_32_32_32_32_UInt;
case "Format_16_16_16_16_UInt":
return AttribFormat.Format_16_16_16_16_UInt;
case "Format_8_8_8_8_UNorm":
return AttribFormat.Format_8_8_8_8_UNorm;
case "Format_32_32_UInt":
return AttribFormat.Format_32_32_UInt;
case "Format_16_16_UInt":
return AttribFormat.Format_16_16_UInt;
case "Format_8_8_UInt":
return AttribFormat.Format_8_8_UInt;
case "Format_32_UInt":
return AttribFormat.Format_32_UInt;
case "Format_16_UInt":
return AttribFormat.Format_16_UInt;
case "Format_8_UInt":
return AttribFormat.Format_8_UInt;
case "Format_8_UNorm":
return AttribFormat.Format_8_UNorm;
case "Format_32_32_32_32_Single":
return AttribFormat.Format_32_32_32_32_Single;
case "Format_16_16_16_16_UNorm":
return AttribFormat.Format_16_16_16_16_UNorm;
case "Format_32_32_Single":
return AttribFormat.Format_32_32_Single;
case "Format_16_16_Single":
return AttribFormat.Format_16_16_Single;
case "Format_16_16_UNorm":
return AttribFormat.Format_16_16_UNorm;
case "Format_16_16_SNorm":
return AttribFormat.Format_16_16_SNorm;
case "Format_8_8_SNorm":
return AttribFormat.Format_8_8_SNorm;
case "Format_8_8_8_8_UInt":
return AttribFormat.Format_8_8_8_8_UInt;
default:
throw new Exception($"{Format} not supported!");
}
}
private void button1_Click(object sender, EventArgs e)
{
//Only check path if material editing is enabled
if (!System.IO.File.Exists(ExternalMaterialPath) && textBoxMaterialPath.Visible)
{
this.DialogResult = DialogResult.None;
MessageBox.Show("Please set a path from an exported material! You can export one by right clicking a material and export!");
textBoxMaterialPath.BackColor = System.Drawing.Color.DarkRed;
}
else
this.DialogResult = DialogResult.OK;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfmat;";
if (ofd.ShowDialog() == DialogResult.OK)
{
ExternalMaterialPath = ofd.FileName;
textBoxMaterialPath.Text = System.IO.Path.GetFileName(ofd.FileName);
textBoxMaterialPath.BackColor = System.Drawing.Color.FromArgb(64,64,64);
}
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,75 +0,0 @@
namespace FirstPlugin
{
partial class BfresProperties
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this.SuspendLayout();
//
// propertyGrid1
//
this.propertyGrid1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.propertyGrid1.CategoryForeColor = System.Drawing.Color.WhiteSmoke;
this.propertyGrid1.CategorySplitterColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.propertyGrid1.CommandsActiveLinkColor = System.Drawing.Color.Red;
this.propertyGrid1.CommandsBorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50)))));
this.propertyGrid1.CommandsDisabledLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50)))));
this.propertyGrid1.CommandsForeColor = System.Drawing.Color.White;
this.propertyGrid1.DisabledItemForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid1.HelpBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.propertyGrid1.HelpBorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(45)))));
this.propertyGrid1.HelpForeColor = System.Drawing.Color.White;
this.propertyGrid1.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
this.propertyGrid1.Name = "propertyGrid1";
this.propertyGrid1.SelectedItemWithFocusForeColor = System.Drawing.Color.Silver;
this.propertyGrid1.Size = new System.Drawing.Size(443, 370);
this.propertyGrid1.TabIndex = 0;
this.propertyGrid1.ToolbarVisible = false;
this.propertyGrid1.ViewBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
this.propertyGrid1.ViewBorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.propertyGrid1.ViewForeColor = System.Drawing.Color.White;
//
// BfresProperties
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.propertyGrid1);
this.Name = "BfresProperties";
this.Size = new System.Drawing.Size(443, 370);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.PropertyGrid propertyGrid1;
}
}

View File

@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Switch_Toolbox.Library;
using Syroot.NintenTools.NSW.Bfres;
using System.Windows.Forms.Design;
using System.Resources;
using System.Drawing.Design;
using System.Collections.Specialized;
using System.Reflection;
namespace FirstPlugin
{
public partial class BfresProperties : UserControl
{
public BfresProperties()
{
InitializeComponent();
}
public void LoadProperty(object type)
{
propertyGrid1.SelectedObject = type;
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,113 +0,0 @@
namespace FirstPlugin
{
partial class BfresShaderOptionsEditor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxValue = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxName
//
this.textBoxName.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.textBoxName.ForeColor = System.Drawing.Color.White;
this.textBoxName.Location = new System.Drawing.Point(72, 9);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(161, 20);
this.textBoxName.TabIndex = 0;
//
// textBoxValue
//
this.textBoxValue.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.textBoxValue.ForeColor = System.Drawing.Color.White;
this.textBoxValue.Location = new System.Drawing.Point(72, 35);
this.textBoxValue.Name = "textBoxValue";
this.textBoxValue.Size = new System.Drawing.Size(161, 20);
this.textBoxValue.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 2;
this.label1.Text = "Name";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 35);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(34, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Value";
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Location = new System.Drawing.Point(182, 74);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(51, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Ok";
this.button1.UseVisualStyleBackColor = true;
//
// BfresShaderOptionsEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.ClientSize = new System.Drawing.Size(245, 102);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxValue);
this.Controls.Add(this.textBoxName);
this.ForeColor = System.Drawing.Color.White;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "BfresShaderOptionsEditor";
this.Text = "Shader Option";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
public System.Windows.Forms.TextBox textBoxName;
public System.Windows.Forms.TextBox textBoxValue;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
}
}

Some files were not shown because too many files have changed in this diff Show More