E
- The extent containing the transformpublic interface Transform<E extends Extent>
Entity
. Comprised of
a Location
and two Vector3d
representing the rotation
and the scale. The implementation may internally use a location or a
separate extent and position. Be wary that calling getLocation()
could result in object creation.
A transform might not have an extent if it is invalid. In this case
all methods which return a reference to it will throw
IllegalStateException
.
This is an entity transform, not a model one. These values are subject to interpretation by the implementation and may trigger animations depending on the target model.
Even though Minecraft doesn't currently support entity scales
it is part of the transform in case it gets added later. For now
this return Vector3d.ONE
.
Modifier and Type | Interface and Description |
---|---|
static interface |
Transform.Builder<E extends Extent>
A builder for transforms.
|
Modifier and Type | Method and Description |
---|---|
Transform<E> |
add(Transform<E> other)
"Adds" another transform to this one.
|
Transform<E> |
addRotation(com.flowpowered.math.imaginary.Quaterniond rotation)
Adds a rotation to this transform.
|
Transform<E> |
addRotation(com.flowpowered.math.vector.Vector3d rotation)
Adds a rotation to this transform.
|
Transform<E> |
addScale(com.flowpowered.math.vector.Vector3d scale)
"Adds" a scale to this transform.
|
Transform<E> |
addTranslation(com.flowpowered.math.vector.Vector3d translation)
Adds a translation to this transform.
|
E |
getExtent()
Gets the
Extent this transform contains. |
Location<E> |
getLocation()
Gets the
Location this transform contains. |
double |
getPitch()
Gets the pitch component of this transform rotation
|
com.flowpowered.math.vector.Vector3d |
getPosition()
Gets the coordinates of this transform.
|
double |
getRoll()
Gets the roll component of this transform rotation
|
com.flowpowered.math.vector.Vector3d |
getRotation()
Gets the rotation of this transform, as a
Vector3d . |
com.flowpowered.math.imaginary.Quaterniond |
getRotationAsQuaternion()
Returns the rotation as a quaternion.
|
com.flowpowered.math.vector.Vector3d |
getScale()
Gets the scale of the transform for each axis.
|
double |
getYaw()
Gets the yaw component of this transform rotation
|
boolean |
isValid()
Returns if this
Transform is still valid. |
Transform<E> |
setExtent(E extent)
Creates a copy of this transform and sets the
Extent . |
Transform<E> |
setLocation(Location<E> location)
Creates a copy of this transform and sets the
Location . |
Transform<E> |
setPosition(com.flowpowered.math.vector.Vector3d position)
Creates a copy of this transform while setting the position of the new one.
|
Transform<E> |
setRotation(com.flowpowered.math.imaginary.Quaterniond rotation)
Creates a copy of this transform and sets the rotation as
a quaternion.
|
Transform<E> |
setRotation(com.flowpowered.math.vector.Vector3d rotation)
Creates a copy of this transform and sets the rotation.
|
Transform<E> |
setScale(com.flowpowered.math.vector.Vector3d scale)
Creates a copy of this transform and sets the scale for
each axis.
|
com.flowpowered.math.matrix.Matrix4d |
toMatrix()
Returns a matrix representation of this transform.
|
Location<E> getLocation()
Location
this transform contains.
This is the position and the extent.IllegalStateException
- If the transform doesn't have an extentTransform<E> setLocation(Location<E> location)
Location
.
This sets both the position and the extent.location
- The new locationE getExtent()
Extent
this transform contains.
Note: This can be null if the Extent
is unloaded and garbage
collected.
IllegalStateException
- If the transform doesn't have an extentTransform<E> setExtent(E extent)
Extent
.extent
- The new extentcom.flowpowered.math.vector.Vector3d getPosition()
Transform<E> setPosition(com.flowpowered.math.vector.Vector3d position)
position
- The positioncom.flowpowered.math.vector.Vector3d getRotation()
Vector3d
.
The format of the rotation is represented by:
x -> pitch
y -> yaw
z -> roll
Transform<E> setRotation(com.flowpowered.math.vector.Vector3d rotation)
The format of the rotation is represented by:
x -> pitch
y -> yaw
z -> roll
rotation
- The new rotationcom.flowpowered.math.imaginary.Quaterniond getRotationAsQuaternion()
Transform<E> setRotation(com.flowpowered.math.imaginary.Quaterniond rotation)
rotation
- The new rotationdouble getPitch()
double getYaw()
double getRoll()
com.flowpowered.math.vector.Vector3d getScale()
Transform<E> setScale(com.flowpowered.math.vector.Vector3d scale)
scale
- The scaleTransform<E> add(Transform<E> other)
other
- The transform to addTransform<E> addTranslation(com.flowpowered.math.vector.Vector3d translation)
translation
- The translation to addTransform<E> addRotation(com.flowpowered.math.vector.Vector3d rotation)
rotation
- The rotation to addTransform<E> addRotation(com.flowpowered.math.imaginary.Quaterniond rotation)
rotation
- The rotation to addTransform<E> addScale(com.flowpowered.math.vector.Vector3d scale)
scale
- The scale to addcom.flowpowered.math.matrix.Matrix4d toMatrix()
Vector3d original = ...;
Transform transform = ...;
Vector3d transformed = transform.toMatrix().transform(original.toVector4(1)).toVector3();
This converts the original 3D vector to 4D by appending 1 as the w coordinate, applies the transformation, then converts it back to 3D by dropping the w coordinate.
Using a 4D matrix and a w coordinate with value 1 is what allows for the position to be included in the transformation applied by the matrix.