public class AnimatedGroup extends Object implements Serializable, Iterable<Animated3D>, Cloneable
Animated3D
's and manipulate them easily.Modifier and Type | Field and Description |
---|---|
static boolean |
MESH_DONT_REUSE
Use a separate mesh.
|
static boolean |
MESH_REUSE
Re-use (share) the mesh.
|
Constructor and Description |
---|
AnimatedGroup(Animated3D... objects)
Creates a new AnimatedGroup out of given objects.
|
Modifier and Type | Method and Description |
---|---|
void |
addToWorld(World world)
Adds all animated objects to world.
|
void |
animatePose(float index,
int sequence)
Same as
animatePose(float, int, 1) |
void |
animatePose(float index,
int sequence,
float weight)
Animates this group using assigned
PoseClipSequence . |
void |
animateSkin(float index,
int sequence)
Animates this object group using assigned
SkinClipSequence . |
void |
applyAnimation()
Calls
applyAnimation() on each of objects. |
void |
applySkeletonPose()
calls
Animated3D.applySkeletonPose() on each of objects. |
AnimatedGroup |
clone()
Same as clone(MESH_REUSE)
|
AnimatedGroup |
clone(boolean reuseMesh)
Clones this object group.
|
Animated3D |
get(int index)
Returns the specified object
|
Animated3D |
get(String name)
Returns the first object with given name.
|
PoseClipSequence |
getPoseClipSequence()
Returns the assigned ClipSequence if any.
|
Object3D |
getRoot()
Returns root object that all animated objects are added as child.
|
int |
getSize()
returns number of objects in this group
|
SkinClipSequence |
getSkinClipSequence()
Returns the assigned ClipSequence if any.
|
boolean |
isAutoApplyAnimation()
Returns if animateXX methods are automatically applied.
|
Iterator<Animated3D> |
iterator()
Returns an iterator of
Animated3D objects. |
static AnimatedGroup |
mergeAnimations(AnimatedGroup... groups)
Merge many identical
AnimatedGroup s with different animations into one. |
static AnimatedGroup |
mergeGroups(AnimatedGroup... groups)
Merge many
AnimatedGroup s with same animations into one. |
void |
removeFromWorld(World world)
Removes all animated objects to world.
|
void |
resetAnimation()
calls
resetAnimation() on each of objects. |
void |
setAutoApplyAnimation(boolean autoApplyAnimation)
Sets if animateXX methods are automatically applied.
|
void |
setPoseClipSequence(PoseClipSequence poseClipSequence)
Sets the
SkinClipSequence of this group. |
void |
setSkeletonPose(SkeletonPose currentPose)
calls
Animated3D.setSkeletonPose(SkeletonPose) on each of objects. |
void |
setSkinClipSequence(SkinClipSequence clipSequence)
Sets the
SkinClipSequence of this group. |
void |
setVisibility(boolean visible)
Sets visibility of all objects in group.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public static final boolean MESH_REUSE
public static final boolean MESH_DONT_REUSE
public AnimatedGroup(Animated3D... objects)
Skeleton
.IllegalArgumentException
- if object array is empty or they have different skeletons.Animated3D.mergeAnimations(Animated3D...)
public Object3D getRoot()
public Animated3D get(int index)
public Animated3D get(String name)
NoSuchElementException
- if object not foundpublic void addToWorld(World world)
World.addObject(Object3D)
public void removeFromWorld(World world)
World.removeObject(Object3D)
public SkinClipSequence getSkinClipSequence()
Returns the assigned ClipSequence if any.
public void setSkinClipSequence(SkinClipSequence clipSequence)
Sets the SkinClipSequence
of this group. The skeleton of ClipSequence must be the same of
this group.
This method is analogue of Object3D.setAnimationSequence(com.threed.jpct.Animation)
.
IllegalArgumentException
- if given ClipSequence has a different Skeleton
mergeAnimations(AnimatedGroup...)
public PoseClipSequence getPoseClipSequence()
Returns the assigned ClipSequence if any.
public void setPoseClipSequence(PoseClipSequence poseClipSequence)
Sets the SkinClipSequence
of this group. The skeleton of ClipSequence must be the same of
this group.
This method is analogue of Object3D.setAnimationSequence(com.threed.jpct.Animation)
.
IllegalArgumentException
- if given ClipSequence has a different Skeleton
mergeAnimations(AnimatedGroup...)
public void animateSkin(float index, int sequence)
Animates this object group using assigned SkinClipSequence
.
Updates curentPose once and if "auto apply animation" is enabled calls
Animated3D.applySkeletonPose()
on each of objects.
This method behaves similar to Object3D.animate(float, int)
.
public void applySkeletonPose()
calls Animated3D.applySkeletonPose()
on each of objects.
Animated3D.applySkeletonPose()
public void setSkeletonPose(SkeletonPose currentPose)
calls Animated3D.setSkeletonPose(SkeletonPose)
on each of objects.
Animated3D.setSkeletonPose(SkeletonPose)
public boolean isAutoApplyAnimation()
animatePose(float, int)
,
animateSkin(float, int)
public void setAutoApplyAnimation(boolean autoApplyAnimation)
Sets if animateXX methods are automatically applied. Also calls setAutoApplyAnimation
on each of objects. Default is true.
To enable animation blending automatic applying must be disabled.
animatePose(float, int)
,
animateSkin(float, int)
public void setVisibility(boolean visible)
public void applyAnimation()
Calls applyAnimation()
on each of objects.
Animated3D.applyAnimation()
public void resetAnimation()
calls resetAnimation()
on each of objects.
Animated3D.resetAnimation()
public void animatePose(float index, int sequence)
animatePose(float, int, 1)
public void animatePose(float index, int sequence, float weight)
Animates this group using assigned PoseClipSequence
.
Updates curentPose and if "auto apply animation" is enabled calls applySkeletonPose()
Pose animations are cumulative if "auto apply animation" is disabled. Each call to this method cancels previous skin animation.
sequence
- the number of PoseClip
in PoseClipSequence
. 1 is the first sequence.
0 means whole PoseClipSequence
index
- time indexweight
- how much animation will be applied. 1 means as it isSkinClipSequence
,
Object3D.animate(float, int)
,
setAutoApplyAnimation(boolean)
public Iterator<Animated3D> iterator()
Animated3D
objects.iterator
in interface Iterable<Animated3D>
public int getSize()
public static AnimatedGroup mergeAnimations(AnimatedGroup... groups)
Merge many identical AnimatedGroup
s with different animations into one.
This method does not require all AnimatedGroups share the same Skeleton
but skeletons are almost identical.
If many AnimatedGroups are loaded from different files, their skeleton objects will be different even if they are identical. This method is meant to help such cases.
This method always uses the skeleton of first group.
public static AnimatedGroup mergeGroups(AnimatedGroup... groups)
Merge many AnimatedGroup
s with same animations into one. This method
does not require all AnimatedGroups share the same Skeleton
but skeletons are almost identical.
This method does not actually check animations are the same but only checks Skeleton's are identical. So if animations differ the merged group will behave strange.
This method is used to merge groups where animations are identical.
If you want to merge AnimetedGroup's instead of animations use mergeGroups(AnimatedGroup...)
.
This method always uses the skeleton and animations of first group.
public AnimatedGroup clone()
clone
in class Object
clone(boolean)
public AnimatedGroup clone(boolean reuseMesh)
Clones this object group. Skeleton
, SkeletonPose
, SkinClipSequence
PoseClipSequence
will be shared.
If the mesh is reused, the clone and master will inherit animations from each other.