Transform — Aspose.3D FOSS for Java
Example: com.aspose.threed (aspose-3d-foss)
Transform 위치, 방향 및 스케일을 제어합니다 a Node 3D 씬에서. 모든 노드는 정확히 하나의 Transform, 에 접근합니다 node.getTransform().
public class Transform extends A3DObject노드의 Transform에 접근하기
import com.aspose.threed.Scene;
Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("box");
Transform t = node.getTransform();Example
| Example | Example | Example | Example | Example |
|---|---|---|---|---|
translation | Vector3 | getTranslation() | setTranslation(Vector3) | 부모 노드 원점으로부터의 위치 오프셋. 기본값 Vector3(0, 0, 0). |
scaling | Vector3 | getScaling() | setScaling(Vector3) | 축별 비균일 스케일 팩터. 기본값 Vector3(1, 1, 1). |
rotation | Quaternion | getRotation() | setRotation(Quaternion) | 단위 쿼터니언으로 회전. 이를 설정하면 오일러 각도도 업데이트됩니다. |
eulerAngles | Vector3 | getEulerAngles() | setEulerAngles(Vector3) | 회전을 (X, Y, Z) 오일러 각도로 도(degree) 표시. 이를 설정하면 쿼터니언 회전도 업데이트됩니다. |
preRotation | Vector3 | getPreRotation() | setPreRotation(Vector3) | 주 회전 전에 적용되는 오일러 각도 (FBX 리그에서 사용). |
postRotation | Vector3 | getPostRotation() | setPostRotation(Vector3) | 주 회전 후에 적용되는 오일러 각도. |
geometricTranslation | Vector3 | getGeometricTranslation() | setGeometricTranslation(Vector3) | 로컬 전용 변환: 기하학에 영향을 주지만 자식 노드에는 영향을 주지 않습니다. |
geometricScaling | Vector3 | getGeometricScaling() | setGeometricScaling(Vector3) | 로컬 전용 스케일: 기하학에 영향을 주지만 자식 노드에는 영향을 주지 않습니다. |
geometricRotation | Vector3 | getGeometricRotation() | setGeometricRotation(Vector3) | 로컬 전용 회전: 기하학에 영향을 주지만 자식 노드에는 영향을 주지 않습니다. |
transformMatrix | Matrix4 | getTransformMatrix() | setTransformMatrix(Matrix4) | 전체 결합된 4x4 변환 행렬. 캐시됨; 구성 요소가 변경될 때마다 다시 계산됩니다. 이를 설정하면 변환/스케일/회전으로 다시 분해됩니다. |
플루언트 세터 메서드
모든 setter는 반환합니다 this, 체이닝을 가능하게 합니다:
| Example | Example | Example |
|---|---|---|
setTranslation(double tx, double ty, double tz) | double, double, double | 위치를 설정합니다. |
setScale(double sx, double sy, double sz) | double, double, double | 스케일을 설정합니다. |
setEulerAngles(double rx, double ry, double rz) | double, double, double | 회전을 도 단위로 설정합니다. |
setRotation(double rx, double ry, double rz, double rw) | double, double, double, double | 회전을 쿼터니언(x, y, z, w)으로 설정합니다. |
setPreRotation(double rx, double ry, double rz) | double, double, double | 전 회전을 도 단위로 설정합니다. |
setPostRotation(double rx, double ry, double rz) | double, double, double | 후 회전을 도 단위로 설정합니다. |
setGeometricTranslation(double x, double y, double z) | double, double, double | 기하학적 변환을 설정합니다. |
setGeometricScaling(double sx, double sy, double sz) | double, double, double | 기하학적 배율을 설정합니다. |
setGeometricRotation(double rx, double ry, double rz) | double, double, double | 기하학적 회전을 도 단위로 설정합니다. |
사용 예시
노드 위치 지정
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));오일러 각을 사용한 회전
import com.aspose.threed.Scene;
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);쿼터니언을 사용한 회전
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 automatically스케일과 위치를 동시에 적용
import com.aspose.threed.Scene;
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);기하학적 오프셋 (피벗 오프셋)
기하학적 변환은 자식 노드에 영향을 주지 않고 노드의 피벗을 기준으로 기하학을 이동시킵니다; 메시를 노드 내에서 중앙에 배치할 때 유용합니다:
import com.aspose.threed.Scene;
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);결합된 Transform 행렬 읽기
import com.aspose.threed.Scene;
import com.aspose.threed.*;
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