Transform

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

Transform controla la posición, orientación y escala de un Node en la escena 3D. Cada nodo tiene exactamente uno Transform, accedido a través de node.getTransform().

public class Transform extends A3DObject

Accediendo al Transform de un Nodo

import com.aspose.threed.Scene;

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

Methods

NameTypeAccessDescription
translationVector3ReadGets the translation.
scalingVector3ReadGets the scaling.
eulerAnglesVector3ReadGets the euler angles.
rotationQuaternionReadGets the rotation.
preRotationVector3ReadGets the pre rotation.
postRotationVector3ReadGets the post rotation.
geometricTranslationVector3ReadGets the geometric translation.
geometricScalingVector3ReadGets the geometric scaling.
geometricRotationVector3ReadGets the geometric rotation.
scalingOffsetVector3ReadGets the scaling offset.
scalingPivotVector3ReadGets the scaling pivot.
rotationOffsetVector3ReadGets the rotation offset.
rotationPivotVector3ReadGets the rotation pivot.
transformMatrixMatrix4ReadGets the transform matrix.
nameStringReadGets the name.
propertiesPropertyCollectionReadGets the properties.

Métodos Setter fluidos

Todos los setters devuelven this, habilitando encadenamiento:

SignatureDescription
Transform()Calls Transform on this Transform instance.
Transform(name: String)Calls Transform(name) on this Transform instance.
getTranslation()Vector3Returns the translation.
setTranslation(value: Vector3)Sets the translation value.
setTranslation(x: double, y: double, z: double)TransformSets the translation value.
getScaling()Vector3Returns the scaling.
setScaling(value: Vector3)Sets the scaling value.
setScale(x: double, y: double, z: double)TransformSets the scale value.
getEulerAngles()Vector3Returns the euler angles.
setEulerAngles(value: Vector3)Sets the euler angles value.
setEulerAngles(x: double, y: double, z: double)TransformSets the euler angles value.
getRotation()QuaternionReturns the rotation.
setRotation(value: Quaternion)Sets the rotation value.
setRotation(x: double, y: double, z: double, w: double)TransformSets the rotation value.
setPreRotation(x: double, y: double, z: double)TransformSets the pre rotation value.
getPreRotation()Vector3Returns the pre rotation.
setPreRotation(value: Vector3)Sets the pre rotation value.
setPostRotation(x: double, y: double, z: double)TransformSets the post rotation value.
getPostRotation()Vector3Returns the post rotation.
setPostRotation(value: Vector3)Sets the post rotation value.
getGeometricTranslation()Vector3Returns the geometric translation.
setGeometricTranslation(value: Vector3)Sets the geometric translation value.
setGeometricTranslation(x: double, y: double, z: double)TransformSets the geometric translation value.
getGeometricScaling()Vector3Returns the geometric scaling.
setGeometricScaling(value: Vector3)Sets the geometric scaling value.
setGeometricScaling(x: double, y: double, z: double)TransformSets the geometric scaling value.
getGeometricRotation()Vector3Returns the geometric rotation.
setGeometricRotation(value: Vector3)Sets the geometric rotation value.
setGeometricRotation(x: double, y: double, z: double)TransformSets the geometric rotation value.
getScalingOffset()Vector3Returns the scaling offset.
setScalingOffset(value: Vector3)Sets the scaling offset value.
getScalingPivot()Vector3Returns the scaling pivot.
setScalingPivot(value: Vector3)Sets the scaling pivot value.
getRotationOffset()Vector3Returns the rotation offset.
setRotationOffset(value: Vector3)Sets the rotation offset value.
getRotationPivot()Vector3Returns the rotation pivot.
setRotationPivot(value: Vector3)Sets the rotation pivot value.
getTransformMatrix()Matrix4Returns 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()StringThe segments of the curve.
setName(name: String)Constructs a CircleShape profile with specified radius.
getProperties()PropertyCollectionInitializes a new instance of Cylinder class.
findProperty(name: String)PropertyInitializes a new instance of the Bone class.
getProperty(name: String)ObjectGets the transform matrix of the node in current pose.
setProperty(name: String, value: Object)Gets the width segments.
removeProperty(name: String)booleanGets flip coordinate system of control points/normal during importing/exporting.

Ejemplos de uso

Posicionar un Nodo

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

Rotar con ángulos de 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);


### Rotar con un 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 automatically

Escalar y posicionar juntos

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


### Desplazamiento geométrico (Desplazamiento del pivote)

Las transformaciones geométricas desplazan la geometría respecto al pivote del nodo sin afectar a los nodos hijos; es útil para centrar una malla dentro de su nodo:



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

Leer la matriz de Transformación combinada

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


---

## Ver también

- [Referencia de la clase Node](/3d/java/node/)
- [Referencia de la clase GlobalTransform](/3d/java/global-transform/)
- [Referencia de la clase Scene](/3d/java/scene/)
- [Referencia de la clase Quaternion](/3d/java/quaternion/)
- [Referencia de la clase Matrix4](/3d/java/matrix4/)
 Español