Transform

Methods: aspose.threed (aspose-3d-foss)

Transform 位置、向き、スケールを制御します Node 3Dシーン内で。すべてのノードは正確に1つの Transform,、次によってアクセスされます node.transform.

class Transform(A3DObject):

ノードの Transform へのアクセス

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("box")
t = node.transform     # Transform object

Methods

MethodsMethodsMethods
translationVector3親ノードの原点からの位置オフセット。デフォルト Vector3(0, 0, 0).
scalingVector3軸ごとの非均一スケール係数。デフォルト Vector3(1, 1, 1).
rotationQuaternion単位クォータニオンとしての回転。これを設定すると、同時に更新されます euler_angles.
euler_anglesVector3回転を度数で (X, Y, Z) のオイラー角として表現。これを設定すると、同時に更新されます rotation.
pre_rotationVector3メイン回転の前に適用されるオイラー角(FBXリグで使用)。.
post_rotationVector3メイン回転の後に適用されるオイラー角。.
geometric_translationVector3ローカルのみの平行移動:ジオメトリには影響しますが、子ノードには影響しません。.
geometric_scalingVector3ローカルのみのスケール: ジオメトリに影響しますが、子ノードには影響しません。.
geometric_rotationVector3ローカルのみの回転: ジオメトリに影響しますが、子ノードには影響しません。.
transform_matrixMatrix4完全に結合された4×4変換行列です。キャッシュされ、任意のコンポーネントが変更されると再計算されます。これを設定すると、平行移動/スケーリング/回転に分解されます。.

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

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

MethodsMethodsMethods
set_translation(tx, ty, tz)float, float, float位置を設定します。.
set_scale(sx, sy, sz)float, float, floatスケールを設定します。.
set_euler_angles(rx, ry, rz)float, float, float回転を度単位で設定します。.
set_rotation(rw, rx, ry, rz)float, float, float, float回転をクォータニオン (w, x, y, z) として設定します。.
set_pre_rotation(rx, ry, rz)float, float, float事前回転を度単位で設定します。.
set_post_rotation(rx, ry, rz)float, float, float事後回転を度単位で設定します。.
set_geometric_translation(x, y, z)float, float, float幾何学的平行移動を設定。.
set_geometric_scaling(sx, sy, sz)float, float, float幾何学的スケールを設定。.
set_geometric_rotation(rx, ry, rz)float, float, float幾何学的回転を度で設定。.

使用例

ノードの位置設定

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("box")

# Using fluent setters
node.transform.set_translation(5.0, 0.0, -3.0)

# Or via property assignment
from aspose.threed.utilities import Vector3
node.transform.translation = Vector3(5.0, 0.0, -3.0)

オイラー角で回転

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("rotated")

# Rotate 45° around Y axis
node.transform.set_euler_angles(0.0, 45.0, 0.0)

# Chain multiple operations
node.transform.set_translation(2.0, 0.0, 0.0).set_scale(2.0, 2.0, 2.0)

クォータニオンで回転

from aspose.threed import Scene
from aspose.threed.utilities import Quaternion, Vector3
import math

scene = Scene()
node = scene.root_node.create_child_node("q-rotated")

# 90° rotation around the Y axis
half_angle = math.radians(45)   # half the total rotation
q = Quaternion(math.cos(half_angle), 0.0, math.sin(half_angle), 0.0)
node.transform.rotation = q

print(f"Euler: {node.transform.euler_angles}")   # synced automatically

スケールと位置を同時に設定

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("big-offset")

(node.transform
    .set_translation(10.0, 0.0, 0.0)
    .set_scale(3.0, 3.0, 3.0)
    .set_euler_angles(0.0, 90.0, 0.0))

ジオメトリ的オフセット(ピボットオフセット)

ジオメトリ変換は、子ノードに影響を与えずにノードのピボットに対してジオメトリをシフトします。メッシュをノード内で中央に配置するのに便利です:

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("centered-mesh")

# Shift the mesh half a unit down so its base sits at y=0
node.transform.set_geometric_translation(0.0, -0.5, 0.0)

結合された Transform 行列を取得

from aspose.threed import Scene

scene = Scene()
node = scene.root_node.create_child_node("m")
node.transform.set_translation(1.0, 2.0, 3.0).set_euler_angles(0.0, 45.0, 0.0)

m = node.transform.transform_matrix
print(type(m))  # <class 'aspose.threed.utilities.Matrix4'>

関連項目

 日本語