I’m currently in the process of creating a mech game. Each model has to be able to have arms (legs would be nice, but not necessary) detached when shot off. The problem is that the mech will have multiple animations (walking, standing, jumping, falling over…) and I’m not sure of the best approach to get easy detachability for certain parts but keep the animation.
I tried making the arms separate meshes with their own skeleton, but the SDK importer would just mess up and not import animations correctly (the arms were missing theirs and instead had those of the body).
Also, as I added another animation, the SDK would just completely refuse to import the model, saying “bonetrack can’t be cast to spatialtrack” in the stacktrace.
Any ideas about the best approach for doing this?
Hey. I had a look at the mech but couldn’t see the problem, though I never use the blender importer.
Assuming I am understanding your requirements correctly, my advice would be to go with the ogre exporter. Make a single skeleton with all the parts required. Add as many animations as you want - if you want an animation that controls only one or two bones, then do so.
I would export the skeleton and then all the mesh parts individually. Then you can load these in JME and get them all controlled by 1 skeleton object.
In code you can create channels for parts that need to play separate animations, and control what is playing what animation there.
I’ve done this before, admittedly with less parts, but I think its the same principle. I had a body, head, shotgun, 3 individual objects, all attached to the same node and controlled by the same animControl or w/e the class is. The face played 1 animation while the body and head had another animation, shotgun playing same as body and I had another animation going for blinking the eyes.
I have never had any problems with the ogre exporter and would gladly help deal with any problems if you at any point decide to try it. I add all animations to one single track in the NLA editor, it keeps it nice - clean and simple.
Note: it may not work well for what you want, but as a hack if you want to keep things all in one mesh, you can set the scale of a bone to 0 and everything at or below that bone will disappear.
Doctor, halp, my arm disappeared!
What about to create a skeleton with all the models in one blend file. Then export it into j3o file. This one will contain all the stuff. Finally copy this j3o file several times, and for each delete unnecessary parts.
This way, the animation should be working properly, the workflow is not that bad either. To further improve the workflow, considers doing the copying and deletion by a script.
What if you leave the base skeleton and make the arms invisible somehow?
E.g. with a alpha texture layer which you then change on demand?
This is a bit complex but without that you will have other problems like when a human moves his hips, his arms follow a bit, or when you duck yourself, the arm has to be lowered. So I think separating the animations will lead to sync issues.
What you can try to do is using xbuf, the sdk supports it natively, you just need to download the blender exporter addon from github (something like
xbuf/jme3_xbuf_io), then you can export .xbufs just like you would do with ogre
Well, the XBUF exporter / importer messes up, too.
The animations are not imported / imported incorrectly (weird artifacts) and the textures are not imported correctly either.
Thanks for the tip anyway.
I see that at least in blender, the setting scale of a bone to 0 works.
I’ll try it in-engine and report back.
Well actually no one ever had problems with xbuf so far, especially the textures are strange because they are so simple (xbuf just exports them to a folder and then get added to your asset folder).
Maybe it is a problem with JME not supporting something?
Can you maybe give a rough description what doesn’t work with xbuf?