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 VertexElementVertexElement
vertex_element_type | VertexElementType | อ่าน | ประเภทเชิงความหมายของชั้นนี้ (เช่น., NORMAL, UV, VERTEX_COLOR). |
name | str | อ่าน/เขียน | ชื่อทางเลือกสำหรับชั้นนี้. |
mapping_mode | MappingMode | อ่าน/เขียน | ควบคุมว่า primitive ของเรขาคณิตใดที่ค่าข้อมูลแต่ละค่าถูกเชื่อมโยงกับ. |
reference_mode | ReferenceMode | อ่าน/เขียน | ควบคุมว่าค่าจะถูกอ้างอิงโดยตรงหรือผ่านอาเรย์ของดัชนี. |
indices | list[int] | อ่าน | อาเรย์ดัชนีที่ใช้เมื่อ reference_mode คือ INDEX_TO_DIRECT. |
data | list[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 VertexElementNormalVertexElement → VertexElementFVector → VertexElementNormal
VertexElementNormal(name="", mapping_mode=None, reference_mode=None)vertex_element_type ถูกกำหนดเป็น VertexElementType.NORMAL.
VertexElementUV
เก็บพิกัดเทกซ์เจอร์ UV. เมชอาจมีหลายชั้น UV สำหรับช่องเทกซ์เจอร์ที่แตกต่างกัน.
from aspose.threed.entities import VertexElementUVVertexElement → VertexElementFVector → VertexElementUV
VertexElementUV(texture_mapping=None, name="", mapping_mode=None, reference_mode=None)texture_mapping | TextureMapping | ช่องเทกเจอร์ที่เลเยอร์ UV นี้ให้บริการ ค่าเริ่มต้นคือ TextureMapping.DIFFUSE. |
คุณสมบัติเพิ่มเติม
texture_mapping | TextureMapping | อ่าน | ช่องเทกเจอร์ที่เลเยอร์ 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 VertexElementVertexColorVertexElement → VertexElementFVector → VertexElementVertexColor
VertexElementVertexColor(name="", mapping_mode=None, reference_mode=None)vertex_element_type ถูกกำหนดเป็น VertexElementType.VERTEX_COLOR.
VertexElementTangent
เก็บเวกเตอร์แทนเจนต์ต่อเวอร์เท็กซ์หรือต่อคอร์เนอร์ ใช้สำหรับการเรนเดอร์แผนที่นอร์มอล.
from aspose.threed.entities import VertexElementTangentVertexElement → VertexElementFVector → VertexElementTangent
vertex_element_type ถูกกำหนดเป็น VertexElementType.TANGENT.
VertexElementBinormal
เก็บเวกเตอร์ไบโนมัล (บิแทนเจนท์) ต่อเวอร์เท็กซ์หรือต่อคอร์เนอร์, เสริม VertexElementTangent สำหรับการทำ tangent-space normal mapping.
from aspose.threed.entities import VertexElementBinormalVertexElement → VertexElementFVector → VertexElementBinormal
vertex_element_type ถูกกำหนดเป็น VertexElementType.BINORMAL.
VertexElementSmoothingGroup
เก็บค่า ID ของกลุ่ม smoothing group แบบจำนวนเต็มต่อโพลิกอน โหลดจากไฟล์ OBJ ที่มี s การประกาศ.
from aspose.threed.entities import VertexElementSmoothingGroupVertexElement → VertexElementIntsTemplate → VertexElementSmoothingGroup
vertex_element_type ถูกกำหนดเป็น VertexElementType.SMOOTHING_GROUP.
enumeration VertexElementType
ระบุบทบาทเชิงความหมายของเลเยอร์องค์ประกอบเวอร์เท็กซ์.
from aspose.threed.entities import VertexElementTypeNORMAL | เวกเตอร์นอร์มัลของพื้นผิว. |
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 MappingModeCONTROL_POINT | หนึ่งค่าต่อจุดควบคุม (vertex). |
POLYGON_VERTEX | หนึ่งค่าต่อมุมของโพลิกอน (face-vertex). |
POLYGON | หนึ่งค่าต่อโพลิกอน. |
EDGE | หนึ่งค่าต่อขอบ. |
ALL_SAME | ค่าหนึ่งค่าจะใช้กับเมชทั้งหมด. |
enumeration ReferenceMode
ควบคุมวิธีการทำดัชนีของอาเรย์ข้อมูล.
from aspose.threed.entities import ReferenceModeDIRECT | ข้อมูลถูกเข้าถึงแบบต่อเนื่องโดยไม่มีอาเรย์ดัชนีแยกต่างหาก. |
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")