GlobalTransform – Aspose.3D FOSS for Java
Notes
GlobalTransform là một chỉ đọc ảnh chụp của một Nodechuyển đổi không gian thế giới của ‘. Nó được lấy thông qua node.getGlobalTransform() và phản ánh sự kết hợp của node 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 local của node Transform thay vào đó.
Notes: com.aspose.threed
import com.aspose.threed.GlobalTransform;GlobalTransform không được khởi tạo trực tiếp; bạn nhận nó từ node.getGlobalTransform().
Notes
| Class | Description |
|---|---|
GlobalTransform | Read-only world-space transform snapshot. Exposes the composed translation, rotation, scale, and matrix of a node in world space. |
| Name | Type | Access | Description |
|---|---|---|---|
translation | Vector3 | Read | Returns the world-space translation (position) of the node. |
rotation | Vector3 | Read | Returns the world-space rotation (Euler angles) of the node. |
scale | Vector3 | Read | Returns the world-space scale of the node. |
transformMatrix | Matrix4 | Read | Returns the full 4x4 world-space transformation matrix. |
| Signature | Description |
|---|---|
getTranslation() to Vector3 | Returns the world-space translation of the node. |
getRotation() to Vector3 | Returns the world-space rotation of the node. |
getScale() to Vector3 | Returns the world-space scale of the node. |
getTransformMatrix() to Matrix4 | Returns the full 4x4 world-space transformation matrix. |
Notes
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);Notes
GlobalTransformđược tính vào thời điểmnode.getGlobalTransform()được truy cập; nó là không được cập nhật động nếu nút chaTransformcác thay đổi sau.- Getter là
getScale()bậtGlobalTransform(khônggetScaling()). Cục bộTransformsử dụnggetScaling()cho thuộc tính tỷ lệ có thể ghi.