mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2026-08-15 15:07:48 +04:00
75 lines
2.0 KiB
C#
75 lines
2.0 KiB
C#
using System.Numerics;
|
|
using NResUI.Rendering.Viewport.Meshes;
|
|
|
|
namespace NResUI.Rendering.Viewport;
|
|
|
|
public sealed class ViewportPiece
|
|
{
|
|
public int Id { get; }
|
|
public string Name { get; }
|
|
public IReadOnlyList<GpuMesh> Meshes { get; }
|
|
|
|
public GpuMesh Mesh => Meshes[0];
|
|
|
|
public Matrix4x4 LocalTransform { get; set; }
|
|
|
|
public Vector3 BoundsMin { get; }
|
|
public Vector3 BoundsMax { get; }
|
|
|
|
public ViewportPieceDebugInfo? DebugInfo { get; }
|
|
|
|
public ViewportPiece(
|
|
int id,
|
|
string name,
|
|
GpuMesh mesh,
|
|
Matrix4x4 localTransform,
|
|
Vector3 boundsMin,
|
|
Vector3 boundsMax,
|
|
ViewportPieceDebugInfo? debugInfo = null)
|
|
: this(id, name, new[] { mesh }, localTransform, boundsMin, boundsMax, debugInfo)
|
|
{
|
|
}
|
|
|
|
public ViewportPiece(
|
|
int id,
|
|
string name,
|
|
IReadOnlyList<GpuMesh> meshes,
|
|
Matrix4x4 localTransform,
|
|
Vector3 boundsMin,
|
|
Vector3 boundsMax,
|
|
ViewportPieceDebugInfo? debugInfo = null)
|
|
{
|
|
if (meshes.Count == 0)
|
|
throw new ArgumentException("A viewport piece must contain at least one mesh.", nameof(meshes));
|
|
|
|
Id = id;
|
|
Name = name;
|
|
Meshes = meshes;
|
|
LocalTransform = localTransform;
|
|
BoundsMin = boundsMin;
|
|
BoundsMax = boundsMax;
|
|
DebugInfo = debugInfo;
|
|
}
|
|
|
|
public static ViewportPiece CreateUnitCube(int id, string name, GpuMesh mesh)
|
|
{
|
|
return new ViewportPiece(
|
|
id,
|
|
name,
|
|
mesh,
|
|
Matrix4x4.Identity,
|
|
new Vector3(-1.0f, -1.0f, -1.0f),
|
|
new Vector3(1.0f, 1.0f, 1.0f),
|
|
new ViewportPieceDebugInfo
|
|
{
|
|
SourceKind = "Debug primitive",
|
|
SourcePieceIndex = id,
|
|
SourceParentIndex = -1,
|
|
GeometrySlotIndex = 0,
|
|
Msh01Flags = 0,
|
|
BatchCount = 1,
|
|
TriangleCount = 12
|
|
});
|
|
}
|
|
}
|