VertexElement — Aspose.3D FOSS for Java
Package: com.aspose.threed (aspose-3d-foss 26.1.0)
VertexElement is the abstract base class for per-vertex (or per-polygon, per-edge) data layers attached to a Mesh. Each subclass stores a specific kind of geometric attribute – normals, UV coordinates, vertex colours, or smoothing groups.
VertexElement (abstract base)
Properties
| Property | Type | Getter | Setter | Description |
|---|---|---|---|---|
vertexElementType | VertexElementType | getVertexElementType() | – | Semantic type of this element (read-only). |
mappingMode | MappingMode | getMappingMode() | setMappingMode(MappingMode) | Controls which primitive each value maps to. |
referenceMode | ReferenceMode | getReferenceMode() | setReferenceMode(ReferenceMode) | Controls how values are indexed. |
indices | List<Integer> | getIndices() | – | Index array (used when reference mode is INDEX_TO_DIRECT). |
name | String | getName() | setName(String) | Optional name of this vertex element layer. |
VertexElementNormal
Stores one normal vector per vertex or per polygon corner, depending on getMappingMode(). Data values are Vector4 instances with w unused.
import com.aspose.threed.*;
VertexElement normals = mesh.createElement(
VertexElementType.NORMAL,
MappingMode.CONTROL_POINT,
ReferenceMode.DIRECT
);Properties
| Property | Type | Getter | Description |
|---|---|---|---|
data | List<Vector4> | getData() | Normal vectors. The w component is unused (typically 0.0). |
VertexElementUV
Stores texture-coordinate pairs (Vector2) per vertex or per polygon corner. A mesh may carry multiple UV layers for different texture channels.
VertexElementUV uv = mesh.createElementUV(
TextureMapping.DIFFUSE,
MappingMode.POLYGON_VERTEX,
ReferenceMode.INDEX_TO_DIRECT
);Properties
| Property | Type | Getter | Description |
|---|---|---|---|
data | List<Vector2> | getData() | UV coordinate pairs. |
VertexElementVertexColor
Stores per-vertex or per-corner RGBA colour data as Vector4 (r, g, b, a in the range 0–1).
Properties
| Property | Type | Getter | Description |
|---|---|---|---|
data | List<Vector4> | getData() | RGBA colour values. |
VertexElementType Enumeration
Identifies the semantic role of a vertex element layer.
import com.aspose.threed.*;| Value | Description |
|---|---|
NORMAL | Surface normal vectors. |
UV | Texture UV coordinates. |
VERTEX_COLOR | Per-vertex RGBA colour. |
TANGENT | Tangent vectors for normal mapping. |
BINORMAL | Binormal (bitangent) vectors. |
MATERIAL | Per-polygon material index. |
POLYGON_GROUP | Polygon grouping index. |
VERTEX_CREASE | Subdivision vertex crease weights. |
EDGE_CREASE | Subdivision edge crease weights. |
USER_DATA | Arbitrary user-defined data. |
VISIBILITY | Per-element visibility flags. |
SPECULAR | Specular colour or intensity. |
WEIGHT | Blend weights for skinning. |
HOLE | Polygon hole flags. |
MappingMode Enumeration
Controls which geometry primitive each vertex element value is associated with.
| Value | Description |
|---|---|
CONTROL_POINT | One value per control point (vertex). |
POLYGON_VERTEX | One value per polygon corner (face-vertex). |
POLYGON | One value per polygon. |
ReferenceMode Enumeration
Controls how the vertex element data array is indexed.
| Value | Description |
|---|---|
DIRECT | Data is accessed sequentially without a separate indices array. |
INDEX | Data is accessed via a separate indices array. |
INDEX_TO_DIRECT | An indices array maps each mapping primitive to a position in the data array. |
Example
import com.aspose.threed.Scene;
import com.aspose.threed.*;
Scene scene = Scene.fromFile("model.obj");
for (Node node : scene.getRootNode().getChildNodes()) {
if (node.getEntity() instanceof Mesh) {
Mesh mesh = (Mesh) node.getEntity();
for (VertexElement ve : mesh.getVertexElements()) {
System.out.println(" Element: " + ve.getVertexElementType()
+ " mapping=" + ve.getMappingMode()
+ " ref=" + ve.getReferenceMode());
}
}
}