Transform
Properties: com.aspose.threed (aspose-3d-foss)
Transform kiểm soát vị trí, hướng và tỉ lệ của một Node trong cảnh 3D. Mỗi nút có đúng một Transform, được truy cập qua node.getTransform().
public class Transform extends A3DObjectTruy cập Transform của Node
import com.aspose.threed.Scene;
Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("box");
Transform t = node.getTransform();Properties
| Name | Type | Access | Description |
|---|---|---|---|
translation | Vector3 | Read | Gets the translation. |
scaling | Vector3 | Read | Gets the scaling. |
eulerAngles | Vector3 | Read | Gets the euler angles. |
rotation | Quaternion | Read | Gets the rotation. |
preRotation | Vector3 | Read | Gets the pre rotation. |
postRotation | Vector3 | Read | Gets the post rotation. |
geometricTranslation | Vector3 | Read | Gets the geometric translation. |
geometricScaling | Vector3 | Read | Gets the geometric scaling. |
geometricRotation | Vector3 | Read | Gets the geometric rotation. |
scalingOffset | Vector3 | Read | Gets the scaling offset. |
scalingPivot | Vector3 | Read | Gets the scaling pivot. |
rotationOffset | Vector3 | Read | Gets the rotation offset. |
rotationPivot | Vector3 | Read | Gets the rotation pivot. |
transformMatrix | Matrix4 | Read | Gets the transform matrix. |
name | String | Read | Gets the name. |
properties | PropertyCollection | Read | Gets the properties. |
Các phương thức Setter dạng fluent
Tất cả các hàm setter trả về this, cho phép chuỗi lệnh:
| Signature | Description |
|---|---|
Transform() | Calls Transform on this Transform instance. |
Transform(name: String) | Calls Transform(name) on this Transform instance. |
getTranslation() → Vector3 | Returns the translation. |
setTranslation(value: Vector3) | Sets the translation value. |
setTranslation(x: double, y: double, z: double) → Transform | Sets the translation value. |
getScaling() → Vector3 | Returns the scaling. |
setScaling(value: Vector3) | Sets the scaling value. |
setScale(x: double, y: double, z: double) → Transform | Sets the scale value. |
getEulerAngles() → Vector3 | Returns the euler angles. |
setEulerAngles(value: Vector3) | Sets the euler angles value. |
setEulerAngles(x: double, y: double, z: double) → Transform | Sets the euler angles value. |
getRotation() → Quaternion | Returns the rotation. |
setRotation(value: Quaternion) | Sets the rotation value. |
setRotation(x: double, y: double, z: double, w: double) → Transform | Sets the rotation value. |
setPreRotation(x: double, y: double, z: double) → Transform | Sets the pre rotation value. |
getPreRotation() → Vector3 | Returns the pre rotation. |
setPreRotation(value: Vector3) | Sets the pre rotation value. |
setPostRotation(x: double, y: double, z: double) → Transform | Sets the post rotation value. |
getPostRotation() → Vector3 | Returns the post rotation. |
setPostRotation(value: Vector3) | Sets the post rotation value. |
getGeometricTranslation() → Vector3 | Returns the geometric translation. |
setGeometricTranslation(value: Vector3) | Sets the geometric translation value. |
setGeometricTranslation(x: double, y: double, z: double) → Transform | Sets the geometric translation value. |
getGeometricScaling() → Vector3 | Returns the geometric scaling. |
setGeometricScaling(value: Vector3) | Sets the geometric scaling value. |
setGeometricScaling(x: double, y: double, z: double) → Transform | Sets the geometric scaling value. |
getGeometricRotation() → Vector3 | Returns the geometric rotation. |
setGeometricRotation(value: Vector3) | Sets the geometric rotation value. |
setGeometricRotation(x: double, y: double, z: double) → Transform | Sets the geometric rotation value. |
getScalingOffset() → Vector3 | Returns the scaling offset. |
setScalingOffset(value: Vector3) | Sets the scaling offset value. |
getScalingPivot() → Vector3 | Returns the scaling pivot. |
setScalingPivot(value: Vector3) | Sets the scaling pivot value. |
getRotationOffset() → Vector3 | Returns the rotation offset. |
setRotationOffset(value: Vector3) | Sets the rotation offset value. |
getRotationPivot() → Vector3 | Returns the rotation pivot. |
setRotationPivot(value: Vector3) | Sets the rotation pivot value. |
getTransformMatrix() → Matrix4 | Returns the transform matrix. |
setTransformMatrix(value: Matrix4) | Sets the transform matrix value. |
A3DObject() | Parameterized Cylinder. It can also be used to represent a cone when one of radiusTop/radiusBottom is zero. |
getName() → String | The segments of the curve. |
setName(name: String) | Constructs a CircleShape profile with specified radius. |
getProperties() → PropertyCollection | Initializes a new instance of Cylinder class. |
findProperty(name: String) → Property | Initializes a new instance of the Bone class. |
getProperty(name: String) → Object | Gets the transform matrix of the node in current pose. |
setProperty(name: String, value: Object) | Gets the width segments. |
removeProperty(name: String) → boolean | Gets flip coordinate system of control points/normal during importing/exporting. |
Ví dụ sử dụng
Đặt vị trí cho Node
import com.aspose.threed.Scene;
import com.aspose.threed.*;
Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("box");
// Using fluent setters
node.getTransform().setTranslation(5.0, 0.0, -3.0);
// Or via property setter
node.getTransform().setTranslation(new Vector3(5.0, 0.0, -3.0));Xoay bằng góc Euler
Scene scene = new Scene(); Node node = scene.getRootNode().createChildNode(“rotated”);
// Rotate 45 degrees around Y axis node.getTransform().setEulerAngles(0.0, 45.0, 0.0);
// Chain multiple operations node.getTransform() .setTranslation(2.0, 0.0, 0.0) .setScale(2.0, 2.0, 2.0);
### Xoay bằng Quaternion
```java
import com.aspose.threed.Scene;
import com.aspose.threed.*;
import com.aspose.threed.*;
Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("q-rotated");
// 90 degrees rotation around the Y axis
double halfAngle = Math.toRadians(45); // half the total rotation
Quaternion q = new Quaternion(Math.cos(halfAngle), 0.0, Math.sin(halfAngle), 0.0);
node.getTransform().setRotation(q);
System.out.println("Euler: " + node.getTransform().getEulerAngles()); // synced automaticallyTỉ lệ và Vị trí cùng lúc
Scene scene = new Scene(); Node node = scene.getRootNode().createChildNode(“big-offset”);
node.getTransform() .setTranslation(10.0, 0.0, 0.0) .setScale(3.0, 3.0, 3.0) .setEulerAngles(0.0, 90.0, 0.0);
### Độ dịch hình học (Pivot Offset)
Các biến đổi hình học di chuyển hình học so với pivot của node mà không ảnh hưởng đến các node con; hữu ích để căn giữa một mesh trong node của nó:
Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("centered-mesh");
// Shift the mesh half a unit down so its base sits at y=0
node.getTransform().setGeometricTranslation(0.0, -0.5, 0.0);Đọc ma trận Transform kết hợp
Scene scene = new Scene(); Node node = scene.getRootNode().createChildNode(“m”); node.getTransform().setTranslation(1.0, 2.0, 3.0); node.getTransform().setEulerAngles(0.0, 45.0, 0.0);
Matrix4 m = node.getTransform().getTransformMatrix(); System.out.println(m.getClass().getName()); // com.aspose.threed.Matrix4
---
## Xem thêm
- [Tham chiếu lớp Node](/3d/java/node/)
- [Tham chiếu lớp GlobalTransform](/3d/java/global-transform/)
- [Tham chiếu lớp Scene](/3d/java/scene/)
- [Tham chiếu lớp Quaternion](/3d/java/quaternion/)
- [Tham chiếu lớp Matrix4](/3d/java/matrix4/)