TriangleMeshData<T>
Models & Types · AiDotNet.Geometry.Data
Represents a triangle mesh with vertex and face attributes.
How It Works
For Beginners: A triangle mesh is a surface defined by vertices (points in 3D space) and faces (triangles that connect three vertices). Meshes are a common way to represent 3D objects in graphics and AI.
Constructors
| Constructor | Summary |
|---|---|
TriangleMeshData(Tensor<T> vertices, Tensor<int> faces, Tensor<T> vertexNormals, Tensor<T> vertexColors, Tensor<T> vertexUVs, Tensor<T> faceNormals, bool validateIndices) |
Initializes a new instance of the TriangleMeshData class. |
Properties
| Property | Summary |
|---|---|
Dictionary<string, object> Metadata { get; set; } |
Optional metadata associated with the mesh (units, source, labels, etc.). |
Tensor<T> FaceNormals { get; set; } |
Optional per-face normals of shape [numFaces, 3]. |
Tensor<T> VertexColors { get; } |
Optional per-vertex colors of shape [numVertices, 3] or [numVertices, 4]. |
Tensor<T> VertexNormals { get; set; } |
Optional per-vertex normals of shape [numVertices, 3]. |
Tensor<T> VertexUVs { get; } |
Optional per-vertex UV coordinates of shape [numVertices, 2]. |
Tensor<T> Vertices { get; } |
Vertex positions of shape [numVertices, 3]. |
Tensor<int> Faces { get; } |
Triangle indices of shape [numFaces, 3]. |
int NumFaces { get; } |
Number of faces in the mesh. |
int NumVertices { get; } |
Number of vertices in the mesh. |
Methods
| Method | Summary |
|---|---|
PointCloudData<T> ToPointCloud(bool includeColors, bool includeNormals, bool includeUVs) |
Converts the mesh to a point cloud using vertex positions and optional attributes. |
Tensor<T> ComputeFaceNormals() |
Computes and stores per-face normals. |
Tensor<T> ComputeVertexNormals() |
Computes and stores per-vertex normals by averaging adjacent face normals. |
ValueTuple<Vector<T>, Vector<T>> ComputeBounds() |
Computes the axis-aligned bounding box for the mesh. |