Hi,
My target is to display 4 animations of the same mesh, at the same time with 2 different animation states (walk and idle).
What i found out yet:
- If i just clone the mesh with mesh.clone(), the SkeletonAnimator (and its SkeletonAnimationSet and Skeleton) will also be cloned. This will give me the possibility to play different animation states, but cloned SkeletonAnimators are bad for performance. I got 6 FPS here…
- If i just clone the mesh with mesh.clone(), and reference only 1 SkeletonAnimator to all meshes i am getting 30FPS, but i can’t play different animation states.
So my approach was to create an individual SkeletonAnimator for each mesh, with a reference to only 1 SkeletonAnimationSet and 1 Skeleton.
First i created the SkeletonAnimator, SkeletonAnimationSet and the animation nodes.
private function onAssetComplete(event: AssetEvent): void {
if (event.asset.assetType == AssetType.MESH) {
protoMesh = event.asset as Mesh;
} else if (event.asset.assetType == AssetType.ANIMATION_NODE) {
var animationNode: SkeletonClipNode = event.asset as SkeletonClipNode;
skeletonAnimationSet.addAnimation(animationNode);
} else if (event.asset.assetType == AssetType.SKELETON) {
skeletonAnimationSet = new SkeletonAnimationSet();
skeletonAnimator = new SkeletonAnimator(skeletonAnimationSet, event.asset as Skeleton);
}
}
Then i cloned the mesh and added an individual Animator for each cloned mesh, sharing the same SkeletonAnimationSet and Skeleton.
var clonedMesh:Mesh = protoMesh.clone() as Mesh;
clonedMesh.animator = new SkeletonAnimator(skeletonAnimationSet, skeletonAnimator.skeleton);
I started the application and I got this error:
A Material instance cannot be shared across renderables with different animator libraries
Ok, i tried a different way…instead of cloning the mesh, i cloned the geometry and assigned a new texture
var clonedMesh:Mesh = new Mesh(protoMesh.clone(), new TextureMaterial(TextureMaterial(protoMesh.material).texture));
Now, the animation works but is incredibly slow. I get 6 FPS with a weird looking texture.
My Question is, what is the correct workflow to display 4 animations of the same mesh with different animation states and a good performance?