Add probe lighting object to muunt editor

This commit is contained in:
KillzXGaming 2019-04-09 19:43:24 -04:00
parent 1841c00878
commit 6414744c28
19 changed files with 249 additions and 4 deletions

Binary file not shown.

View file

@ -54,8 +54,8 @@ namespace FirstPlugin
}
}
aampv1.AampFile aampFileV1;
aampv2.AampFile aampFileV2;
public aampv1.AampFile aampFileV1;
public aampv2.AampFile aampFileV2;
AampV1Editor aampEditorV1;
AampV2Editor aampEditorV2;

View file

@ -297,6 +297,7 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
public List<BFRES> BfresObjects = new List<BFRES>();
public List<KCL> KclObjects = new List<KCL>();
public List<AAMP> ParameterArchives = new List<AAMP>();
public void AddRenderableKcl(string FilePath)
{
@ -319,5 +320,16 @@ namespace FirstPlugin.Turbo.CourseMuuntStructs
if (bfres != null)
BfresObjects.Add(bfres);
}
public void AddParameterArchive(string FilePath)
{
if (!System.IO.File.Exists(FilePath))
return;
AAMP aamp = (AAMP)Switch_Toolbox.Library.IO.STFileLoader.OpenFileFormat(FilePath);
if (aamp != null)
ParameterArchives.Add(aamp);
}
}
}

View file

