VertexElement

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

PropertyTypeGetterSetterDescription
vertexElementTypeVertexElementTypegetVertexElementType()Semantic type of this element (read-only).
mappingModeMappingModegetMappingMode()setMappingMode(MappingMode)Controls which primitive each value maps to.
referenceModeReferenceModegetReferenceMode()setReferenceMode(ReferenceMode)Controls how values are indexed.
indicesList<Integer>getIndices()Index array (used when reference mode is INDEX_TO_DIRECT).
nameStringgetName()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

PropertyTypeGetterDescription
dataList<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

PropertyTypeGetterDescription
dataList<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

PropertyTypeGetterDescription
dataList<Vector4>getData()RGBA colour values.

VertexElementType Enumeration

Identifies the semantic role of a vertex element layer.

import com.aspose.threed.*;
ValueDescription
NORMALSurface normal vectors.
UVTexture UV coordinates.
VERTEX_COLORPer-vertex RGBA colour.
TANGENTTangent vectors for normal mapping.
BINORMALBinormal (bitangent) vectors.
MATERIALPer-polygon material index.
POLYGON_GROUPPolygon grouping index.
VERTEX_CREASESubdivision vertex crease weights.
EDGE_CREASESubdivision edge crease weights.
USER_DATAArbitrary user-defined data.
VISIBILITYPer-element visibility flags.
SPECULARSpecular colour or intensity.
WEIGHTBlend weights for skinning.
HOLEPolygon hole flags.

MappingMode Enumeration

Controls which geometry primitive each vertex element value is associated with.

ValueDescription
CONTROL_POINTOne value per control point (vertex).
POLYGON_VERTEXOne value per polygon corner (face-vertex).
POLYGONOne value per polygon.

ReferenceMode Enumeration

Controls how the vertex element data array is indexed.

ValueDescription
DIRECTData is accessed sequentially without a separate indices array.
INDEXData is accessed via a separate indices array.
INDEX_TO_DIRECTAn 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());
        }
    }
}

See Also