GlobalTransform — Aspose.3D FOSS for Python API Reference
Example
GlobalTransform 是一个 只读 快照,表示一个 Node的世界空间变换。它通过以下方式获取: node.global_transform 并反映节点自身的 Transform 与所有祖先节点的变换组合,直至场景根节点。.
所有属性都是只读的。要更改节点的位置,请修改节点的本地 Transform 而不是。.
Example: aspose.threed
from aspose.threed import GlobalTransformGlobalTransform 通常不会直接实例化;你会从以下获取它: node.global_transform.
Example
| Example | Example | Example |
|---|---|---|
translation | Vector3 | 节点的世界空间位置 |
scale | Vector3 | 节点的世界空间缩放 |
rotation | Quaternion | 节点的世界空间旋转(四元数) |
euler_angles | Vector3 | 节点的世界空间旋转(欧拉角,单位为弧度) (roll, pitch, yaw) |
transform_matrix | Matrix4 | 完整的 4×4 世界空间变换矩阵 |
Example
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)Example
GlobalTransform在以下时间计算node.global_transform被访问时;它是 不 如果父节点的,则动态更新Transform后续更改。.- Example
scale属性名称在GlobalTransform是scale(不是scaling)Transform使用scaling用于可写的比例属性。.