@ -10,6 +10,9 @@ using FirstPlugin.Turbo.CourseMuuntStructs;
using GL_EditorFramework.EditorDrawables;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using aampv1 = AampV1Library;
using aampv2 = AampV2Library;
using Switch_Toolbox.Library.Rendering;
namespace FirstPlugin.Forms
{
@ -58,14 +61,35 @@ namespace FirstPlugin.Forms
string CourseFolder = System.IO.Path.GetDirectoryName(FilePath);
scene = new CourseMuuntScene(by);
//Add collsion (switch)
if (File.Exists($"{CourseFolder}/course_kcl.szs"))
scene.AddRenderableKcl($"{CourseFolder}/course_kcl.szs");
//Add collsion (wii u)
if (File.Exists($"{CourseFolder}/course.kcl"))
scene.AddRenderableKcl($"{CourseFolder}/course.kcl");
//Add probe lighting config (wii u)
if (File.Exists($"{CourseFolder}/course.bglpbd"))
scene.AddParameterArchive($"{CourseFolder}/course.bglpbd");
//Add probe lighting config (switch)
if (File.Exists($"{CourseFolder}/course_bglpbd.szs"))
scene.AddParameterArchive($"{CourseFolder}/course_bglpbd.szs");
//Add course model
if (File.Exists($"{CourseFolder}/course_model.szs"))
{
scene.AddRenderableBfres($"{CourseFolder}/course_model.szs");
foreach (AAMP aamp in scene.ParameterArchives)
{
if (aamp.aampFileV1 != null)
LoadParameters(aamp.aampFileV1);
else if (aamp.aampFileV2 != null)
LoadParameters(aamp.aampFileV2);
else
throw new Exception("Failed to load parameter file " + aamp.FileName);
}
viewport.AddDrawable(new GL_EditorFramework.EditorDrawables.SingleObject(new OpenTK.Vector3(0)));
@ -125,6 +149,126 @@ namespace FirstPlugin.Forms
IsLoaded = true;
}
ProbeLighting probeLightingConfig;
private void LoadParameters(aampv1.AampFile aamp)
{
if (aamp.EffectType == "Probe Data")
{
probeLightingConfig = new ProbeLighting();
viewport.AddDrawable(probeLightingConfig);
treeView1.Nodes.Add(new ProbeLightingWrapper(probeLightingConfig));
uint index = 0;
foreach (var val in aamp.RootNode.childParams)
{
var entry = new ProbeLighting.Entry();
entry.Index = index;
probeLightingConfig.Entries.Add(entry);
foreach (var param in val.paramObjects)
{
switch (param.HashString)
{
case "param_obj":
foreach (var data in param.paramEntries) {
if (data.HashString == "index") entry.Index = (uint)data.Value;
if (data.HashString == "type") entry.Type = (uint)data.Value;
}
break;
case "grid":
entry.Grid = LoadGridData(param.paramEntries);
break;
case "sh_index_buffer":
LoadIndexBuffer(param.paramEntries, entry);
break;
case "sh_data_buffer":
LoadDataBuffer(param.paramEntries, entry);
break;
}
}
}
foreach (var entry in probeLightingConfig.Entries)
{
Console.WriteLine(entry.Name);
Console.WriteLine($"IndexType {entry.IndexType}");
Console.WriteLine($"DataType {entry.DataType}");
Console.WriteLine($"MaxIndexNum {entry.MaxIndexNum}");
Console.WriteLine($"UsedIndexNum {entry.UsedIndexNum}");
Console.WriteLine($"MaxShDataNum {entry.MaxShDataNum}");
Console.WriteLine($"UsedShDataNum {entry.UsedShDataNum}");
Console.WriteLine($"AABB_Max_Position {entry.Grid.AABB_Max_Position}");
Console.WriteLine($"AABB_Min_Position {entry.Grid.AABB_Min_Position}");
Console.WriteLine($"Voxel_Step_Position {entry.Grid.Voxel_Step_Position}");
Console.WriteLine($"DataBuffer {entry.DataBuffer.Length}");
Console.WriteLine($"IndexBuffer {entry.IndexBuffer.Length}");
}
}
}
private void LoadDataBuffer(aampv1.ParamEntry[] paramEntries, ProbeLighting.Entry probeEntry)
{
foreach (var entry in paramEntries)
{
if (entry.HashString == "type")
probeEntry.DataType = (uint)entry.Value;
if (entry.HashString == "used_data_num")
probeEntry.UsedShDataNum = (uint)entry.Value;
if (entry.HashString == "max_sh_data_num")
probeEntry.MaxShDataNum = (uint)entry.Value;
if (entry.HashString == "data_buffer")
{
if (entry.ParamType == aampv1.ParamType.BufferFloat)
probeEntry.DataBuffer = (float[])entry.Value;
}
}
}
private void LoadIndexBuffer(aampv1.ParamEntry[] paramEntries, ProbeLighting.Entry probeEntry)
{
foreach (var entry in paramEntries)
{
if (entry.HashString == "type")
probeEntry.IndexType = (uint)entry.Value;
if (entry.HashString == "used_index_num")
probeEntry.UsedIndexNum = (uint)entry.Value;
if (entry.HashString == "max_index_num")
probeEntry.MaxIndexNum = (uint)entry.Value;
if (entry.HashString == "index_buffer")
{
if (entry.ParamType == aampv1.ParamType.BufferUint)
probeEntry.IndexBuffer = (uint[])entry.Value;
}
}
}
private ProbeLighting.Grid LoadGridData(aampv1.ParamEntry[] paramEntries)
{
ProbeLighting.Grid grid = new ProbeLighting.Grid();
foreach (var entry in paramEntries)
{
if (entry.HashString == "aabb_min_pos")
grid.AABB_Max_Position = Utils.ToVec3((Syroot.Maths.Vector3F)entry.Value);
if (entry.HashString == "aabb_max_pos")
grid.AABB_Min_Position = Utils.ToVec3((Syroot.Maths.Vector3F)entry.Value);
if (entry.HashString == "voxel_step_pos")
grid.Voxel_Step_Position = Utils.ToVec3((Syroot.Maths.Vector3F)entry.Value);
}
return grid;
}
private void LoadParameters(aampv2.AampFile aamp)
{
}
private void AddPathDrawable(string Name, IEnumerable<BasePathPoint> Groups, Color color, bool CanConnect = true)
{

View file

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Switch_Toolbox.Library;
using Switch_Toolbox.Library.Rendering;
namespace FirstPlugin.Turbo.CourseMuuntStructs
{
public class ProbeLightingWrapper : TreeNodeCustom
{
ProbeLighting ProbeLightingConfig;
public ProbeLightingWrapper(ProbeLighting config) {
Text = "course.bglpbd (Probe Lighting)";
ProbeLightingConfig = config;
}
}
}

View file

@ -362,6 +362,7 @@
<Compile Include="GUI\Byaml\CourseMuunt\Wrappers\PathCollectionNode.cs" />
<Compile Include="GUI\Byaml\CourseMuunt\Wrappers\PathGroupNode.cs" />
<Compile Include="GUI\Byaml\CourseMuunt\Wrappers\PathPointNode.cs" />
<Compile Include="GUI\Byaml\CourseMuunt\Wrappers\ProbeLightingWrapper.cs" />
<Compile Include="MarioCostumeEditor.cs" />
<Compile Include="GUI\AAMP\AampV1Editor.cs">
<SubType>UserControl</SubType>

View file

@ -1 +1 @@
303eb09c135d9731661be3be002bdbe8c1380569
7798e93b603f2ef483cd6e7dc6584588e301ec40

View file

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using OpenTK;
using System.Text;
using System.Threading.Tasks;
using GL_EditorFramework.GL_Core;
using GL_EditorFramework.Interfaces;
using GL_EditorFramework.EditorDrawables;
using GL_EditorFramework;
namespace Switch_Toolbox.Library.Rendering
{
public class ProbeLighting : AbstractGlDrawable
{
public List<Entry> Entries = new List<Entry>();
public class Entry
{
public string Name { get { return $"b_{Index}"; } }
public uint Index = 0;
public uint Type = 0;
public Grid Grid = new Grid();
//Index Buffer
public uint IndexType = 1;
public uint UsedIndexNum;
public uint MaxIndexNum;
public uint[] IndexBuffer = new uint[0];
//Data Buffer
public uint DataType = 0;
public uint UsedShDataNum;
public uint MaxShDataNum;
public uint PerProbeNum = 27;
public float[] DataBuffer = new float[0];
}
public class Grid
{
public Vector3 AABB_Max_Position;
public Vector3 AABB_Min_Position;
public Vector3 Voxel_Step_Position;
}
public override void Draw(GL_ControlModern control, Pass pass)
{
}
public override void Draw(GL_ControlLegacy control, Pass pass)
{
}
public override void Prepare(GL_ControlModern control)
{
}
public override void Prepare(GL_ControlLegacy control)
{
}
}
}

View file

@ -574,6 +574,7 @@
<Compile Include="Rendering\DrawableSkybox.cs" />
<Compile Include="Rendering\DrawableFloor.cs" />
<Compile Include="Rendering\DrawableXyzLines.cs" />
<Compile Include="Rendering\ProbeLighting.cs" />
<Compile Include="Rendering\RenderTools.cs" />
<Compile Include="Rendering\ScreenTriangle.cs" />
<Compile Include="Generics\STSkeleton.cs" />