VertexElement

VertexElement — Aspose.3D FOSS for Java

Gói: com.aspose.threed (aspose-3d-foss 26.1.0)

VertexElement là lớp cơ sở trừu tượng cho các lớp dữ liệu theo đỉnh (hoặc theo đa giác, theo cạnh) được gắn vào một Mesh.Mỗi lớp con lưu trữ một loại thuộc tính hình học cụ thể – vector pháp tuyến, tọa độ UV, màu đỉnh, hoặc nhóm làm mịn.


Properties

Properties

PropertiesPropertiesPropertiesPropertiesProperties
vertexElementTypeVertexElementTypegetVertexElementType()Kiểu ngữ nghĩa của phần tử này (chỉ đọc).
mappingModeMappingModegetMappingMode()setMappingMode(MappingMode)Kiểm soát primitive nào mà mỗi giá trị được ánh xạ tới.
referenceModeReferenceModegetReferenceMode()setReferenceMode(ReferenceMode)Kiểm soát cách các giá trị được lập chỉ mục.
indicesList<Integer>getIndices()Mảng chỉ mục (được sử dụng khi chế độ tham chiếu là INDEX_TO_DIRECT).
nameStringgetName()setName(String)Tên tùy chọn của lớp phần tử đỉnh này.

VertexElementNormal

Lưu trữ một vector pháp tuyến cho mỗi đỉnh hoặc cho mỗi góc đa giác, tùy thuộc vào getMappingMode(). Các giá trị dữ liệu là Vector4 các thể hiện với w không được sử dụng.

import com.aspose.threed.*;

VertexElement normals = mesh.createElement(
    VertexElementType.NORMAL,
    MappingMode.CONTROL_POINT,
    ReferenceMode.DIRECT
);

Properties

PropertiesPropertiesPropertiesProperties
dataList<Vector4>getData()Vector pháp tuyến. The w thành phần không được sử dụng (thông thường 0.0).

Trả về: VertexElementUV

Lưu trữ các cặp tọa độ texture (Vector2) trên mỗi đỉnh hoặc trên mỗi góc đa giác. Một lưới có thể chứa nhiều lớp UV cho các kênh kết cấu khác nhau.


VertexElementUV uv = mesh.createElementUV(
    TextureMapping.DIFFUSE,
    MappingMode.POLYGON_VERTEX,
    ReferenceMode.INDEX_TO_DIRECT
);

Properties

PropertiesPropertiesPropertiesProperties
dataList<Vector2>getData()Các cặp tọa độ UV.

VertexElementVertexColor

Lưu trữ dữ liệu màu RGBA cho mỗi đỉnh hoặc mỗi góc dưới dạng Vector4 (r, g, b, a trong khoảng 0–1).

Properties

PropertiesPropertiesPropertiesProperties
dataList<Vector4>getData()Giá trị màu RGBA.

Enumeration VertexElementType

Xác định vai trò ngữ nghĩa của lớp phần tử đỉnh.

import com.aspose.threed.*;
PropertiesProperties
NORMALVector pháp tuyến bề mặt.
UVTọa độ UV của texture.
VERTEX_COLORMàu RGBA cho mỗi đỉnh.
TANGENTVector tiếp tuyến cho normal mapping.
BINORMALVector binormal (bitangent).
MATERIALChỉ mục vật liệu cho mỗi đa giác.
POLYGON_GROUPChỉ mục nhóm đa giác.
VERTEX_CREASETrọng số nếp gấp đỉnh trong subdivision.
EDGE_CREASETrọng số nếp gấp cạnh trong subdivision.
USER_DATADữ liệu tùy ý do người dùng định nghĩa.
VISIBILITYCờ hiển thị cho mỗi phần tử.
SPECULARMàu phản chiếu hoặc cường độ.
WEIGHTTrọng số pha trộn cho skinning.
HOLECờ lỗ đa giác.

Enumeration MappingMode

Kiểm soát primitive hình học nào mà mỗi giá trị phần tử đỉnh được gắn kết.

PropertiesProperties
CONTROL_POINTMột giá trị cho mỗi điểm điều khiển (đỉnh).
POLYGON_VERTEXMột giá trị cho mỗi góc đa giác (đỉnh-mặt).
POLYGONMột giá trị cho mỗi đa giác.

Enumeration ReferenceMode

Kiểm soát cách mảng dữ liệu phần tử đỉnh được đánh chỉ mục.

PropertiesProperties
DIRECTDữ liệu được truy cập tuần tự mà không có mảng chỉ số riêng.
INDEXDữ liệu được truy cập thông qua một mảng chỉ số riêng.
INDEX_TO_DIRECTMột mảng chỉ số ánh xạ mỗi primitive tới một vị trí trong mảng dữ liệu.

Properties

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());
        }
    }
}

Xem thêm

 Tiếng Việt