Kav/Geometry/MeshPart.cs

60 lines
1.8 KiB
C#
Raw Normal View History

2020-08-04 09:32:02 +00:00
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Kav
{
public class MeshPart : IIndexDrawable
2020-08-04 09:32:02 +00:00
{
public IndexBuffer IndexBuffer { get; }
public VertexBuffer VertexBuffer { get; }
public Triangle[] Triangles { get; }
public Vector3[] Positions { get; }
2020-10-20 01:22:54 +00:00
public BoundingBox BoundingBox { get; }
private Texture2D albedoTexture = null;
private Texture2D normalTexture = null;
private Texture2D metallicRoughnessTexture = null;
2020-08-04 09:32:02 +00:00
public Texture2D AlbedoTexture
{
get { return DisableAlbedoMap ? null : albedoTexture; }
set { albedoTexture = value; }
}
public Texture2D NormalTexture
{
get { return DisableNormalMap ? null : normalTexture; }
set { normalTexture = value; }
}
public Texture2D MetallicRoughnessTexture
{
get { return DisableMetallicRoughnessMap ? null : metallicRoughnessTexture; }
set { metallicRoughnessTexture = value; }
}
public Vector3 Albedo { get; set; } = Vector3.One;
public float Metallic { get; set; } = 0.5f;
public float Roughness { get; set; } = 0.5f;
public bool DisableAlbedoMap { get; set; } = false;
public bool DisableNormalMap { get; set; } = false;
public bool DisableMetallicRoughnessMap { get; set; } = false;
public MeshPart(
VertexBuffer vertexBuffer,
IndexBuffer indexBuffer,
Vector3[] positions,
Triangle[] triangles
) {
2020-08-04 09:32:02 +00:00
VertexBuffer = vertexBuffer;
IndexBuffer = indexBuffer;
Positions = positions;
Triangles = triangles;
2020-10-20 01:22:54 +00:00
BoundingBox = BoundingBox.CreateFromPoints(Positions);
2020-08-04 09:32:02 +00:00
}
}
}