GlobalTransform

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 GlobalTransform

GlobalTransform không thường được khởi tạo trực tiếp; bạn nhận nó từ node.global_transform.

Properties

PropertiesPropertiesProperties
translationVector3Vị trí không gian thế giới của node
scaleVector3Tỷ lệ không gian thế giới của node
rotationQuaternionXoay không gian thế giới dưới dạng quaternion
euler_anglesVector3Xoay không gian thế giới dưới dạng góc Euler tính bằng radian (roll, pitch, yaw)
transform_matrixMatrix4Ma 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ểm node.global_transform được truy cập; nó là không được cập nhật động nếu nút cha Transform thay đổi sau này.
  • Properties scale tên thuộc tính trên GlobalTransformscale (không scaling). Cục bộ Transform sử dụng scaling cho thuộc tính tỷ lệ có thể ghi.

Xem thêm

 Tiếng Việt