Package com.jme3.math
Class Transform
java.lang.Object
com.jme3.math.Transform
- All Implemented Interfaces:
Serializable
,Cloneable
A 3-D coordinate transform composed of translation, rotation, and scaling.
The order of application is: scale, then rotate, then translate.
Started July 16, 2004
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionInstantiates an identity transform: no translation, no rotation, and no scaling.Transform
(Vector3f translation, Quaternion rot) Instantiates a coordinate transform without scaling.Transform
(Vector3f translation, Quaternion rot, Vector3f scale) Instantiates a coordinate transform with scaling. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a copy.boolean
Tests for exact equality with the argument, distinguishing -0 from 0.void
Sets the current instance from a transform matrix.Returns the rotation component.getScale()
Returns the scaling component.Returns the translation component.int
hashCode()
Returns a hash code.invert()
Returns the inverse.void
Sets the current instance to the identity transform: translation=(0,0,0) scaling=(1,1,1) rotation=(0,0,0,1).setRotation
(Quaternion rot) Sets the rotation component to the argument.setScale
(float scale) Sets the scaling component to the argument.Sets the scaling component to the argument.setTranslation
(Vector3f trans) Sets the translation component to the argument.toString()
Returns a string representation of the transform, which is unaffected.Creates an equivalent transform matrix.toTransformMatrix
(Matrix4f store) Converts to an equivalent transform matrix.
-
Field Details
-
IDENTITY
Shared instance of the identity transform. Do not modify!
-
-
Constructor Details
-
Transform
Instantiates a coordinate transform without scaling.- Parameters:
translation
- the desired translation (not null, unaffected)rot
- the desired rotation (not null, unaffected)
-
Transform
Instantiates a coordinate transform with scaling.- Parameters:
translation
- the desired translation (not null, unaffected)rot
- the desired rotation (not null, unaffected)scale
- the desired scaling (not null, unaffected)
-
Transform
public Transform()Instantiates an identity transform: no translation, no rotation, and no scaling.
-
-
Method Details
-
setRotation
Sets the rotation component to the argument.- Parameters:
rot
- the desired rotation value (not null, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
setTranslation
Sets the translation component to the argument.- Parameters:
trans
- the desired offsets (not null, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
getTranslation
Returns the translation component.- Returns:
- the pre-existing instance (not null)
-
setScale
Sets the scaling component to the argument.- Parameters:
scale
- the desired scale factors (not null, unaffected)- Returns:
- the (modified) current instance (for chaining)
-
setScale
Sets the scaling component to the argument. This yields uniform scaling.- Parameters:
scale
- the desired scale factor for all local axes- Returns:
- the (modified) current instance (for chaining)
-
getScale
Returns the scaling component.- Returns:
- the pre-existing instance (not null)
-
getRotation
Returns the rotation component.- Returns:
- the pre-existing instance (not null)
-
toTransformMatrix
Creates an equivalent transform matrix. The current instance is unaffected.- Returns:
- a new Matrix4f
-
toTransformMatrix
Converts to an equivalent transform matrix. The current instance is unaffected.- Parameters:
store
- storage for the result (modified if not null)- Returns:
- a transform matrix (either
store
or a new Matrix4f)
-
fromTransformMatrix
Sets the current instance from a transform matrix. Any reflection or shear in the matrix is lost -- in other words, it may not be possible to recreate the original matrix from the result.After this method is invoked, all components of
scale
will be non-negative, even ifmat
includes reflection.- Parameters:
mat
- the input matrix (not null, unaffected)
-
invert
Returns the inverse. The current instance is unaffected.Assumes (but does not verify) that the scale factors are all positive. If any component of
scale
is negative or zero, the result is undefined.- Returns:
- a new Transform
-
loadIdentity
public void loadIdentity()Sets the current instance to the identity transform: translation=(0,0,0) scaling=(1,1,1) rotation=(0,0,0,1). -
hashCode
public int hashCode()Returns a hash code. If two transforms have identical values, they will have the same hash code. The current instance is unaffected. -
equals
Tests for exact equality with the argument, distinguishing -0 from 0. Ifobj
is null, false is returned. Either way, the current instance is unaffected. -
toString
Returns a string representation of the transform, which is unaffected. For example, the identity transform is represented by:Transform[ 0.0, 0.0, 0.0] [ 0.0, 0.0, 0.0, 1.0] [ 1.0 , 1.0, 1.0]
-
clone
Creates a copy. The current instance is unaffected.
-