Package com.ardor3d.extension.model.util
Class KeyframeController<T extends Spatial>
java.lang.Object
com.ardor3d.scenegraph.controller.ComplexSpatialController<T>
com.ardor3d.extension.model.util.KeyframeController<T>
- All Implemented Interfaces:
SpatialController<T>
,Savable
,Serializable
TODO: Revisit for better Ardor3D integration.
Started Date: Jun 12, 2004
Class can do linear interpolation of a Mesh between units of time. Similar to VertexKeyframeController but interpolates float units of time instead of integer key frames. setSpeed(float) sets a speed relative to the defined speed. For example, the default is 1. A speed of 2 would run twice as fast and a speed of .5 would run half as fast setMinTime(float) and setMaxTime(float) both define the bounds that KeyframeController should follow. It is the programmer's responsibility to make sure that the MinTime and MaxTime are within the span of the defined setKeyframe Controller functions RepeatType and isActive are both defined in their default way for KeyframeController When this controller is saved/loaded to XML format, it assumes that the mesh it morphs is the Mesh it belongs to, so it is recommended to only attach this controller to the Mesh it animates. (Based on work by Jack Lindamood, kevglass (parts), hevee (blend time), Julien Gouesse (port to Ardor3D))
Class can do linear interpolation of a Mesh between units of time. Similar to VertexKeyframeController but interpolates float units of time instead of integer key frames. setSpeed(float) sets a speed relative to the defined speed. For example, the default is 1. A speed of 2 would run twice as fast and a speed of .5 would run half as fast setMinTime(float) and setMaxTime(float) both define the bounds that KeyframeController should follow. It is the programmer's responsibility to make sure that the MinTime and MaxTime are within the span of the defined setKeyframe Controller functions RepeatType and isActive are both defined in their default way for KeyframeController When this controller is saved/loaded to XML format, it assumes that the mesh it morphs is the Mesh it belongs to, so it is recommended to only attach this controller to the Mesh it animates. (Based on work by Jack Lindamood, kevglass (parts), hevee (blend time), Julien Gouesse (port to Ardor3D))
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
This class defines a point in time that states _morphShape should look like _newShape at _time secondsNested classes/interfaces inherited from class com.ardor3d.scenegraph.controller.ComplexSpatialController
ComplexSpatialController.RepeatType
-
Field Summary
Modifier and TypeFieldDescriptionAn array of PointInTime s that defines the animation -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
Gets the currently set blending time for smooth animation transitionsClass
<? extends KeyframeController> int
double
double
Gets the current time in the animationboolean
boolean
Returns true if the model's bounding volume is being updated every frame.void
read
(InputCapsule capsule) void
setBlendTime
(float blendTime) If repeat type RT_WRAP is set, after reaching the last frame of the currently set animation maxTime (see Controller.setMaxTime), there will be an additional blendTime seconds long phase inserted, morphing from the last frame to the first.void
setCurTime
(double time) Sets the current time in the animationvoid
setInterpTex
(boolean interpTex) void
setKeyframe
(double time, Mesh shape) Tells the controller to change its morphMesh to shape at time seconds.void
setMorphingMesh
(Mesh morph) Sets the Mesh that will be physically changed by this KeyframeControllervoid
setNewAnimationTimes
(double newBeginTime, double newEndTime) Sets the new animation boundaries for this controller.void
setSmoothTranslation
(float newTimeToReach, float translationLen, float newBeginTime, float newEndTime) This function will do a smooth translation between a keframe's current look, to the look directly at newTimeToReach.void
setUpdateBounding
(boolean update) If true, the model's bounding volume will be updated every frame.void
shallowSetMorphMesh
(Mesh morph) void
As defined in Controllerprotected void
Updates the bounding volume of the morph meshvoid
write
(OutputCapsule capsule) Methods inherited from class com.ardor3d.scenegraph.controller.ComplexSpatialController
getControllerValues, getMaxTime, getMinTime, getRepeatType, getSpeed, isActive, isRepeatTypeClamp, isRepeatTypeCycle, isRepeatTypeWrap, setActive, setControllerValues, setMaxTime, setMinTime, setRepeatType, setSpeed
-
Field Details
-
_keyframes
An array of PointInTime s that defines the animation
-
-
Constructor Details
-
KeyframeController
public KeyframeController()Default constructor. Speed is 1, MinTime is 0 MaxTime is 0. Both MinTime and MaxTime are automatically adjusted by setKeyframe if the setKeyframe time is less than MinTime or greater than MaxTime. Default RepeatType is WRAP.
-
-
Method Details
-
getCurrentTime
public double getCurrentTime() -
getCurrentFrame
public int getCurrentFrame() -
getCurTime
public double getCurTime()Gets the current time in the animation- Returns:
- the current time in the animation
-
setCurTime
public void setCurTime(double time) Sets the current time in the animation- Parameters:
time
- The time this Controller should continue at
-
setMorphingMesh
Sets the Mesh that will be physically changed by this KeyframeController- Parameters:
morph
- The new mesh to morph
-
shallowSetMorphMesh
-
setKeyframe
Tells the controller to change its morphMesh to shape at time seconds. Time must be >=0 and shape must be non-null and shape must have the same number of vertexes as the current shape. If not, then nothing happens. It is also required that setMorphingMesh(Mesh) is called before setKeyframe. It is assumed that shape.indices == morphMesh.indices, otherwise morphing may look funny- Parameters:
time
- The time for the changeshape
- The new shape at that time
-
setSmoothTranslation
public void setSmoothTranslation(float newTimeToReach, float translationLen, float newBeginTime, float newEndTime) This function will do a smooth translation between a keframe's current look, to the look directly at newTimeToReach. It takes translationLen time (in seconds) to do that translation, and once translated will animate like normal between newBeginTime and newEndTime
This would be useful for example when a figure stops running and tries to raise an arm. Instead of "teleporting" to the raise-arm animation beginning, a smooth translation can occur.- Parameters:
newTimeToReach
- The time to reach.translationLen
- How long it takesnewBeginTime
- The new cycle beginning timenewEndTime
- The new cycle ending time.
-
setNewAnimationTimes
public void setNewAnimationTimes(double newBeginTime, double newEndTime) Sets the new animation boundaries for this controller. This will start at newBeginTime and proceed in the direction of newEndTime (either forwards or backwards). If both are the same, then the animation is set to their time and turned off, otherwise the animation is turned on to start the animation acording to the repeat type. If either BeginTime or EndTime are invalid times (less than 0 or greater than the maximum set keyframe time) then a warning is set and nothing happens.
It is suggested that this function be called if new animation boundaries need to be set, instead of setMinTime and setMaxTime directly.- Parameters:
newBeginTime
- The starting timenewEndTime
- The ending time
-
update
As defined in Controller- Specified by:
update
in interfaceSpatialController<T extends Spatial>
- Specified by:
update
in classComplexSpatialController<T extends Spatial>
- Parameters:
time
- as defined in Controllercaller
- The spatial currently executing this controller.
-
updateBounding
protected void updateBounding()Updates the bounding volume of the morph mesh -
setUpdateBounding
public void setUpdateBounding(boolean update) If true, the model's bounding volume will be updated every frame. If false, it will not.- Parameters:
update
- The new update model volume per frame value.
-
isUpdateBounding
public boolean isUpdateBounding()Returns true if the model's bounding volume is being updated every frame.- Returns:
- True if bounding volume is updating.
-
setInterpTex
public void setInterpTex(boolean interpTex) -
isInterpTex
public boolean isInterpTex() -
setBlendTime
public void setBlendTime(float blendTime) If repeat type RT_WRAP is set, after reaching the last frame of the currently set animation maxTime (see Controller.setMaxTime), there will be an additional blendTime seconds long phase inserted, morphing from the last frame to the first.- Parameters:
blendTime
- The blend time to set
-
getBlendTime
public float getBlendTime()Gets the currently set blending time for smooth animation transitions- Returns:
- The current blend time
- See Also:
-
getMorphMesh
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
- Overrides:
getClassTag
in classComplexSpatialController<T extends Spatial>
-
read
- Specified by:
read
in interfaceSavable
- Overrides:
read
in classComplexSpatialController<T extends Spatial>
- Throws:
IOException
-
write
- Specified by:
write
in interfaceSavable
- Overrides:
write
in classComplexSpatialController<T extends Spatial>
- Throws:
IOException
-