GlobalTransform — Aspose.3D FOSS for Java
Overview
GlobalTransform is a read-only snapshot of a Node’s world-space transformation. It is obtained via node.getGlobalTransform() and reflects the composition of the node’s own Transform with every ancestor’s transform up to the scene root.
All properties are read-only. To change a node’s position, modify the node’s local Transform instead.
Package: com.aspose.threed
import com.aspose.threed.GlobalTransform;GlobalTransform is not normally instantiated directly; you receive it from node.getGlobalTransform().
Properties
| Name | Type | Getter | Description |
|---|---|---|---|
translation | Vector3 | getTranslation() | World-space position of the node |
scale | Vector3 | getScale() | World-space scale of the node |
rotation | Quaternion | getRotation() | World-space rotation as a quaternion |
eulerAngles | Vector3 | getEulerAngles() | World-space rotation as Euler angles in radians (roll, pitch, yaw) |
transformMatrix | Matrix4 | getTransformMatrix() | Complete 4x4 world-space transform matrix |
Example
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
GlobalTransformis computed at the timenode.getGlobalTransform()is accessed; it is not updated dynamically if a parent node’sTransformlater changes.- The getter is
getScale()onGlobalTransform(notgetScaling()). The localTransformusesgetScaling()for the writable scale property.