MeshPrimitiveType TriangleStrip

book_4_sparkGenerated
code_blocksInput

Description

The TriangleStrip field is a member of the MeshPrimitiveType enumeration in the Sandbox API. It represents a type of mesh primitive that is used to define a series of connected triangles. In a triangle strip, each new vertex after the first two creates a new triangle, sharing the previous two vertices. This is an efficient way to define a complex surface with fewer vertices compared to individual triangles.

Usage

Use MeshPrimitiveType.TriangleStrip when you want to create a mesh that consists of a series of connected triangles. This is particularly useful for rendering surfaces where the geometry is continuous, such as terrain or cloth simulations.

Example

// Example of using MeshPrimitiveType.TriangleStrip
Mesh mesh = new Mesh();
mesh.PrimitiveType = MeshPrimitiveType.TriangleStrip;

// Define vertices for the triangle strip
Vector3[] vertices = new Vector3[]
{
    new Vector3(0, 0, 0),
    new Vector3(1, 0, 0),
    new Vector3(0, 1, 0),
    new Vector3(1, 1, 0),
    new Vector3(0, 2, 0)
};

// Assign vertices to the mesh
mesh.SetVertices(vertices);

// The mesh will render as a series of triangles: (0,1,2), (1,2,3), (2,3,4)