Method FromTriangles
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
FromTriangles(ReadOnlySpan<Vector3>, ReadOnlySpan<int>, MeshOptions?, ReadOnlySpan<byte>)
Builds a mesh from vertices and triangle indices.
public static CollisionMesh FromTriangles(ReadOnlySpan<Vector3> vertices, ReadOnlySpan<int> indices, MeshOptions? options = null, ReadOnlySpan<byte> materialIndices = default)Parameters
verticesReadOnlySpan<Vector3>-
The vertex positions, in mesh-local space.
indicesReadOnlySpan<int>-
Three indices per triangle, wound counter-clockwise when seen from the side the surface faces.
optionsMeshOptions?-
The build options, or null for Box3D.MeshOptions.Default.
materialIndicesReadOnlySpan<byte>-
One material index per triangle, selecting into the per-triangle materials of the shape definition. Leave empty for a single material.
Returns
- CollisionMesh
-
The mesh.
Remarks
The inputs are copied, so the arrays may be reused or released as soon as this returns. Winding decides which side of a triangle is solid, so a mesh built with the wrong winding lets bodies fall through from above.
Exceptions
- ArgumentException
-
The inputs are too small, the index count is not a multiple of three, an index is out of range, or the material index count does not match the triangle count.