VertexElement — Aspose.3D Python API Reference

แพคเกจ: aspose.threed.entities (aspose-3d-foss 26.1.0)

VertexElement เป็นคลาสฐานเชิงนามธรรมสำหรับชั้นข้อมูลต่อจุด (per-vertex) ทั้งหมดที่สามารถแนบเข้ากับ Geometry อ็อบเจ็กต์แต่ละชั้นเก็บอาเรย์ของค่าข้อมูลพร้อมกับ mapping_mode และ reference_mode เมตาดาต้าที่อธิบายว่าข้อมูลแมปกับเรขาคณิตพื้นฐานอย่างไร ชั้นย่อยจะถูกปรับให้เหมาะกับ normals, UV coordinates, vertex colours, tangents, binormals, และ smoothing groups.


from aspose.threed.entities import VertexElement

VertexElement

vertex_element_typeVertexElementTypeอ่านประเภทเชิงความหมายของชั้นนี้ (เช่น., NORMAL, UV, VERTEX_COLOR).
namestrอ่าน/เขียนชื่อทางเลือกสำหรับชั้นนี้.
mapping_modeMappingModeอ่าน/เขียนควบคุมว่า primitive ของเรขาคณิตใดที่ค่าข้อมูลแต่ละค่าถูกเชื่อมโยงกับ.
reference_modeReferenceModeอ่าน/เขียนควบคุมว่าค่าจะถูกอ้างอิงโดยตรงหรือผ่านอาเรย์ของดัชนี.
indiceslist[int]อ่านอาเรย์ดัชนีที่ใช้เมื่อ reference_mode คือ INDEX_TO_DIRECT.
datalist[FVector4]อ่านค่าข้อมูลดิบที่จัดเก็บเป็น FVector4 รายการ (พร้อมใช้งานบน VertexElementFVector คลาสย่อย).

set_data(data)Noneแทนที่อาเรย์ข้อมูล รับค่า list[FVector2], list[FVector3], หรือ list[FVector4]; ค่าถูกทำให้เป็นมาตรฐานเป็น FVector4 ภายในระบบ.
set_indices(data)Noneแทนที่อาเรย์ดัชนีด้วยรายการของจำนวนเต็ม.
clear()Noneลบค่าข้อมูลและดัชนีทั้งหมดออกจากเลเยอร์.
copy_to(target)Noneคัดลอกข้อมูลและดัชนีไปยังอีก VertexElementFVector อินสแตนซ์.

VertexElementNormal

เก็บเวกเตอร์ปกติของพื้นผิว (surface normal vectors). ข้อมูล Normal มักถูกใช้โดยเรนเดอร์เพื่อการคำนวณแสง.

from aspose.threed.entities import VertexElementNormal

VertexElementVertexElementFVectorVertexElementNormal

VertexElementNormal(name="", mapping_mode=None, reference_mode=None)

vertex_element_type ถูกกำหนดเป็น VertexElementType.NORMAL.


VertexElementUV

เก็บพิกัดเทกซ์เจอร์ UV. เมชอาจมีหลายชั้น UV สำหรับช่องเทกซ์เจอร์ที่แตกต่างกัน.

from aspose.threed.entities import VertexElementUV

VertexElementVertexElementFVectorVertexElementUV

VertexElementUV(texture_mapping=None, name="", mapping_mode=None, reference_mode=None)
texture_mappingTextureMappingช่องเทกเจอร์ที่เลเยอร์ UV นี้ให้บริการ ค่าเริ่มต้นคือ TextureMapping.DIFFUSE.

คุณสมบัติเพิ่มเติม

texture_mappingTextureMappingอ่านช่องเทกเจอร์ที่เลเยอร์ UV นี้เชื่อมโยงกับ.

add_data(data)

เพิ่มข้อมูลพิกัด UV รับค่า list[Vector2], list[Vector3], list[FVector2], list[FVector3], หรือ list[FVector4]. ค่าทั้งหมดจะถูกเก็บภายในเป็น FVector4 โดยกำหนดส่วนประกอบที่ไม่ได้ใช้เป็น 0.0.


VertexElementVertexColor

เก็บค่าความสี RGBA ต่อเวอร์เทกซ์ในช่วง 0–1.

from aspose.threed.entities import VertexElementVertexColor

VertexElementVertexElementFVectorVertexElementVertexColor

VertexElementVertexColor(name="", mapping_mode=None, reference_mode=None)

vertex_element_type ถูกกำหนดเป็น VertexElementType.VERTEX_COLOR.


VertexElementTangent

เก็บเวกเตอร์แทนเจนต์ต่อเวอร์เท็กซ์หรือต่อคอร์เนอร์ ใช้สำหรับการเรนเดอร์แผนที่นอร์มอล.

from aspose.threed.entities import VertexElementTangent

VertexElementVertexElementFVectorVertexElementTangent

vertex_element_type ถูกกำหนดเป็น VertexElementType.TANGENT.


VertexElementBinormal

เก็บเวกเตอร์ไบโนมัล (บิแทนเจนท์) ต่อเวอร์เท็กซ์หรือต่อคอร์เนอร์, เสริม VertexElementTangent สำหรับการทำ tangent-space normal mapping.

from aspose.threed.entities import VertexElementBinormal

VertexElementVertexElementFVectorVertexElementBinormal

vertex_element_type ถูกกำหนดเป็น VertexElementType.BINORMAL.


VertexElementSmoothingGroup

