Table of Contents

Class TriangleMesh

Namespace
Jitter2.Collision.Shapes
Assembly
Jitter2.dll

Represents a triangle mesh defined by a collection of vertices and triangle indices.

public class TriangleMesh
Inheritance
TriangleMesh
Inherited Members

Constructors

TriangleMesh(IEnumerable<JTriangle>, bool)

Creates a mesh from a "soup" of triangles. Vertices are automatically identified and deduplicated.

public TriangleMesh(IEnumerable<JTriangle> soup, bool ignoreDegenerated = false)

Parameters

soup IEnumerable<JTriangle>

The triangles used to build the mesh.

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Exceptions

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.

TriangleMesh(ReadOnlySpan<JTriangle>, bool)

Creates a mesh from a "soup" of triangles. Vertices are automatically identified and deduplicated.

public TriangleMesh(ReadOnlySpan<JTriangle> soup, bool ignoreDegenerated = false)

Parameters

soup ReadOnlySpan<JTriangle>

The triangles used to build the mesh.

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Exceptions

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.

TriangleMesh(ReadOnlySpan<JVector>, ReadOnlySpan<int>, bool)

Creates a mesh from existing vertices and indices.

public TriangleMesh(ReadOnlySpan<JVector> vertices, ReadOnlySpan<int> indices, bool ignoreDegenerated = false)

Parameters

vertices ReadOnlySpan<JVector>

The vertex buffer.

indices ReadOnlySpan<int>

The index buffer (must be a multiple of 3).

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Remarks

Vertices with exactly identical positions are canonicalized so adjacency detection also works across duplicated seam vertices in indexed meshes.

Exceptions

ArgumentException

Thrown when indices does not contain a multiple of three entries.

IndexOutOfRangeException

Thrown when an index references an element outside vertices.

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.

TriangleMesh(ReadOnlySpan<JVector>, ReadOnlySpan<ushort>, bool)

Creates a mesh from existing vertices and indices.

public TriangleMesh(ReadOnlySpan<JVector> vertices, ReadOnlySpan<ushort> indices, bool ignoreDegenerated = false)

Parameters

vertices ReadOnlySpan<JVector>

The vertex buffer.

indices ReadOnlySpan<ushort>

The index buffer (must be a multiple of 3).

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Remarks

Vertices with exactly identical positions are canonicalized so adjacency detection also works across duplicated seam vertices in indexed meshes.

Exceptions

ArgumentException

Thrown when indices does not contain a multiple of three entries.

IndexOutOfRangeException

Thrown when an index references an element outside vertices.

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.

TriangleMesh(ReadOnlySpan<JVector>, ReadOnlySpan<uint>, bool)

Creates a mesh from existing vertices and indices.

public TriangleMesh(ReadOnlySpan<JVector> vertices, ReadOnlySpan<uint> indices, bool ignoreDegenerated = false)

Parameters

vertices ReadOnlySpan<JVector>

The vertex buffer.

indices ReadOnlySpan<uint>

The index buffer (must be a multiple of 3).

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Remarks

Vertices with exactly identical positions are canonicalized so adjacency detection also works across duplicated seam vertices in indexed meshes.

Exceptions

ArgumentException

Thrown when indices does not contain a multiple of three entries.

IndexOutOfRangeException

Thrown when an index references an element outside vertices.

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.

Properties

Indices

Gets the triangle indices of the mesh.

public ReadOnlySpan<TriangleMesh.Triangle> Indices { get; }

Property Value

ReadOnlySpan<TriangleMesh.Triangle>

Vertices

Gets the vertices of the mesh.

public ReadOnlySpan<JVector> Vertices { get; }

Property Value

ReadOnlySpan<JVector>

Methods

Create<TVertex>(ReadOnlySpan<TVertex>, ReadOnlySpan<int>, bool)

Creates a mesh from custom vertices (e.g. System.Numerics.Vector3) and indices.

public static TriangleMesh Create<TVertex>(ReadOnlySpan<TVertex> vertices, ReadOnlySpan<int> indices, bool ignoreDegenerated = false) where TVertex : unmanaged

Parameters

vertices ReadOnlySpan<TVertex>

The vertex buffer.

indices ReadOnlySpan<int>

The index buffer (must be a multiple of 3).

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Returns

TriangleMesh

Type Parameters

TVertex

The unmanaged vertex type. It must have the same size as JVector.

Exceptions

ArgumentException

Thrown when TVertex does not have the same size as JVector.

ArgumentException

Thrown when indices does not contain a multiple of three entries.

IndexOutOfRangeException

Thrown when an index references an element outside vertices.

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.

Create<TVertex>(ReadOnlySpan<TVertex>, ReadOnlySpan<ushort>, bool)

Creates a mesh from custom vertices (e.g. System.Numerics.Vector3) and indices.

public static TriangleMesh Create<TVertex>(ReadOnlySpan<TVertex> vertices, ReadOnlySpan<ushort> indices, bool ignoreDegenerated = false) where TVertex : unmanaged

Parameters

vertices ReadOnlySpan<TVertex>

The vertex buffer.

indices ReadOnlySpan<ushort>

The index buffer (must be a multiple of 3).

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Returns

TriangleMesh

Type Parameters

TVertex

The unmanaged vertex type. It must have the same size as JVector.

Exceptions

ArgumentException

Thrown when TVertex does not have the same size as JVector.

ArgumentException

Thrown when indices does not contain a multiple of three entries.

IndexOutOfRangeException

Thrown when an index references an element outside vertices.

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.

Create<TVertex>(ReadOnlySpan<TVertex>, ReadOnlySpan<uint>, bool)

Creates a mesh from custom vertices (e.g. System.Numerics.Vector3) and indices.

public static TriangleMesh Create<TVertex>(ReadOnlySpan<TVertex> vertices, ReadOnlySpan<uint> indices, bool ignoreDegenerated = false) where TVertex : unmanaged

Parameters

vertices ReadOnlySpan<TVertex>

The vertex buffer.

indices ReadOnlySpan<uint>

The index buffer (must be a multiple of 3).

ignoreDegenerated bool

If true, degenerate triangles are skipped.

Returns

TriangleMesh

Type Parameters

TVertex

The unmanaged vertex type. It must have the same size as JVector.

Exceptions

ArgumentException

Thrown when TVertex does not have the same size as JVector.

ArgumentException

Thrown when indices does not contain a multiple of three entries.

IndexOutOfRangeException

Thrown when an index references an element outside vertices.

TriangleMesh.DegenerateTriangleException

Thrown when a degenerate triangle is found and ignoreDegenerated is false.