public class Animated3D extends Object3D implements Cloneable
An Object3D
which can be animated via skeletal or pose animation.
animateSkin(float, int)
and animatePose(float, int)
methods are analogues of
Object3D.animate(float, int)
method. They calculate a new Mesh and apply it if "auto apply animation"
is enabled (It's enabled by default). If you need animation blending, you should disable "auto apply animation",
first perform pose animation(s) then perform skin animation and finally call applyAnimation()
.
Once constructed, Animated3D sets an IVertexController
on its mesh which
modifies the Mesh
to perform animation. So if you set another IVertexController
on its mesh, you will break animation.
Animated objects often consist of sub-objects and in such cases manipulating them in an AnimatedGroup
is much easier and convenient. Most of the methods in this class also exist in AnimatedGroup to allow bulk operations.
For skin animations with many (more than one) sub objects, animating via AnimatedGroup also performs better since
SkeletonPose
calculations are done once for whole group.
Skeletal animation updates vertex normals for proper lighting effects. However pose animation does not update normals since it is simply too expensive. Pose animations are typically used for small deformations (like facial animations) so this wont be a problem for most cases.
Skeletal animation part of this class is adapted from Ardor3D.
AnimatedGroup
,
BonesIO.loadObject(java.io.InputStream)
,
Serialized FormModifier and Type | Field and Description |
---|---|
static boolean |
MESH_DONT_REUSE
Use a separate mesh.
|
static boolean |
MESH_REUSE
Re-use (share) the mesh.
|
BILLBOARDING_DISABLED, BILLBOARDING_ENABLED, BLENDING_DISABLED, BLENDING_ENABLED, BUMPMAPPING_DISABLED, BUMPMAPPING_ENABLED, COLLISION_CHECK_NONE, COLLISION_CHECK_OTHERS, COLLISION_CHECK_SELF, COLLISION_DETECTION_NOT_OPTIMIZED, COLLISION_DETECTION_OPTIMIZED, COLLISION_NONE, CULLING_DISABLED, CULLING_ENABLED, ELLIPSOID_ALIGNED, ELLIPSOID_TRANSFORMED, ENVMAP_CAMERASPACE, ENVMAP_DISABLED, ENVMAP_ENABLED, ENVMAP_WORLDSPACE, ENVMAP_XY, ENVMAP_XZ, ENVMAP_YZ, FILTERING_DISABLED, FILTERING_ENABLED, FINALIZE_DEFAULT, FINALIZE_PRESORTX, FINALIZE_PRESORTY, FINALIZE_PRESORTZ, LIGHTING_ALL_ENABLED, LIGHTING_NO_LIGHTS, MOUSE_SELECTABLE, MOUSE_UNSELECTABLE, NO_OBJECT, OBJ_INVISIBLE, OBJ_VISIBLE, RAY_MISSES_BOX, SECTOR_AUTODETECT, SECTOR_PRECALCULATED, SHADING_FAKED_FLAT, SHADING_GOURAUD, SPECULAR_DISABLED, SPECULAR_ENABLED, TRANSPARENCY_MODE_ADD, TRANSPARENCY_MODE_DEFAULT, UNKNOWN_OBJECTSIZE
Constructor and Description |
---|
Animated3D(Animated3D object)
Same as
Animated3D(Object3D, MESH_REUSE) |
Animated3D(Animated3D object,
boolean reuseMesh)
Behaves same as
Object3D(Object3D, reuseMesh) . |
Animated3D(MeshData meshData,
SkinData skin,
SkeletonPose currentPose)
Creates a Animated3D out of given information.
|
Animated3D(Object3D object,
SkinData skin,
SkeletonPose currentPose)
Creates a Animated3D out of given information.
|
Modifier and Type | Method and Description |
---|---|
void |
animatePose(float index,
int sequence)
Same as
animatePose(float, int, 1) |
void |
animatePose(float index,
int sequence,
float weight)
Animates this object using assigned
PoseClipSequence . |
void |
animateSkin(float index,
int sequence)
Animates this object using assigned
SkinClipSequence . |
void |
applyAnimation()
Applies animation to mesh.
|
void |
applySkeletonPose()
Applies skin animation to internal copy of mesh.
|
Animated3D |
cloneObject()
Clones this object.
|
void |
discardMeshData()
If this object is called via Ardor3D's or jME's loader, calling this method saves some memory.
|
int |
getIndex()
returns the index in group
|
PoseClipSequence |
getPoseClipSequence()
Returns the assigned
PoseClipSequence if any. |
Skeleton |
getSkeleton()
Returns the Skeleton this object is bound to.
|
SkeletonPose |
getSkeletonPose()
Returns the skeleton pose used for animation.
|
SkinClipSequence |
getSkinClipSequence()
Returns the assigned
SkinClipSequence if any. |
SkinData |
getSkinData()
Returns skin data if any.
|
boolean |
isAutoApplyAnimation()
Returns if animateXX methods are automatically applied.
|
static Animated3D |
mergeAnimations(Animated3D... objects)
Merge many
Animated3D s into one. |
void |
resetAnimation()
Clears all animation state to initial position of Mesh.
|
void |
setAutoApplyAnimation(boolean autoApplyAnimation)
Sets if animateXX methods are automatically applied.
|
void |
setPoseClipSequence(PoseClipSequence poseClipSequence)
Sets the
PoseClipSequence of this object. |
void |
setScale(float sX,
float sY,
float sZ)
Sets the scaling of Animated3D.
|
void |
setSkeletonPose(SkeletonPose currentPose)
Sets skeleton pose used for animation.
|
void |
setSkinClipSequence(SkinClipSequence clipSequence)
Sets the
SkinClipSequence of this object. |
addChild, addCollisionListener, addParent, addTriangle, addTriangle, addTriangle, addTriangle, addTriangle, addTriangle, addTriangle, addTriangle, align, align, animate, animate, build, calcBoundingBox, calcCenter, calcMinDistance, calcMinDistance, calcNormals, calcTangentVectors, calcTextureWrap, calcTextureWrapSpherical, checkForCollision, checkForCollisionEllipsoid, checkForCollisionSpherical, clearAdditionalColor, clearAnimation, clearObject, clearRotation, clearTranslation, compile, compile, compile, compileAndStrip, createDummyObj, createTriangleStrips, createTriangleStrips, cullingIsInverted, decompile, decoupleMesh, disableCollisionListeners, disableLazyTransformations, disableVertexSharing, ellipsoidIntersectsAABB, enableCollisionListeners, enableLazyTransformations, forceGeometryIndices, getAdditionalColor, getAnimationSequence, getBlending, getCenter, getCollisionListeners, getCulling, getEllipsoidMode, getEnvmapMode, getID, getInverseWorldTransformation, getInverseWorldTransformation, getLightCount, getLighting, getMaxLights, getMesh, getName, getNextID, getOcTree, getOrigin, getOriginMatrix, getParents, getPolygonManager, getRenderHook, getRotationMatrix, getRotationPivot, getScale, getTextureMatrix, getTransformedCenter, getTransformedCenter, getTranslation, getTranslation, getTranslationMatrix, getTransparency, getTransparencyMode, getUserObject, getVisibility, getWorldTransformation, getWorldTransformation, getXAxis, getYAxis, getZAxis, hasChild, hasParent, hasVertexAlpha, invert, invertCulling, invertTextureCoords, isBumpmapped, isCompiled, isEnvmapped, isSelectable, isTransparent, mergeAll, mergeObjects, rayIntersectsAABB, rayIntersectsAABB, rebuild, recreateTextureCoords, removeChild, removeCollisionListener, removeMultiTexturing, removeParent, reorderSectors, resetCollisionStatus, resetNextID, rotateAxis, rotateMesh, rotateX, rotateY, rotateZ, scale, setAdditionalColor, setAllTextures, setAllTextures, setAnimationSequence, setAsMultiSectored, setBaseTexture, setBillboarding, setBlending, setBoundingBox, setBumpmapped, setBumpmapTexture, setCenter, setCollisionMode, setCollisionOptimization, setCulling, setDepthBufferWrites, setEllipsoidMode, setEnvmapDirection, setEnvmapMode, setEnvmapped, setFiltering, setLighting, setMatrixCacheUsage, setMaxLights, setMesh, setName, setNextID, setOcTree, setOrientation, setOrigin, setRenderHook, setReNormalization, setRotationMatrix, setRotationPivot, setScale, setSector, setSectorDetectionMode, setSelectable, setShadingMode, setSortOffset, setSpecularLighting, setTexture, setTexture, setTextureMatrix, setTranslationMatrix, setTransparency, setTransparencyMode, setUserObject, setVisibility, shareCompiledData, shareTextureData, sphereIntersectsAABB, strip, touch, translate, translate, translateMesh, unbuild, wasTargetOfLastCollision, wasVisible
public static final boolean MESH_REUSE
public static final boolean MESH_DONT_REUSE
public Animated3D(Animated3D object)
Same as Animated3D(Object3D, MESH_REUSE)
Animated3D(Animated3D, boolean)
public Animated3D(Animated3D object, boolean reuseMesh)
Behaves same as Object3D(Object3D, reuseMesh)
.
In addition copies animation data.
Note: If master object has skin animation, its mesh must be in bind pose, otherwise created object will have garbled animation.
MESH_REUSE
,
MESH_DONT_REUSE
public Animated3D(MeshData meshData, SkinData skin, SkeletonPose currentPose)
public Animated3D(Object3D object, SkinData skin, SkeletonPose currentPose)
public void setScale(float sX, float sY, float sZ)
Sets the scaling of Animated3D. Scaling may be non-uniform (i.e. x-y-z scaling may be different). Note however normals aren't updated in according to scaling, so if x-y-z scaling differ a lot lighting artifacts may occur.
sX
- scaling at X axissY
- scaling at Y axissZ
- scaling at Z axispublic SkeletonPose getSkeletonPose()
public void setSkeletonPose(SkeletonPose currentPose)
public Skeleton getSkeleton()
public SkinData getSkinData()
public void discardMeshData()
public boolean isAutoApplyAnimation()
animatePose(float, int)
,
animateSkin(float, int)
public void setAutoApplyAnimation(boolean autoApplyAnimation)
Sets if animateXX methods are automatically applied. Default is true.
To enable animation blending automatic applying must be disabled.
animatePose(float, int)
,
animateSkin(float, int)
public void resetAnimation()
public void applyAnimation()
public void animateSkin(float index, int sequence)
Animates this object using assigned SkinClipSequence
.
Updates current SkeletonPose
, applies current pose by calling
applySkeletonPose()
and if "auto apply animation" is enabled calls applyAnimation()
Skin animations are not cumulative. Each call to this method cancels previous skin animation.
Note, if many animated objects share the same pose,
updating current pose for each of them is a waste. Consider
using AnimatedGroup.animateSkin(float, int)
This method behaves similar to Object3D.animate(float, int)
.
sequence
- the number of SkinClip
in SkinClipSequence
. 1 is the first sequence.
0 means whole SkinClipSequence
index
- time indexSkinClipSequence
,
Object3D.animate(float, int)
,
setAutoApplyAnimation(boolean)
public void animatePose(float index, int sequence)
animatePose(float, int, 1)
public void animatePose(float index, int sequence, float weight)
Animates this object using assigned PoseClipSequence
.
If "auto apply animation" is enabled calls applyAnimation()
Pose animations are cumulative if "auto apply animation" is disabled. Each call to this method cancels previous skin animation.
This method behaves similar to Object3D.animate(float, int)
.
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 isPoseClipSequence
,
Object3D.animate(float, int)
,
setAutoApplyAnimation(boolean)
public void setPoseClipSequence(PoseClipSequence poseClipSequence)
Sets the PoseClipSequence
of this object.
This method is analogue of Object3D.setAnimationSequence(com.threed.jpct.Animation)
.
public PoseClipSequence getPoseClipSequence()
Returns the assigned PoseClipSequence
if any.
public SkinClipSequence getSkinClipSequence()
Returns the assigned SkinClipSequence
if any.
public void setSkinClipSequence(SkinClipSequence clipSequence)
Sets the SkinClipSequence
of this object. The skeleton of SkinClipSequence must be the same of
this object.
This method is analogue of Object3D.setAnimationSequence(com.threed.jpct.Animation)
.
IllegalArgumentException
- if given ClipSequence has a different Skeleton
mergeAnimations(Animated3D...)
public Animated3D cloneObject()
Clones this object. Behaves same as Animated3D(Animated3D, MESH_REUSE)
.
cloneObject
in class Object3D
Animated3D(Animated3D, boolean)
public int getIndex()
public void applySkeletonPose()
applyAnimation()
to update mesh.public static Animated3D mergeAnimations(Animated3D... objects)
Merge many Animated3D
s into one. This method
does not require all Animated3Ds share the same Skeleton
but skeletons are almost identical.
If many Animated3Ds 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 object.