add dependency on smuggler
parent
4c41506204
commit
da52273dd0
|
@ -9,11 +9,12 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../FNA/FNA.Core.csproj" />
|
<ProjectReference Include="../FNA/FNA.Core.csproj" />
|
||||||
|
<ProjectReference Include="../Smuggler/Smuggler.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Effects\FXB\PBREffect.fxb">
|
<EmbeddedResource Include="Effects\FXB\PBREffect.fxb">
|
||||||
<LogicalName>Smuggler.Resources.PBREffect.fxb</LogicalName>
|
<LogicalName>Kav.Resources.PBREffect.fxb</LogicalName>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace Kav
|
||||||
|
{
|
||||||
|
public static class ModelLoader
|
||||||
|
{
|
||||||
|
public static Kav.Model Load(GraphicsDevice graphicsDevice, Smuggler.ModelData modelData)
|
||||||
|
{
|
||||||
|
var meshes = new List<Kav.Mesh>();
|
||||||
|
|
||||||
|
foreach (var meshData in modelData.Meshes)
|
||||||
|
{
|
||||||
|
var meshParts = new List<Kav.MeshPart>();
|
||||||
|
|
||||||
|
foreach (var meshPartData in meshData.MeshParts)
|
||||||
|
{
|
||||||
|
var effect = new Kav.PBREffect(
|
||||||
|
graphicsDevice
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Albedo = meshPartData.Albedo,
|
||||||
|
Metallic = meshPartData.Metallic,
|
||||||
|
Roughness = meshPartData.Roughness,
|
||||||
|
|
||||||
|
AlbedoTexture = meshPartData.AlbedoTexture,
|
||||||
|
NormalTexture = meshPartData.NormalTexture,
|
||||||
|
MetallicRoughnessTexture = meshPartData.MetallicRoughnessTexture
|
||||||
|
};
|
||||||
|
|
||||||
|
var triangles = new Kav.Triangle[meshPartData.Triangles.Length];
|
||||||
|
for (int i = 0; i < meshPartData.Triangles.Length; i++)
|
||||||
|
{
|
||||||
|
var smugglerTriangle = meshPartData.Triangles[i];
|
||||||
|
|
||||||
|
triangles[i] = new Kav.Triangle(
|
||||||
|
smugglerTriangle.A,
|
||||||
|
smugglerTriangle.B,
|
||||||
|
smugglerTriangle.C
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
meshParts.Add(new Kav.MeshPart(
|
||||||
|
meshPartData.VertexBuffer,
|
||||||
|
meshPartData.IndexBuffer,
|
||||||
|
meshPartData.Positions,
|
||||||
|
triangles,
|
||||||
|
effect
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
meshes.Add(new Kav.Mesh(meshParts.ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Kav.Model(meshes.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ namespace Kav
|
||||||
private static byte[] GetResource(string name)
|
private static byte[] GetResource(string name)
|
||||||
{
|
{
|
||||||
Stream stream = typeof(Resources).Assembly.GetManifestResourceStream(
|
Stream stream = typeof(Resources).Assembly.GetManifestResourceStream(
|
||||||
"Smuggler.Resources." + name + ".fxb"
|
"Kav.Resources." + name + ".fxb"
|
||||||
);
|
);
|
||||||
using (MemoryStream ms = new MemoryStream())
|
using (MemoryStream ms = new MemoryStream())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue