private final Map<String, AnimationClip> animationStore = Maps.newHashMap();
private AnimationManager createAnimationManager(final SkeletonPose pose) {
// Make our manager
final AnimationManager manager = new AnimationManager(_timer, pose);
// Add our "applier logic".
final SimpleAnimationApplier applier = new SimpleAnimationApplier();
manager.setApplier(applier);
// Add a call back to load clips.
final InputStore input = new InputStore();
input.getClips().setMissCallback(new MissingCallback<String, AnimationClip>() {
public AnimationClip getValue(final String key) {
if (!animationStore.containsKey(key)) {
try {
final ColladaStorage storage1 = new ColladaImporter().load("collada/skeleton/" + key + ".dae");
animationStore.put(key, storage1.extractChannelsAsClip(key));
} catch (final IOException e) {
e.printStackTrace();
animationStore.put(key, null);
}
}
return animationStore.get(key);
}
});
// Load our layer and states from script
try {
final ResourceSource layersFile = new URLResourceSource(ResourceLocatorTool.getClassPathResource(
AnimationDemoExample.class, "com/ardor3d/example/pipeline/AnimationDemoExample.js"));
JSLayerImporter.addLayers(layersFile, manager, input);
} catch (final Exception e) {
e.printStackTrace();
}
// kick things off by setting our starting state
manager.getBaseAnimationLayer().setCurrentState("walk_anim", true);
return manager;
}