Transform — Aspose.3D FOSS for Java

Example: com.aspose.threed (aspose-3d-foss)

Transform 位置、向き、スケールを制御します Node 3Dシーン内で。すべてのノードは正確に1つの 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

ExampleExampleExampleExampleExample
translationVector3getTranslation()setTranslation(Vector3)親ノードの原点からの位置オフセット。デフォルト Vector3(0, 0, 0).
scalingVector3getScaling()setScaling(Vector3)軸ごとの非一様スケール係数。デフォルト Vector3(1, 1, 1).
rotationQuaterniongetRotation()setRotation(Quaternion)単位クォータニオンとしての回転。これを設定するとオイラー角も更新されます。.
eulerAnglesVector3getEulerAngles()setEulerAngles(Vector3)(X, Y, Z)オイラー角としての回転(度単位)。これを設定するとクォータニオン回転も更新されます。.
preRotationVector3getPreRotation()setPreRotation(Vector3)メイン回転の前に適用されるオイラー角(FBXリグで使用)。.
postRotationVector3getPostRotation()setPostRotation(Vector3)メイン回転の後に適用されるオイラー角。.
geometricTranslationVector3getGeometricTranslation()setGeometricTranslation(Vector3)ローカルのみの平行移動:ジオメトリには影響しますが、子ノードには影響しません。.
geometricScalingVector3getGeometricScaling()setGeometricScaling(Vector3)ローカル専用スケール: ジオメトリに影響しますが、子ノードには影響しません。.
geometricRotationVector3getGeometricRotation()setGeometricRotation(Vector3)ローカル専用回転: ジオメトリに影響しますが、子ノードには影響しません。.
transformMatrixMatrix4getTransformMatrix()setTransformMatrix(Matrix4)完全に結合された4x4変換行列です。キャッシュされ、任意のコンポーネントが変更されると再計算されます。これを設定すると、平行移動/スケーリング/回転に分解されます。.

フルエント セッター メソッド

すべてのセッターは返します this,、チェーンを可能にします:

ExampleExampleExample
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

参照

 日本語