[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>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BevelConverter</RootNamespace>
|
||||
<AssemblyName>BevelConverter</AssemblyName>
|
||||
<RootNamespace>Bevels</RootNamespace>
|
||||
<AssemblyName>Bevels</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
|
|
@ -33,9 +33,6 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="LZ4">
|
||||
<HintPath>Packages\LZ4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RobloxFileFormat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Packages\RobloxFileFormat.dll</HintPath>
|
||||
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.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
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -8,7 +8,7 @@ using System.Text.RegularExpressions;
|
|||
|
||||
using RobloxFiles.DataTypes;
|
||||
|
||||
namespace BevelConverter
|
||||
namespace BevelGenerator
|
||||
{
|
||||
public class Mesh
|
||||
{
|
||||
|
|
@ -32,13 +32,15 @@ namespace BevelConverter
|
|||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
private static void CheckDefaultLODs(Mesh mesh)
|
||||
private static Mesh CheckLOD(Mesh mesh)
|
||||
{
|
||||
if (mesh.NumLODs == 0)
|
||||
{
|
||||
mesh.NumLODs = 2;
|
||||
mesh.LODs = new List<int> { 0, mesh.NumFaces };
|
||||
}
|
||||
|
||||
return 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)
|
||||
|
|
@ -125,7 +127,7 @@ namespace BevelConverter
|
|||
|
||||
for (int i = 0; i < mesh.NumVerts; i++)
|
||||
{
|
||||
Vertex vert = new Vertex()
|
||||
var vert = new Vertex()
|
||||
{
|
||||
Position = ReadVector3(reader),
|
||||
Normal = ReadVector3(reader),
|
||||
|
|
@ -134,12 +136,9 @@ namespace BevelConverter
|
|||
|
||||
if (vertSize > 36)
|
||||
{
|
||||
byte r = reader.ReadByte(),
|
||||
g = reader.ReadByte(),
|
||||
b = reader.ReadByte(),
|
||||
a = reader.ReadByte();
|
||||
int rgba = reader.ReadInt32();
|
||||
int argb = (rgba << 24 | rgba >> 8);
|
||||
|
||||
int argb = (a << 24 | r << 16 | g << 8 | b);
|
||||
vert.Color = Color.FromArgb(argb);
|
||||
vert.HasColor = true;
|
||||
}
|
||||
|
|
@ -165,13 +164,11 @@ namespace BevelConverter
|
|||
mesh.LODs.Add(lod);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckDefaultLODs(mesh);
|
||||
}
|
||||
|
||||
CheckLOD(mesh);
|
||||
}
|
||||
|
||||
public void AddLod(Mesh lodMesh)
|
||||
public void AddLOD(Mesh lodMesh)
|
||||
{
|
||||
Verts.AddRange(lodMesh.Verts);
|
||||
|
||||
|
|
@ -232,11 +229,11 @@ namespace BevelConverter
|
|||
|
||||
if (vertex.HasColor)
|
||||
{
|
||||
Color color = vertex.Color;
|
||||
writer.Write(color.R);
|
||||
writer.Write(color.G);
|
||||
writer.Write(color.B);
|
||||
writer.Write(color.A);
|
||||
var color = vertex.Color;
|
||||
int argb = color.ToArgb();
|
||||
|
||||
int rgba = (argb << 8 | argb >> 24);
|
||||
writer.Write(rgba);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -293,13 +290,14 @@ namespace BevelConverter
|
|||
|
||||
if (cmd == "v" || cmd == "vn")
|
||||
{
|
||||
float x = float.Parse(buffer[1]),
|
||||
y = float.Parse(buffer[2]),
|
||||
z = float.Parse(buffer[3]);
|
||||
|
||||
Vector3 value = new Vector3(x, y, z);
|
||||
float[] input = buffer
|
||||
.Skip(1)
|
||||
.Select(float.Parse)
|
||||
.ToArray();
|
||||
|
||||
var value = new Vector3(input);
|
||||
var target = (cmd == "v" ? posTable : normTable);
|
||||
|
||||
target.Add(value);
|
||||
}
|
||||
else if (cmd == "f")
|
||||
|
|
@ -340,8 +338,7 @@ namespace BevelConverter
|
|||
}
|
||||
}
|
||||
|
||||
CheckDefaultLODs(mesh);
|
||||
return mesh;
|
||||
return CheckLOD(mesh);
|
||||
}
|
||||
|
||||
public static Mesh FromBuffer(byte[] data)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Drawing;
|
||||
using RobloxFiles.DataTypes;
|
||||
|
||||
namespace BevelConverter
|
||||
namespace BevelGenerator
|
||||
{
|
||||
public class Vertex
|
||||
{
|
||||
|
|
@ -7,12 +7,12 @@ using System.Text;
|
|||
using System.Windows.Forms;
|
||||
|
||||
using RobloxFiles;
|
||||
using RobloxFiles.Enums;
|
||||
using RobloxFiles.DataTypes;
|
||||
using RobloxFiles.XmlFormat;
|
||||
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace BevelConverter
|
||||
namespace BevelGenerator
|
||||
{
|
||||
class Program
|
||||
{
|
||||
|
|
@ -186,37 +186,45 @@ namespace BevelConverter
|
|||
static void ProcessFileArg(string filePath)
|
||||
{
|
||||
RobloxFile file = RobloxFile.Open(filePath);
|
||||
Instance exportBin = file.FindFirstChild("ExportBin");
|
||||
var exportBin = file.FindFirstChild<Folder>("ExportBin");
|
||||
|
||||
if (exportBin != null)
|
||||
exportBin.Name = "BevelCache";
|
||||
else
|
||||
return;
|
||||
|
||||
Instance[] unions = exportBin.GetChildren()
|
||||
.Where((child) => child.ClassName == "UnionOperation")
|
||||
.OrderBy(child => child.Name)
|
||||
.ToArray();
|
||||
|
||||
var unions = exportBin.GetChildrenOfType<UnionOperation>();
|
||||
|
||||
for (int i = 0; i < unions.Length; i++)
|
||||
{
|
||||
Instance union = unions[i];
|
||||
UnionOperation union = unions[i];
|
||||
string name = union.Name;
|
||||
|
||||
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);
|
||||
|
||||
if (meshId == null)
|
||||
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))
|
||||
|
|
@ -5,11 +5,11 @@ 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("BevelConverter")]
|
||||
[assembly: AssemblyTitle("BevelGenerator")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BevelConverter")]
|
||||
[assembly: AssemblyProduct("BevelGenerator")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace BevelConverter.Properties {
|
||||
namespace BevelGenerator.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ namespace BevelConverter.Properties {
|
|||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
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;
|
||||
}
|
||||
return resourceMan;
|
||||
Loading…
Reference in New Issue