GlobalTransform

GlobalTransform

Methods

GlobalTransform là một chỉ-đọc bản chụp nhanh của một Node’s world-space transformation. Nó được lấy thông qua node.getGlobalTransform() và phản ánh sự kết hợp của node’s own Transform với mọi 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.

Methods: com.aspose.threed

import com.aspose.threed.GlobalTransform;

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

Methods

NameTypeAccessDescription
translationVector3ReadGets the translation.
scaleVector3ReadGets the scale.
eulerAnglesVector3ReadGets the rotation represented in Euler angles, measured in degree.
rotationQuaternionReadGets the rotation represented in quaternion.
transformMatrixMatrix4ReadGets the transform matrix.
SignatureDescription
GlobalTransform()Initializes a new instance of the GlobalTransform class.
GlobalTransform(matrix: Matrix4)Initializes a new instance of the GlobalTransform class with the specified matrix.
getTranslation()Vector3Gets the translation.
getScale()Vector3Gets the scale.
getEulerAngles()Vector3Gets the rotation represented in Euler angles, measured in degree.
getRotation()QuaternionGets the rotation represented in quaternion.
getTransformMatrix()Matrix4Gets the transform matrix.

Methods

import com.aspose.threed.Scene;
import com.aspose.threed.Node;
import com.aspose.threed.GlobalTransform;
import com.aspose.threed.*;


Scene scene = new Scene();

// Create a parent node at (10, 0, 0)
Node parent = scene.getRootNode().createChildNode("parent");
parent.getTransform().setTranslation(new Vector3(10.0, 0.0, 0.0));

// Create a child node at (5, 0, 0) relative to parent
Node child = parent.createChildNode("child");
child.getTransform().setTranslation(new Vector3(5.0, 0.0, 0.0));

// Read world-space position
GlobalTransform gt = child.getGlobalTransform();
System.out.println(gt.getTranslation());          // Vector3(15.0, 0.0, 0.0)
System.out.println(gt.getScale());                 // Vector3(1.0, 1.0, 1.0)

// Access the 4x4 matrix directly
Matrix4 mat = gt.getTransformMatrix();
System.out.println(mat.m03);   // 15.0 -- world-space X translation

// Euler angles in degrees
Vector3 angles = gt.getEulerAngles();
System.out.println(Math.toDegrees(angles.x));   // 0.0 (no rotation)

// Using evaluateGlobalTransform to include geometric offset
Matrix4 manualMat = child.evaluateGlobalTransform(true);

Methods

  • GlobalTransform được tính vào thời điểm node.getGlobalTransform() được truy cập; nó là không được cập nhật động nếu của nút cha Transform thay đổi sau này.
  • Getter là getScale() bật GlobalTransform (không getScaling()). Cục bộ Transform sử dụng getScaling() cho thuộc tính tỷ lệ có thể ghi.

Xem thêm

 Tiếng Việt