Issues doing animation with interchangable meshes

I’m learning how to animate and I’d really like to make a character whose meshes can be switched out on the fly (imagine equipment in an RPG), and although I’ve gotten really far, there are a few things that I haven’t got right.

My approach for rigging the model was to have each body part as a seperate object, and set them as parents with non-deformity to specific bones (it took way too much time and frustration to succeed with this). I have created some animations as you can see here:

My first issue is that, for each mesh the ogre exporter creates, the entire skeleton with all the animations (even unusable stashed ones) are included, resulting in a 4 meg skeleton xml PER BODY PART, and the export process takes way too long.

I probably could edit the exported mesh files to point to a single skeleton file, but hard drive space is not the real issue here.
My animations are all on the armature object, and due to the parenting, the body part objects are in turn children of the bones, which is probably why the whole structure is included for each.

I have tried to join the meshes together in blender before exporting but i have not managed to get anything working that way.

I did however succeed in combining different animations per body part (only an upper and lower half seems necessary atm), which looks like this:
The skeleton copy in front of the guy shows the skeleton attached to the HEAD object, where you can see that unrelated bones are included (anything underneath the spine and sidewards from the neck), but at least the animation for each part is now filtered from the root bone to the mesh’s bone. (you cannot see the hand swing, etc)

How do i do this correctly?

So my enthusiasm kept me going, and although I have not managed to optimize the use of skeletons, I did however manage to get the part replacement going.

Here’s a clip of the shoulder mesh being replaced during init, using a mesh that was modeled in a seperate blender file:

Upon passing a replacer mesh, it creates the bone buffers and moves the vertices based on a pre-supplied transform (which is easy to copy ONCE per skeleton per original body part).

Considering time investment, it’s actually not that bad after all, because animations can be tweaked in blender before exporting, and the replacement parts can be mass produced without bloat.

As for the redundant bones, if it proved to be a bottleneck at some point, I could probably initialize one skeleton to be shallow copied with irrelevant bones removed.

This is one of the topics that should be detailed in the wiki but isn’t.

Some further research done, apparently trying to recreate the skeletons with the “irrelevant” bones removed was a bad idea. The animations seem to be set up in a way that references every bone of the original structure so the missing bones will cause crazy stuff to happen.

I did however manage to code an animation frame limiter which would help improve performance, if needed. All it does is disable the skeletonControl & animControl while setting time manually, which is a bit hacky but it works.

At 100 animated dudes on screen I had 72 FPS, and by slashing the animation framerate to 1/3, the scene rendered at 190 FPS, so using some LOD tricks would be very viable.
Then I tried to compare that to 100 oto golems and had a few thousand FPS difference… erk.

I’d really appreciate if someone could tell me how to optimize the export in the first place


I managed to do this a few months ago, but ended up accidentally tossing out the code since it was more of a learning excerice, I guess I procrastinated making more than one character for too long.

But if I remember correctly, I exported a model from blender with multiple parts/materials (all attached to one skeleton) and all of the parts were joined together - I found it was necessary to join all my object in blender (ctrl-j) and to have everything selected at export time for the ogre exporter to work right.

Then I converted my model to j3o format, copied it and pasted a second version, and I removed the skeleton from the first j3o file. Then I removed the spatial from the second j3o file, this way you have a scene with the skeleton and a scene with the spatial.

Now you’d be able to apply that skeleton to any model that has matching vertex groups

 Spatial skeletonScene = assetManager.loadModel("Models/Skeletons/playerSkeleton.j3o");

 SkeletonControl skeletonControl = skeletonScene.getControl(SkeletonControl.class);
 AnimControl animControl = skeletonScene .getControl(AnimControl.class);

 Spatial characterModelScene = assetManager.loadModel("Models/PlayerModels/selectedCharacterModel");

  skeletonControl .setSpatial(null);
  characterModelScene .addControl(skeletonControl );
  characterModelScene .addControl(animControl);

I managed to find that code in a backup file.

As for the other issue you mentioned about exporting with the ogre exporter,

I haven’t used the ogre exporter in a while since I switched to the GLTF exporter, but if I remember correctly, this was the only way I could get my ogre models working. I had to join all the meshes together and then create a single keleton for that joined mesh if i recall. But i also didn’t quite understand the ogre exporter as well at the time, so hopefully someone who’s better with the ogre exporter can offer some insight in regards to the trouble you’re having exporting a model with more than one mesh / material.