Vertex Elements — Aspose.3D FOSS for Java
Overview
Vertex elements are typed data layers attached to a Mesh object. Each layer stores per-vertex or per-polygon-corner data such as normals, UV coordinates, vertex colours, or tangent vectors. All concrete vertex element classes extend VertexElement.
Package: com.aspose.threed
Retrieve a vertex element from a mesh with Mesh.getElement(VertexElementType). Create one with Mesh.createElement(VertexElementType).
Base Class
| Class | Description |
|---|---|
VertexElement | Abstract base for all vertex element types. Carries getMappingMode(), getReferenceMode(), and a data list. |
Concrete Element Types
| Class | Description |
|---|---|
VertexElementNormal | Stores per-vertex or per-corner normal vectors as Vector4 (w unused). |
VertexElementUV | Stores texture-coordinate pairs (Vector2) per vertex or per polygon corner. A mesh may carry multiple UV layers. |
VertexElementVertexColor | Stores per-vertex or per-corner RGBA colour data as Vector4 (r, g, b, a in 0–1 range). |
VertexElementTangent | Stores tangent vectors for normal-map shading. |
VertexElementBinormal | Stores binormal (bitangent) vectors, perpendicular to both the normal and the tangent. |
VertexElementMaterial | Stores per-face material index references. |
Supporting Enumerations
| Enumeration | Description |
|---|---|
VertexElementType | Semantic role: NORMAL, UV, VERTEX_COLOR, TANGENT, BINORMAL, and others. |
MappingMode | Controls which primitive a value maps to: CONTROL_POINT, POLYGON_VERTEX, or POLYGON. |
ReferenceMode | Controls indexing: DIRECT or INDEX_TO_DIRECT. |
Quick Example
import com.aspose.threed.Mesh;
import com.aspose.threed.VertexElementNormal;
import com.aspose.threed.VertexElementType;
import com.aspose.threed.MappingMode;
import com.aspose.threed.ReferenceMode;
import com.aspose.threed.Vector4;
Mesh mesh = new Mesh();
VertexElementNormal normals = (VertexElementNormal) mesh.createElement(VertexElementType.NORMAL);
// Default MappingMode: CONTROL_POINT; default ReferenceMode: DIRECT (set by createElement)
normals.getData().add(new Vector4(0, 1, 0, 0)); // up-facing normal