Transform — Aspose.3D FOSS for Java

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

Transform kontroluje pozycję, orientację i skalę a Node w scenie 3D. Każdy węzeł ma dokładnie jeden Transform, dostępny poprzez node.getTransform().

public class Transform extends A3DObject

Dostęp do Transformacji węzła

import com.aspose.threed.Scene;

Scene scene = new Scene();
Node node = scene.getRootNode().createChildNode("box");
Transform t = node.getTransform();

Enumerations

EnumerationsEnumerationsEnumerationsEnumerationsEnumerations
translationVector3getTranslation()setTranslation(Vector3)Przesunięcie pozycji względem początku węzła nadrzędnego. Domyślnie Vector3(0, 0, 0).
scalingVector3getScaling()setScaling(Vector3)Niejednorodny współczynnik skali dla każdej osi. Domyślnie Vector3(1, 1, 1).
rotationQuaterniongetRotation()setRotation(Quaternion)Rotacja jako jednostkowy kwaternion. Ustawienie tego również aktualizuje kąty Eulera.
eulerAnglesVector3getEulerAngles()setEulerAngles(Vector3)Rotacja w stopniach jako (X, Y, Z) kąty Eulera. Ustawienie tego również aktualizuje rotację kwaternionową.
preRotationVector3getPreRotation()setPreRotation(Vector3)Kąty Eulera stosowane przed główną rotacją (używane w rigach FBX).
postRotationVector3getPostRotation()setPostRotation(Vector3)Kąty Eulera stosowane po głównej rotacji.
geometricTranslationVector3getGeometricTranslation()setGeometricTranslation(Vector3)Tłumaczenie tylko lokalne: wpływa na geometrię, ale nie na węzły potomne.
geometricScalingVector3getGeometricScaling()setGeometricScaling(Vector3)Skalowanie tylko lokalne: wpływa na geometrię, ale nie na węzły potomne.
geometricRotationVector3getGeometricRotation()setGeometricRotation(Vector3)Obrót tylko lokalny: wpływa na geometrię, ale nie na węzły potomne.
transformMatrixMatrix4getTransformMatrix()setTransformMatrix(Matrix4)Pełna połączona macierz transformacji 4x4. Buforowana; przeliczana ponownie, gdy zmieni się którykolwiek komponent. Ustawienie jej powoduje dekompozycję z powrotem do translacji/skali/obrotu.

Metody ustawiające w stylu fluent

Wszystkie settery zwracają this, umożliwiając łańcuchowanie:

EnumerationsEnumerationsEnumerations
setTranslation(double tx, double ty, double tz)double, double, doubleUstaw pozycję.
setScale(double sx, double sy, double sz)double, double, doubleUstaw skalę.
setEulerAngles(double rx, double ry, double rz)double, double, doubleUstaw obrót w stopniach.
setRotation(double rx, double ry, double rz, double rw)double, double, double, doubleUstaw obrót jako kwaternion (x, y, z, w).
setPreRotation(double rx, double ry, double rz)double, double, doubleUstaw pre-rotation w stopniach.
setPostRotation(double rx, double ry, double rz)double, double, doubleUstaw post-rotation w stopniach.
setGeometricTranslation(double x, double y, double z)double, double, doubleUstaw przesunięcie geometryczne.
setGeometricScaling(double sx, double sy, double sz)double, double, doubleUstaw skalę geometryczną.
setGeometricRotation(double rx, double ry, double rz)double, double, doubleUstaw obrót geometryczny w stopniach.

Przykład użycia

Ustaw pozycję węzła

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));

Obróć przy użyciu kątów Eulera

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);

Obróć przy użyciu kwaternionu

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

Skaluj i pozycjonuj jednocześnie

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);

Przesunięcie geometryczne (przesunięcie pivotu)

Transformacje geometryczne przesuwają geometrię względem pivotu węzła, nie wpływając na węzły potomne; przydatne do wyśrodkowania siatki w jej węźle:

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);

Odczytaj połączoną macierz transformacji

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

Zobacz także

 Polski