GlobalTransform — Aspose.3D FOSS for Python API Reference
Properties
GlobalTransform là một chỉ đọc bản chụp của một Nodebiến đổi không gian thế giới của nó. Nó được lấy thông qua node.global_transform và phản ánh sự kết hợp của node’s own Transform với mọi phép biến đổi của các tổ tiên lên tới gốc cảnh.
Tất cả các thuộc tính đều chỉ đọc. Để thay đổi vị trí của node, sửa đổi node’s local Transform thay vào.
Properties: aspose.threed
from aspose.threed import GlobalTransformGlobalTransform không thường được khởi tạo trực tiếp; bạn nhận nó từ node.global_transform.
Properties
| Properties | Properties | Properties |
|---|---|---|
translation | Vector3 | Vị trí không gian thế giới của node |
scale | Vector3 | Tỷ lệ không gian thế giới của node |
rotation | Quaternion | Xoay không gian thế giới dưới dạng quaternion |
euler_angles | Vector3 | Xoay không gian thế giới dưới dạng góc Euler tính bằng radian (roll, pitch, yaw) |
transform_matrix | Matrix4 | Ma trận biến đổi không gian thế giới 4×4 đầy đủ |
Properties
from aspose.threed import Scene
from aspose.threed.utilities import Vector3
import math
scene = Scene()
# Create a parent node at (10, 0, 0)
parent = scene.root_node.create_child_node("parent")
parent.transform.translation = Vector3(10.0, 0.0, 0.0)
# Create a child node at (5, 0, 0) relative to parent
child = parent.create_child_node("child")
child.transform.translation = Vector3(5.0, 0.0, 0.0)
# Read world-space position
gt = child.global_transform
print(gt.translation) # Vector3(15.0, 0.0, 0.0)
print(gt.scale) # Vector3(1.0, 1.0, 1.0)
# Access the 4x4 matrix directly
mat = gt.transform_matrix
print(mat.m03) # 15.0 — world-space X translation
# Euler angles in degrees
angles = gt.euler_angles
print(math.degrees(angles.x)) # 0.0 (no rotation)
# Using evaluate_global_transform to include geometric offset
manual_mat = child.evaluate_global_transform(True)Properties
GlobalTransformđược tính vào thời điểmnode.global_transformđược truy cập; nó là không được cập nhật động nếu nút chaTransformthay đổi sau này.- Properties
scaletên thuộc tính trênGlobalTransformlàscale(khôngscaling). Cục bộTransformsử dụngscalingcho thuộc tính tỷ lệ có thể ghi.