เก็บค่า ID ของกลุ่ม smoothing group แบบจำนวนเต็มต่อโพลิกอน โหลดจากไฟล์ OBJ ที่มี s การประกาศ.

from aspose.threed.entities import VertexElementSmoothingGroup

VertexElementVertexElementIntsTemplateVertexElementSmoothingGroup

vertex_element_type ถูกกำหนดเป็น VertexElementType.SMOOTHING_GROUP.


enumeration VertexElementType

ระบุบทบาทเชิงความหมายของเลเยอร์องค์ประกอบเวอร์เท็กซ์.

from aspose.threed.entities import VertexElementType
NORMALเวกเตอร์นอร์มัลของพื้นผิว.
UVพิกัด UV ของเทกซ์เจอร์.
VERTEX_COLORสี RGBA ต่อเวอร์เท็กซ์.
TANGENTเวกเตอร์แทนเจนท์สำหรับ normal mapping.
BINORMALเวกเตอร์ไบโนมอล (bitangent).
SMOOTHING_GROUPค่า ID จำนวนเต็มของกลุ่ม smoothing group ต่อโพลิกอน.
MATERIALดัชนีวัสดุต่อโพลิกอน.
POLYGON_GROUPดัชนีการจัดกลุ่มโพลิกอน.
VERTEX_CREASEน้ำหนักรอยพับของเวอร์เท็กซ์ในการแบ่งส่วน.
EDGE_CREASEน้ำหนักรอยพับของขอบในการแบ่งส่วน.
USER_DATAข้อมูลที่ผู้ใช้กำหนดเองแบบอิสระ.
VISIBILITYแฟล็กการมองเห็นต่อแต่ละองค์ประกอบ.
SPECULARสีหรือความเข้มของสเปคูลาร์.
WEIGHTน้ำหนักการผสมสำหรับสกินนิ่ง.
HOLEแฟล็กรูของโพลิกอน.

enumeration MappingMode

ควบคุมว่าเรขาคณิตพื้นฐานใดที่ค่าขององค์ประกอบเวอร์เท็กซ์แต่ละค่าเชื่อมโยงด้วย.

from aspose.threed.entities import MappingMode
CONTROL_POINTหนึ่งค่าต่อจุดควบคุม (vertex).
POLYGON_VERTEXหนึ่งค่าต่อมุมของโพลิกอน (face-vertex).
POLYGONหนึ่งค่าต่อโพลิกอน.
EDGEหนึ่งค่าต่อขอบ.
ALL_SAMEค่าหนึ่งค่าจะใช้กับเมชทั้งหมด.

enumeration ReferenceMode

ควบคุมวิธีการทำดัชนีของอาเรย์ข้อมูล.

from aspose.threed.entities import ReferenceMode
DIRECTข้อมูลถูกเข้าถึงแบบต่อเนื่องโดยไม่มีอาเรย์ดัชนีแยกต่างหาก.
INDEXข้อมูลถูกเข้าถึงผ่านอาเรย์ดัชนีแยกต่างหาก.
INDEX_TO_DIRECTอาเรย์ดัชนีจะทำการแมป primitive แต่ละตัวไปยังตำแหน่งในอาเรย์ข้อมูล.

แนบเลเยอร์นอร์มอลเข้ากับเมช (การแมปแบบ DIRECT):

from aspose.threed import Scene
from aspose.threed.entities import Mesh, VertexElementType, MappingMode, ReferenceMode, VertexElementNormal
from aspose.threed.utilities import Vector4, FVector4

mesh = Mesh()
mesh.control_points.append(Vector4(0.0, 0.0, 0.0, 1.0))
mesh.control_points.append(Vector4(1.0, 0.0, 0.0, 1.0))
mesh.control_points.append(Vector4(0.5, 1.0, 0.0, 1.0))
mesh.create_polygon(0, 1, 2)

normals: VertexElementNormal = mesh.create_element(
    VertexElementType.NORMAL,
    MappingMode.CONTROL_POINT,
    ReferenceMode.DIRECT,
)
normals.set_data([
    FVector4(0.0, 0.0, 1.0, 0.0),
    FVector4(0.0, 0.0, 1.0, 0.0),
    FVector4(0.0, 0.0, 1.0, 0.0),
])

scene = Scene()
scene.root_node.create_child_node("tri", mesh)
scene.save("triangle_normals.glb")

แนบพิกัด UV (การแมป INDEX_TO_DIRECT):

from aspose.threed import Scene
from aspose.threed.entities import Mesh, TextureMapping, MappingMode, ReferenceMode
from aspose.threed.utilities import Vector4, FVector4

mesh = Mesh()
for x, z in [(0, 0), (1, 0), (1, 1), (0, 1)]:
    mesh.control_points.append(Vector4(float(x), 0.0, float(z), 1.0))
mesh.create_polygon(0, 1, 2, 3)

uv = mesh.create_element_uv(
    TextureMapping.DIFFUSE,
    MappingMode.POLYGON_VERTEX,
    ReferenceMode.INDEX_TO_DIRECT,
)
uv.set_data([
    FVector4(0.0, 0.0, 0.0, 0.0),
    FVector4(1.0, 0.0, 0.0, 0.0),
    FVector4(1.0, 1.0, 0.0, 0.0),
    FVector4(0.0, 1.0, 0.0, 0.0),
])
uv.set_indices([0, 1, 2, 3])

scene = Scene()
scene.root_node.create_child_node("quad", mesh)
scene.save("quad_uv.glb")

ดูเพิ่มเติม

 ภาษาไทย