public final class Transform extends java.lang.Object implements Savable, java.lang.Cloneable, java.io.Serializable
Started July 16, 2004
Modifier and Type | Field and Description |
---|---|
static Transform |
IDENTITY
Shared instance of the identity transform.
|
Constructor and Description |
---|
Transform()
Instantiates an identity transform: no translation, no rotation, and no
scaling.
|
Transform(Quaternion rot)
Instantiates a rotation-only transform.
|
Transform(Vector3f translation)
Instantiates a translation-only transform.
|
Transform(Vector3f translation,
Quaternion rot)
Instantiates a coordinate transform without scaling.
|
Transform(Vector3f translation,
Quaternion rot,
Vector3f scale)
Instantiates a coordinate transform with scaling.
|
Modifier and Type | Method and Description |
---|---|
Transform |
clone()
Creates a copy.
|
Transform |
combineWithParent(Transform parent)
Combines with the argument and returns the (modified) current instance.
|
boolean |
equals(java.lang.Object obj)
Tests for exact equality with the argument, distinguishing -0 from 0.
|
void |
fromTransformMatrix(Matrix4f mat)
Sets the current instance from a transform matrix.
|
Quaternion |
getRotation()
Returns the rotation component.
|
Quaternion |
getRotation(Quaternion quat)
Copies the rotation component to the argument.
|
Vector3f |
getScale()
Returns the scaling component.
|
Vector3f |
getScale(Vector3f scale)
Copies the scaling component to the argument.
|
Vector3f |
getTranslation()
Returns the translation component.
|
Vector3f |
getTranslation(Vector3f trans)
Copies the translation component to the argument.
|
int |
hashCode()
Returns a hash code.
|
void |
interpolateTransforms(Transform t1,
Transform t2,
float delta)
Interpolates quickly between the specified transforms, using
Quaternion.nlerp(com.jme3.math.Quaternion, float) and
Vector3f.interpolateLocal(com.jme3.math.Vector3f, com.jme3.math.Vector3f, float) . |
Transform |
invert()
Returns the inverse.
|
boolean |
isIdentity()
Tests for exact identity.
|
void |
loadIdentity()
Sets the current instance to the identity transform: translation=(0,0,0)
scaling=(1,1,1) rotation=(0,0,0,1).
|
void |
read(JmeImporter e)
De-serializes from the argument, for example when loading from a J3O
file.
|
Transform |
set(Transform matrixQuat)
Copies all 3 components from the argument.
|
Transform |
setRotation(Quaternion rot)
Sets the rotation component to the argument.
|
Transform |
setScale(float scale)
Sets the scaling component to the argument.
|
Transform |
setScale(float x,
float y,
float z)
Sets the scaling component to the specified values.
|
Transform |
setScale(Vector3f scale)
Sets the scaling component to the argument.
|
Transform |
setTranslation(float x,
float y,
float z)
Sets the translation component to the specified values.
|
Transform |
setTranslation(Vector3f trans)
Sets the translation component to the argument.
|
java.lang.String |
toString()
Returns a string representation.
|
Matrix4f |
toTransformMatrix()
Creates an equivalent transform matrix.
|
Matrix4f |
toTransformMatrix(Matrix4f store)
Converts to an equivalent transform matrix.
|
Vector3f |
transformInverseVector(Vector3f in,
Vector3f store)
Applies the inverse transform to the specified coordinates and returns
the result in
store . |
Vector3f |
transformVector(Vector3f in,
Vector3f store)
Transforms the specified coordinates and returns the result in
store . |
void |
write(JmeExporter e)
Serializes to the argument, for example when saving to a J3O file.
|
public static final Transform IDENTITY
public Transform(Vector3f translation, Quaternion rot)
translation
- the desired translation (not null, unaffected)rot
- the desired rotation (not null, unaffected)public Transform(Vector3f translation, Quaternion rot, Vector3f scale)
translation
- the desired translation (not null, unaffected)rot
- the desired rotation (not null, unaffected)scale
- the desired scaling (not null, unaffected)public Transform(Vector3f translation)
translation
- the desired translation (not null, unaffected)public Transform(Quaternion rot)
rot
- the desired rotation (not null, unaffected)public Transform()
public Transform setRotation(Quaternion rot)
rot
- the desired rotation value (not null, unaffected)public Transform setTranslation(Vector3f trans)
trans
- the desired offsets (not null, unaffected)public Vector3f getTranslation()
public Transform setScale(Vector3f scale)
scale
- the desired scale factors (not null, unaffected)public Transform setScale(float scale)
scale
- the desired scale factor for all local axespublic Vector3f getScale()
public Vector3f getTranslation(Vector3f trans)
trans
- storage for the result (modified if not null)trans
or a new
Vector3f)public Quaternion getRotation(Quaternion quat)
quat
- storage for the result (modified if not null)quat
or a new Quaternion)public Quaternion getRotation()
public Vector3f getScale(Vector3f scale)
scale
- storage for the result (modified if not null)scale
or a new Vector3f)public void interpolateTransforms(Transform t1, Transform t2, float delta)
Quaternion.nlerp(com.jme3.math.Quaternion, float)
and
Vector3f.interpolateLocal(com.jme3.math.Vector3f, com.jme3.math.Vector3f, float)
.t1
- the desired value when delta
=0 (not null,
unaffected unless it's this
)t2
- the desired value when delta
=1 (not null,
unaffected unless it's this
)delta
- the fractional change amountpublic Transform combineWithParent(Transform parent)
parent
- the parent transform (not null, unaffected unless it's
this
)public Transform setTranslation(float x, float y, float z)
x
- the desired X offsety
- the desired Y offsetz
- the desired Z offsetpublic Transform setScale(float x, float y, float z)
x
- the desired X scale factory
- the desired Y scale factorz
- the desired Z scale factorpublic Vector3f transformVector(Vector3f in, Vector3f store)
store
. If the store
is null, a new Vector3f is
created to hold the value. Either way, the current instance is
unaffected, unless store
is its translation or scaling.in
- the coordinates to transform (not null, unaffected)store
- storage for the result (modified if not null)store
or a new
Vector3f)public Vector3f transformInverseVector(Vector3f in, Vector3f store)
store
. If the store
is null, a
new Vector3f is created to hold the value. Either way, the current
instance is unaffected, unless store
is its translation or
scaling.in
- the coordinates to transform (not null, unaffected unless it's
store
)store
- storage for the result (modified if not null)store
or a new
Vector3f)public Matrix4f toTransformMatrix()
public Matrix4f toTransformMatrix(Matrix4f store)
store
- storage for the result (modified if not null)store
or a new Matrix4f)public void fromTransformMatrix(Matrix4f mat)
mat
- the input matrix (not null, unaffected)public Transform invert()
public void loadIdentity()
public boolean isIdentity()
IDENTITY
, otherwise falsepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare to (may be null, unaffected)public java.lang.String toString()
toString
in class java.lang.Object
public Transform set(Transform matrixQuat)
matrixQuat
- The Transform to copy (not null, unaffected)public void write(JmeExporter e) throws java.io.IOException
public void read(JmeImporter e) throws java.io.IOException
public Transform clone()
clone
in class java.lang.Object