[BevelGen] Use newer version of RobloxFileFormat
Also cleaned up a bunch of stuff.
This commit is contained in:
parent
fa6aac6af6
commit
4a02ef76c5
|
|
@ -7,8 +7,8 @@
|
||||||
<ProjectGuid>{957A7717-A3CB-41B0-A17C-0E638017E915}</ProjectGuid>
|
<ProjectGuid>{957A7717-A3CB-41B0-A17C-0E638017E915}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>BevelConverter</RootNamespace>
|
<RootNamespace>Bevels</RootNamespace>
|
||||||
<AssemblyName>BevelConverter</AssemblyName>
|
<AssemblyName>Bevels</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
|
@ -33,9 +33,6 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="LZ4">
|
|
||||||
<HintPath>Packages\LZ4.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="RobloxFileFormat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="RobloxFileFormat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>Packages\RobloxFileFormat.dll</HintPath>
|
<HintPath>Packages\RobloxFileFormat.dll</HintPath>
|
||||||
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 14
|
# Visual Studio 14
|
||||||
VisualStudioVersion = 14.0.25420.1
|
VisualStudioVersion = 14.0.25420.1
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BevelConverter", "BevelConverter.csproj", "{957A7717-A3CB-41B0-A17C-0E638017E915}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BevelGenerator", "BevelGenerator.csproj", "{957A7717-A3CB-41B0-A17C-0E638017E915}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using RobloxFiles.DataTypes;
|
using RobloxFiles.DataTypes;
|
||||||
|
|
||||||
namespace BevelConverter
|
namespace BevelGenerator
|
||||||
{
|
{
|
||||||
public class Mesh
|
public class Mesh
|
||||||
{
|
{
|
||||||
|
|
@ -32,13 +32,15 @@ namespace BevelConverter
|
||||||
return new Vector3(x, y, z);
|
return new Vector3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckDefaultLODs(Mesh mesh)
|
private static Mesh CheckLOD(Mesh mesh)
|
||||||
{
|
{
|
||||||
if (mesh.NumLODs == 0)
|
if (mesh.NumLODs == 0)
|
||||||
{
|
{
|
||||||
mesh.NumLODs = 2;
|
mesh.NumLODs = 2;
|
||||||
mesh.LODs = new List<int> { 0, mesh.NumFaces };
|
mesh.LODs = new List<int> { 0, mesh.NumFaces };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void LoadGeometry_Ascii(StringReader reader, Mesh mesh)
|
private static void LoadGeometry_Ascii(StringReader reader, Mesh mesh)
|
||||||
|
|
@ -99,7 +101,7 @@ namespace BevelConverter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckDefaultLODs(mesh);
|
CheckLOD(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void LoadGeometry_Binary(BinaryReader reader, Mesh mesh)
|
private static void LoadGeometry_Binary(BinaryReader reader, Mesh mesh)
|
||||||
|
|
@ -125,7 +127,7 @@ namespace BevelConverter
|
||||||
|
|
||||||
for (int i = 0; i < mesh.NumVerts; i++)
|
for (int i = 0; i < mesh.NumVerts; i++)
|
||||||
{
|
{
|
||||||
Vertex vert = new Vertex()
|
var vert = new Vertex()
|
||||||
{
|
{
|
||||||
Position = ReadVector3(reader),
|
Position = ReadVector3(reader),
|
||||||
Normal = ReadVector3(reader),
|
Normal = ReadVector3(reader),
|
||||||
|
|
@ -134,12 +136,9 @@ namespace BevelConverter
|
||||||
|
|
||||||
if (vertSize > 36)
|
if (vertSize > 36)
|
||||||
{
|
{
|
||||||
byte r = reader.ReadByte(),
|
int rgba = reader.ReadInt32();
|
||||||
g = reader.ReadByte(),
|
int argb = (rgba << 24 | rgba >> 8);
|
||||||
b = reader.ReadByte(),
|
|
||||||
a = reader.ReadByte();
|
|
||||||
|
|
||||||
int argb = (a << 24 | r << 16 | g << 8 | b);
|
|
||||||
vert.Color = Color.FromArgb(argb);
|
vert.Color = Color.FromArgb(argb);
|
||||||
vert.HasColor = true;
|
vert.HasColor = true;
|
||||||
}
|
}
|
||||||
|
|
@ -165,13 +164,11 @@ namespace BevelConverter
|
||||||
mesh.LODs.Add(lod);
|
mesh.LODs.Add(lod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
CheckLOD(mesh);
|
||||||
CheckDefaultLODs(mesh);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddLod(Mesh lodMesh)
|
public void AddLOD(Mesh lodMesh)
|
||||||
{
|
{
|
||||||
Verts.AddRange(lodMesh.Verts);
|
Verts.AddRange(lodMesh.Verts);
|
||||||
|
|
||||||
|
|
@ -232,11 +229,11 @@ namespace BevelConverter
|
||||||
|
|
||||||
if (vertex.HasColor)
|
if (vertex.HasColor)
|
||||||
{
|
{
|
||||||
Color color = vertex.Color;
|
var color = vertex.Color;
|
||||||
writer.Write(color.R);
|
int argb = color.ToArgb();
|
||||||
writer.Write(color.G);
|
|
||||||
writer.Write(color.B);
|
int rgba = (argb << 8 | argb >> 24);
|
||||||
writer.Write(color.A);
|
writer.Write(rgba);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -293,13 +290,14 @@ namespace BevelConverter
|
||||||
|
|
||||||
if (cmd == "v" || cmd == "vn")
|
if (cmd == "v" || cmd == "vn")
|
||||||
{
|
{
|
||||||
float x = float.Parse(buffer[1]),
|
float[] input = buffer
|
||||||
y = float.Parse(buffer[2]),
|
.Skip(1)
|
||||||
z = float.Parse(buffer[3]);
|
.Select(float.Parse)
|
||||||
|
.ToArray();
|
||||||
Vector3 value = new Vector3(x, y, z);
|
|
||||||
|
|
||||||
|
var value = new Vector3(input);
|
||||||
var target = (cmd == "v" ? posTable : normTable);
|
var target = (cmd == "v" ? posTable : normTable);
|
||||||
|
|
||||||
target.Add(value);
|
target.Add(value);
|
||||||
}
|
}
|
||||||
else if (cmd == "f")
|
else if (cmd == "f")
|
||||||
|
|
@ -340,8 +338,7 @@ namespace BevelConverter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckDefaultLODs(mesh);
|
return CheckLOD(mesh);
|
||||||
return mesh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mesh FromBuffer(byte[] data)
|
public static Mesh FromBuffer(byte[] data)
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using RobloxFiles.DataTypes;
|
using RobloxFiles.DataTypes;
|
||||||
|
|
||||||
namespace BevelConverter
|
namespace BevelGenerator
|
||||||
{
|
{
|
||||||
public class Vertex
|
public class Vertex
|
||||||
{
|
{
|
||||||
|
|
@ -7,12 +7,12 @@ using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using RobloxFiles;
|
using RobloxFiles;
|
||||||
|
using RobloxFiles.Enums;
|
||||||
using RobloxFiles.DataTypes;
|
using RobloxFiles.DataTypes;
|
||||||
using RobloxFiles.XmlFormat;
|
|
||||||
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace BevelConverter
|
namespace BevelGenerator
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
|
|
@ -186,37 +186,45 @@ namespace BevelConverter
|
||||||
static void ProcessFileArg(string filePath)
|
static void ProcessFileArg(string filePath)
|
||||||
{
|
{
|
||||||
RobloxFile file = RobloxFile.Open(filePath);
|
RobloxFile file = RobloxFile.Open(filePath);
|
||||||
Instance exportBin = file.FindFirstChild("ExportBin");
|
var exportBin = file.FindFirstChild<Folder>("ExportBin");
|
||||||
|
|
||||||
if (exportBin != null)
|
if (exportBin != null)
|
||||||
exportBin.Name = "BevelCache";
|
exportBin.Name = "BevelCache";
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Instance[] unions = exportBin.GetChildren()
|
var unions = exportBin.GetChildrenOfType<UnionOperation>();
|
||||||
.Where((child) => child.ClassName == "UnionOperation")
|
|
||||||
.OrderBy(child => child.Name)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
for (int i = 0; i < unions.Length; i++)
|
for (int i = 0; i < unions.Length; i++)
|
||||||
{
|
{
|
||||||
Instance union = unions[i];
|
UnionOperation union = unions[i];
|
||||||
string name = union.Name;
|
string name = union.Name;
|
||||||
|
|
||||||
Console.WriteLine("Working on {0}... ({1}/{2})", union.Name, i, unions.Length);
|
Console.WriteLine("Working on {0}... ({1}/{2})", union.Name, i, unions.Length);
|
||||||
union.ClassName = "MeshPart";
|
|
||||||
|
|
||||||
union.RemoveProperty("AssetId");
|
|
||||||
union.RemoveProperty("MeshData");
|
|
||||||
union.RemoveProperty("ChildData");
|
|
||||||
union.RemoveProperty("UsePartColor");
|
|
||||||
|
|
||||||
string meshId = ProcessInput(name);
|
string meshId = ProcessInput(name);
|
||||||
|
|
||||||
if (meshId == null)
|
if (meshId == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
union.SetProperty("MeshId", meshId);
|
MeshPart bevelMesh = new MeshPart()
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
MeshId = meshId,
|
||||||
|
|
||||||
|
Size = union.Size,
|
||||||
|
InitialSize = union.InitialSize,
|
||||||
|
RenderFidelity = RenderFidelity.Automatic,
|
||||||
|
|
||||||
|
PhysicsData = union.PhysicsData,
|
||||||
|
CollisionFidelity = CollisionFidelity.Box,
|
||||||
|
PhysicalConfigData = union.PhysicalConfigData,
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (string tag in union.Tags)
|
||||||
|
bevelMesh.Tags.Add(tag);
|
||||||
|
|
||||||
|
bevelMesh.Parent = exportBin;
|
||||||
|
union.Parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (FileStream export = File.OpenWrite(filePath))
|
using (FileStream export = File.OpenWrite(filePath))
|
||||||
|
|
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("BevelConverter")]
|
[assembly: AssemblyTitle("BevelGenerator")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("BevelConverter")]
|
[assembly: AssemblyProduct("BevelGenerator")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace BevelConverter.Properties {
|
namespace BevelGenerator.Properties {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace BevelConverter.Properties {
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BevelConverter.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bevels.Properties.Resources", typeof(Resources).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
Loading…
Reference in New Issue