Package com.jme3.anim.tween
Class AbstractTween
java.lang.Object
com.jme3.anim.tween.AbstractTween
- All Implemented Interfaces:
Tween
,JmeCloneable
,Cloneable
Base implementation of the Tween interface that provides
default implementations of the getLength() and interpolate()
methods that provide common tween clamping and bounds checking.
Subclasses need only override the doInterpolate() method and
the rest is handled for them.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneFields
(Cloner cloner, Object original) Callback fromCloner
to convert this shallow-cloned tween into a deep-cloned one, using the specified cloner and original to resolve copied fields.protected abstract void
doInterpolate
(double t) double
Returns the length of the tween.boolean
interpolate
(double t) Default implementation clamps the time value, converts it to 0 to 1.0 based on getLength(), and calls doInterpolate().jmeClone()
Create a shallow clone for the JME cloner.void
setLength
(double length)
-
Constructor Details
-
AbstractTween
protected AbstractTween(double length)
-
-
Method Details
-
getLength
public double getLength()Description copied from interface:Tween
Returns the length of the tween. If 't' represents time in seconds then this is the notional time in seconds that the tween will run. Note: all the caveats are because tweens may be externally scaled in such a way that 't' no longer represents actual time. -
setLength
public void setLength(double length) -
interpolate
public boolean interpolate(double t) Default implementation clamps the time value, converts it to 0 to 1.0 based on getLength(), and calls doInterpolate().- Specified by:
interpolate
in interfaceTween
- Parameters:
t
- animation time (in de-scaled seconds)- Returns:
- true if t>length(), otherwise false
-
doInterpolate
protected abstract void doInterpolate(double t) -
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClone
in interfaceJmeCloneable
- Returns:
- a new tween (not null)
-
cloneFields
Callback fromCloner
to convert this shallow-cloned tween into a deep-cloned one, using the specified cloner and original to resolve copied fields.- Specified by:
cloneFields
in interfaceJmeCloneable
- Parameters:
cloner
- the cloner that's cloning this tween (not null)original
- the tween from which this tween was shallow-cloned (unused)
-