Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,977 changes: 9,977 additions & 0 deletions External/ColladaSharp/ColladaSharp.cs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions External/ColladaSharp/ColladaSharp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion Rime/RimeRenderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using RimeLib.Content.Mounting;
using RimeLib.Frostbite;
using RimeLib.IO.Conversion;
using RimeLib.Mesh.Frostbite;
using RimeLib.Mesh.Frostbite2_0.Frostbite;
using RimeLib.Shader.Frostbite2_0.Frostbite;
using RimeLib.Texture;
using RimeLib.Texture.DDS;
Expand Down
8 changes: 7 additions & 1 deletion RimeLib.Cmd/Commands/Base/MountGameCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ public override bool Execute(ref ExecutionContext p_Context, TextWriter p_Writer
p_Writer.WriteLine($"Failed to load supporting texture assembly for engine '{Engine}'. This means that the engine is not supported or that you are missing required files.");
return false;
}


if (!AssemblyUtils.LoadSupportAssembly(AssemblyType.Mesh, Engine))
{
p_Writer.WriteLine($"Failed to load supporting mesh assembly for engine '{Engine}'. This means that the engine is not supported or that you are missing required files.");
return false;
}

if (!AssemblyUtils.LoadSupportAssembly(AssemblyType.Serialization, Engine))
{
p_Writer.WriteLine($"Failed to load supporting serialization assembly for engine '{Engine}'. This means that the engine is not supported or that you are missing required files.");
Expand Down
49 changes: 49 additions & 0 deletions RimeLib.Cmd/Commands/Game/DumpMeshCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using RimeLib.Cmd.Attributes;
using RimeLib.Cmd.Contexts;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RimeLib.Cmd.Commands.Game
{
[CommandDescription("Converts and dumps the specified mesh resource file.")]
public class DumpMeshCommand : Command
{
[CommandArgument(Description = "The name of the mesh resource.")]
public string? Name { get; set; }

[CommandArgument(Description = "The destination file name where the mesh file will be saved.")]
public FileInfo? Destination { get; set; }

public enum ExportType
{
Text,
Obj,
BlenderScript,
Gltf
}

[CommandArgument(Description = "The exporting type.")]
public ExportType DestinationType { get; set; }

public override bool Execute(ref ExecutionContext p_Context, TextWriter p_Writer)
{
try
{
(p_Context as GameContext)?.DumpMesh(Name!, Destination!, DestinationType);
p_Writer.WriteLine("Mesh successfully converted and dumped.");
return true;
}
catch (Exception s_Exception)
{
p_Writer.WriteLine("Failed to convert and dump mesh.");
p_Writer.Write(s_Exception.Message);
}

return false;
}
}
}
27 changes: 27 additions & 0 deletions RimeLib.Cmd/Contexts/GameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using RimeLib.IO;
using RimeLib.Serialization;
using RimeLib.Texture;
using RimeLib.Mesh;

namespace RimeLib.Cmd.Contexts
{
Expand Down Expand Up @@ -43,6 +44,7 @@ public GameContext(BaseContext p_Parent, int p_Id, IEngineMounter p_Mounter)
RegisterCommand<DumpPartitionCommand>();
RegisterCommand<DumpPartitionJsonCommand>();
RegisterCommand<DumpTextureCommand>();
RegisterCommand<DumpMeshCommand>();
}

public override string GetShortDescription()
Expand Down Expand Up @@ -148,6 +150,31 @@ internal void DumpTexture(string p_Name, FileInfo p_Destination)
s_Converter.ConvertToDDS(s_Resource.FirstVariant!, m_Mounter, s_Writer);
}

internal void DumpMesh(string p_Name, FileInfo p_Destination, DumpMeshCommand.ExportType p_ExportType)
{
var s_ShortName = p_Name.Split('/').Last();

if (!m_Mounter.TryGetResource(p_Name, out var s_Resource))
throw new Exception($"Could not find resource with name '{p_Name}'");

var s_Converter = EngineInterfaceRegistry.Create<IMeshConverter>(m_Mounter.GetEngineType());

using var s_FileStream = File.Create(p_Destination.FullName);
using var s_Writer = new RimeWriter(s_FileStream);

switch (p_ExportType)
{
case DumpMeshCommand.ExportType.Obj:
s_Converter.ConvertToObj(s_Resource.FirstVariant, m_Mounter, s_Writer);
break;
case DumpMeshCommand.ExportType.Gltf:
s_Converter.ConvertToGltf(s_Resource.FirstVariant, m_Mounter, s_Writer);
break;
default:
throw new Exception("Invalid export type.");
}
}

