public class TransformBuilder
extends java.lang.Object
TransformBuilder is used to build transform matrix by a chain of transformations.
Example:
The following code shows how to create a matrix by a set of operation
TransformBuilder tb = new TransformBuilder();
tb.translate(10, 20, 0);
tb.scale(10, 10, 10);
tb.rotateEulerDegree(90, 0, 0);
System.out.printf("Transform Matrix: %s", tb.getMatrix());
| Constructor and Description |
|---|
TransformBuilder()
Construct a
TransformBuilder with initial identity transform matrix and specified compose order |
TransformBuilder(ComposeOrder order)
Construct a
TransformBuilder with initial identity transform matrix and specified compose order |
TransformBuilder(Matrix4 initial,
ComposeOrder order)
Construct a
TransformBuilder with initial transform matrix and specified compose order |
| Modifier and Type | Method and Description |
|---|---|
TransformBuilder |
append(Matrix4 m)
Append the new transform matrix to the transform chain.
|
void |
compose(Matrix4 m)
Append or prepend the argument to internal matrix.
|
ComposeOrder |
getComposeOrder()
Gets the chain compose order.
|
Matrix4 |
getMatrix()
Gets the current matrix value
|
TransformBuilder |
prepend(Matrix4 m)
Prepend the new transform matrix to the transform chain.
|
TransformBuilder |
rearrange(Axis newX,
Axis newY,
Axis newZ)
Rearrange the layout of the axis.
|
void |
reset()
Reset the transform to identity matrix
|
TransformBuilder |
rotate(Quaternion q)
Chain a rotation by a quaternion
Example:
|
TransformBuilder |
rotateDegree(double angle,
Vector3 axis)
Chain a rotation transform in degree
|
void |
rotateDegree(Vector3 rot,
RotationOrder order)
Append rotation with specified order
|
TransformBuilder |
rotateEulerDegree(double degX,
double degY,
double degZ)
Chain a rotation by Euler angles in degree
Example:
|
TransformBuilder |
rotateEulerRadian(double x,
double y,
double z)
Chain a rotation by Euler angles in radian
Example:
|
TransformBuilder |
rotateEulerRadian(Vector3 r)
Chain a rotation by Euler angles in radian
Example:
|
TransformBuilder |
rotateRadian(double angle,
Vector3 axis)
Chain a rotation transform in radian
|
void |
rotateRadian(Vector3 rot,
RotationOrder order)
Append rotation with specified order
|
TransformBuilder |
scale(double s)
Chain a scaling transform matrix with a component scaled by s
Example:
|
TransformBuilder |
scale(double x,
double y,
double z)
Chain a scaling transform matrix
Example:
|
TransformBuilder |
scale(Vector3 s)
Chain a scale transform
Example:
|
void |
setComposeOrder(ComposeOrder value)
Sets the chain compose order.
|
void |
setMatrix(Matrix4 value)
Sets the current matrix value
|
TransformBuilder |
translate(double tx,
double ty,
double tz)
Chain a translation transform
Example:
|
TransformBuilder |
translate(Vector3 v)
Chain a translation transform
Example:
|
public TransformBuilder(Matrix4 initial, ComposeOrder order)
TransformBuilder with initial transform matrix and specified compose orderpublic TransformBuilder(ComposeOrder order)
TransformBuilder with initial identity transform matrix and specified compose orderpublic TransformBuilder()
TransformBuilder with initial identity transform matrix and specified compose orderpublic Matrix4 getMatrix()
public void setMatrix(Matrix4 value)
value - New valuepublic ComposeOrder getComposeOrder()
public void setComposeOrder(ComposeOrder value)
value - New valuepublic void compose(Matrix4 m)
public TransformBuilder append(Matrix4 m)
public TransformBuilder prepend(Matrix4 m)
public TransformBuilder rearrange(Axis newX, Axis newY, Axis newZ)
newX - The new x component sourcenewY - The new y component sourcenewZ - The new z component sourcepublic TransformBuilder scale(double s)
TransformBuilder tb = new TransformBuilder();
tb.scale(10);
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder scale(double x, double y, double z)
TransformBuilder tb = new TransformBuilder();
tb.scale(10, 10, 10);
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder scale(Vector3 s)
TransformBuilder tb = new TransformBuilder();
tb.scale(new Vector3(10, 10, 10));
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder rotateDegree(double angle, Vector3 axis)
angle - The angle to rotate in degreeaxis - The axis to rotate
Example:
TransformBuilder tb = new TransformBuilder();
tb.rotateDegree(90, Vector3.getUnitY());
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder rotateRadian(double angle, Vector3 axis)
angle - The angle to rotate in radianaxis - The axis to rotate
Example:
TransformBuilder tb = new TransformBuilder();
tb.rotateRadian(Math.PI, Vector3.getUnitY());
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder rotate(Quaternion q)
TransformBuilder tb = new TransformBuilder();
tb.rotate(Quaternion.fromEulerAngle(0, Math.PI, 0));
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder rotateEulerDegree(double degX, double degY, double degZ)
TransformBuilder tb = new TransformBuilder();
tb.rotateEulerDegree(0, 90, 0);
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder rotateEulerRadian(double x, double y, double z)
TransformBuilder tb = new TransformBuilder();
tb.rotateEulerRadian(0, Math.PI, 0);
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder rotateEulerRadian(Vector3 r)
TransformBuilder tb = new TransformBuilder();
tb.rotateEulerRadian(new Vector3(0, Math.PI, 0));
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder translate(double tx, double ty, double tz)
TransformBuilder tb = new TransformBuilder();
tb.translate(0, 10, 0);
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public TransformBuilder translate(Vector3 v)
TransformBuilder tb = new TransformBuilder();
tb.translate(new Vector3(0, 10, 0));
System.out.printf("Transform Matrix: %s", tb.getMatrix());
public void reset()
public void rotateDegree(Vector3 rot, RotationOrder order)
rot - Rotation in degreespublic void rotateRadian(Vector3 rot, RotationOrder order)
rot - Rotation in radian
Example:
TransformBuilder tb = new TransformBuilder();
tb.rotateRadian(new Vector3(0.3, 0.4, 0.1), RotationOrder.YZX);
System.out.printf("Transform Matrix: %s", tb.getMatrix());