The Autodesk.Revit.DB.DirectContext3D.IndexPrimitive
class represents a set of index buffer primitives used to render geometric models in a 3D view in Revit.
public class IndexPrimitive : RenderPrimitive
The IndexPrimitive
class has the following properties:
IndexCount
: Gets the number of indices in the index buffer.Indices
: Gets the index buffer data as an array of integers.IsIndexed
: Gets a value indicating whether this instance supports indexed rendering.The IndexPrimitive
class is used as a base class for more specific index buffer primitives, such as TriangleListPrimitive
and LineStripPrimitive
. It provides a way to specify the indices that reference vertices in a vertex buffer for rendering.
Index buffers are used to optimize rendering by reducing the number of times that duplicate vertex data needs to be processed by the graphics processing unit (GPU). By using indices to reference vertices in a vertex buffer, multiple triangles or other geometric shapes can be defined using the same vertices.
The following code example demonstrates how to create and use an IndexPrimitive
object:
// Create a new index buffer primitive with four vertices and two triangles
IndexPrimitive indexPrimitive = new IndexPrimitive(4, 2);
// Set the indices for the first triangle
indexPrimitive.SetTriangleIndices(0, 0, 1, 2);
// Set the indices for the second triangle
indexPrimitive.SetTriangleIndices(1, 0, 2, 3);
// Render the primitive using the DirectContext3D object
DirectContext3D.DrawIndexedPrimitive(indexPrimitive);
In this example, an IndexPrimitive
object is created to define four vertices and two triangles. The indices for each triangle are set using the SetTriangleIndices
method, and the primitive is rendered using the DirectContext3D
object's DrawIndexedPrimitive
method.
Autodesk.Revit.DB.DirectContext3D.TriangleListPrimitive
Autodesk.Revit.DB.DirectContext3D.LineStripPrimitive
Autodesk.Revit.DB.DirectContext3D.DirectContext3D