internal IEnumerable<GUID> GetBundleChunks(string p_Bundle)
{
return m_Mounter.GetChunksInBundle(p_Bundle);
Expand Down
1 change: 1 addition & 0 deletions RimeLib.Cmd/RimeLib.Cmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<ItemGroup>
<ProjectReference Include="..\RimeLib.Content\RimeLib.Content.csproj" />
<ProjectReference Include="..\RimeLib.Mesh\RimeLib.Mesh.csproj" />
<ProjectReference Include="..\RimeLib.Serialization\RimeLib.Serialization.csproj" />
<ProjectReference Include="..\RimeLib.Texture\RimeLib.Texture.csproj" />
<ProjectReference Include="..\RimeLibLite\RimeLibLite.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions RimeLib.Enlighten.Frostbite2_0/EnlightenDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public void Deserialize(RimeReader p_Reader)
SystemNames[i] = p_Reader.ReadNullTerminatedString();

TerrainLightMapCount = p_Reader.ReadUInt32();
TerrainLightMaps = new EnlightenTerrainLightmap[TerrainLightMapCount];
TerrainLightMaps = new List<EnlightenTerrainLightmap>((int)TerrainLightMapCount);
for (var i = 0; i < TerrainLightMapCount; i++)
TerrainLightMaps[i] = new EnlightenTerrainLightmap(p_Reader);

LightMapInstanceCount = p_Reader.ReadUInt32();
LightMapInstances = new LightMapInstance[LightMapInstanceCount];
LightMapInstances = new List<LightMapInstance>((int)LightMapInstanceCount);
for (var i = 0; i < LightMapInstanceCount; i++)
LightMapInstances[i] = new LightMapInstance(p_Reader);

Expand Down
3 changes: 2 additions & 1 deletion RimeLib.Enlighten.Frostbite2_0/EnlightenMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
using System.IO;
using fb;
using RimeLib.Frostbite;
using RimeLib.Frostbite.Core;
using RimeLib.IO;

namespace RimeLib.Enlighten.Frostbite2_0;

public class EnlightenMaterial : IFbSerializable
{
public Vec3 Color { get; set; } = new Vec3();
public GUID Guid { get; set; }
public GUID Guid { get; set; } = GUID.Empty;
public ulong ShaderId { get; set; }
public bool Emissive { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion RimeLib.Enlighten.Frostbite2_0/EnlightenProbeSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class EnlightenProbeSet : IFbSerializable
public LinearTransform InverseTransform { get; set; } = new LinearTransform();
public AxisAlignedBox BoundingBox { get; set; } = new AxisAlignedBox();
public float BlendDistance { get; set; }
public uint[] Dim { get; set; } = new Dim[3];
public uint[] Dim { get; set; } = new uint[3];
public uint Priority { get; set; }
public uint ProbeCount { get; set; }
public uint GlobalOffset { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion RimeLib.Enlighten.Frostbite2_0/EnlightenShaderDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public bool Serialize([NotNullWhen(true)] out byte[]? p_Data)
public void Deserialize(RimeReader p_Reader)
{
MaterialCount = p_Reader.ReadUInt32();
Materials = new EnlightenMaterial[MaterialCount];
Materials = new List<EnlightenMaterial>((int)MaterialCount);
for (var i = 0; i < MaterialCount; i++)
Materials[i] = new EnlightenMaterial(p_Reader);
}
Expand Down
3 changes: 2 additions & 1 deletion RimeLib.Enlighten.Frostbite2_0/LightMapInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
using System.IO;
using fb;
using RimeLib.Frostbite;
using RimeLib.Frostbite.Core;
using RimeLib.IO;

namespace RimeLib.Enlighten.Frostbite2_0;

public class LightMapInstance : IFbSerializable
{
public GUID Guid { get; set; }
public GUID Guid { get; set; } = GUID.Empty;
public LinearTransform Transform { get; set; } = new LinearTransform();
public Vec4 UVTransform { get; set; } = new Vec4();
public Vec2 UVTranslation { get; set; } = new Vec2();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>default</LangVersion>
<Nullable>enable</Nullable>
<OutputPath>$(SolutionDir)\bin\$(Configuration)</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion RimeLib.Enlighten/RimeLib.Enlighten.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>default</LangVersion>
<Nullable>enable</Nullable>
<OutputPath>$(SolutionDir)\bin\$(Configuration)</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using fb;
using RimeLib.Frostbite;
using RimeLib.Frostbite.Core;
using RimeLib.IO;

namespace RimeLib.Mesh.Frostbite
namespace RimeLib.Mesh.Frostbite2_0.Frostbite
{
/// <summary>
/// Venice (Battlefield 3) Mesh layout
/// </summary>
public class MeshLayout : IFbSerializable
public class MeshLayout : Mesh.Frostbite.MeshLayout
{
/// <summary>
/// Flags for the mesh layout
Expand Down Expand Up @@ -167,7 +166,7 @@ public MeshLayout(RimeReader p_Reader)
/// Writes the mesh layout to an opened writer
/// </summary>
/// <param name="p_Writer">Writer opened to the position of the mesh layout</param>
public bool Serialize(RimeWriter p_Writer)
public override bool Serialize(RimeWriter p_Writer)
{
p_Writer.Write((uint)Type);

Expand Down Expand Up @@ -197,14 +196,14 @@ public bool Serialize(RimeWriter p_Writer)
return true;
}

public bool Serialize([NotNullWhen(true)] out byte[]? p_Data)
public override bool Serialize([NotNullWhen(true)] out byte[]? p_Data)
{
p_Data = null;
throw new NotImplementedException();
}

/// <inheritdoc />
public void Deserialize(RimeReader p_Reader)
public override void Deserialize(RimeReader p_Reader)
{
Type = (MeshType)p_Reader.ReadUInt32();
//m_subsetCount = p_Reader.ReadUInt32();
Expand Down Expand Up @@ -235,7 +234,7 @@ public void Deserialize(RimeReader p_Reader)
}

/// <inheritdoc />
public void Deserialize(byte[] p_Data)
public override void Deserialize(byte[] p_Data)
{
Deserialize(new RimeReader(new MemoryStream(p_Data)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using fb;
using RimeLib.Frostbite;
using RimeLib.Frostbite.Core;
using RimeLib.IO;
using RimeLib.Mesh.Frostbite;

namespace RimeLib.Mesh.Frostbite
namespace RimeLib.Mesh.Frostbite2_0.Frostbite
{
/// <summary>
/// Implementation for fb::MeshSetLayout
/// </summary>
public class MeshSetLayout : IFbSerializable
public class MeshSetLayout : Mesh.Frostbite.MeshSetLayout
{
/// <summary>
/// Mesh type
Expand Down Expand Up @@ -84,7 +83,7 @@ public MeshSetLayout(RimeReader p_Reader)
/// Writes a MeshSetLayout to an opened writer
/// </summary>
/// <param name="p_Writer">Writer opened to the position of a MeshSetLayout</param>
public bool Serialize(RimeWriter p_Writer)
public override bool Serialize(RimeWriter p_Writer)
{
p_Writer.Write((uint)MeshType);
p_Writer.Write((uint)Flags);
Expand Down Expand Up @@ -113,13 +112,13 @@ public bool Serialize(RimeWriter p_Writer)
return true;
}

public bool Serialize([NotNullWhen(true)] out byte[]? p_Data)
public override bool Serialize([NotNullWhen(true)] out byte[]? p_Data)
{
p_Data = null;
throw new System.NotImplementedException();
}

public void Deserialize(RimeReader p_Reader)
public override void Deserialize(RimeReader p_Reader)
{
MeshType = (MeshType)p_Reader.ReadUInt32();
Flags = (MeshLayoutFlags)p_Reader.ReadUInt32();
Expand Down Expand Up @@ -158,7 +157,7 @@ public void Deserialize(RimeReader p_Reader)
Padding = p_Reader.ReadUInt32();
}

public void Deserialize(byte[] p_Data)
public override void Deserialize(byte[] p_Data)
{
Deserialize(new RimeReader(new MemoryStream(p_Data)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
using RimeLib.Frostbite;
using RimeLib.Frostbite.Core;
using RimeLib.IO;
using RimeLib.Mesh.Frostbite;

namespace RimeLib.Mesh.Frostbite
namespace RimeLib.Mesh.Frostbite2_0.Frostbite
{
/// <summary>
/// Implementation of fb::MeshSubset
/// Sizeof MeshSubset = 148 or 0x94
/// </summary>
public class MeshSubset : IFbSerializable
public class MeshSubset : Mesh.Frostbite.MeshSubset
{
/// <summary>
/// Geometry declarations
Expand Down Expand Up @@ -103,7 +104,7 @@ public MeshSubset(RimeReader p_Reader)
/// Writes a meshsubset to an opened writer
/// </summary>
/// <param name="p_Writer">Writer opened to the position of a MeshSubset</param>
public bool Serialize(RimeWriter p_Writer)
public override bool Serialize(RimeWriter p_Writer)
{
p_Writer.Write(GeometryDeclarations); // 0
p_Writer.Write(MaterialName.BaseAddress);
Expand All @@ -127,13 +128,13 @@ public bool Serialize(RimeWriter p_Writer)
return true;
}

public bool Serialize([NotNullWhen(true)] out byte[]? p_Data)
public override bool Serialize([NotNullWhen(true)] out byte[]? p_Data)
{
p_Data = null;
throw new System.NotImplementedException();
}

public void Deserialize(RimeReader p_Reader)
public override void Deserialize(RimeReader p_Reader)
{
GeometryDeclarations = p_Reader.ReadUInt64();
MaterialName = new RelocPtr<string>(p_Reader);
Expand All @@ -153,7 +154,7 @@ public void Deserialize(RimeReader p_Reader)
TexCoordRatios.Add(p_Reader.ReadSingle());
}

public void Deserialize(byte[] p_Data)
public override void Deserialize(byte[] p_Data)
{
Deserialize(new RimeReader(new MemoryStream(p_Data)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace RimeLib.Mesh.Frostbite.Fb2
namespace RimeLib.Mesh.Frostbite2_0.Frostbite
{
[Flags]
public enum MeshSubsetCategoryFlags
Expand Down
Loading