Hi all,
I’m trying to figure out what would be the best approach to, for example, attach a piece of clothing to a character (both have to be separate models). I understand that the vertices of the clothing will have to be influenced by the bones of the character’s skeleton. I just have no idea where to start. Is that something that should be done in the modelling tool (blender in my case)? Would there be an issue with using gltf format to export from blender? What has to be done in order to end up with two j3o files, one for the character and one for the clothing, so they can be combined together later in tho process?
I will probably figure it out sooner or later myself but I thought that maybe someone already did this and would be so kind to point me in the right direction
apply only part of cloth to cloth physics or all of it
you can also use DAC that is nice.
step 5)
to split into 2 files: Create new Blender file, press file → append, select previous file, append Object → Armature + cloth. (you need armature, otherwise JME will not export animations).
make sure in modifiers that cloth have proper armature linked
export using GLTF same way
in game code, load character, and later cloth, but append to character node(Armature node exactly), only cloth Geometries, not armature again.
SceneGraphVisitor visitor = new SceneGraphVisitor() {
@Override
public void visit(Spatial spatTraversal) {
if(!spatTraversal.getName().equals("Armature")){
((Node)model.getChild("Armature")).attachChild(spatTraversal);
}
}
};
((Node)clothes).breadthFirstTraversal(visitor);
step 6)
to make character feel alive, talking, or customize it even more, not just with bones, you can use shape keys (vertex shapes)
Select model, and clikc “+”, it will add basic shape, then next “+” will add another shaped you can do and transform into them. (but please dont make too much of them - what you can, do with bones)
my example:
export model again using export → GLTF (with setting selected objects and having selected what you need)
Even more helpfull things:
you can make IK bones in blender, and unselect deform:
it will be not exported as bone, but animation will be readed properly.
you dont need j3o (but it work faster)
anyway you can load GLTF files directly
please note advice with shape keys work on JME 3.3+
using gradle instead of Ant give soem advantage later, so if you want, its worth to use it.
(here use gradle in code project and Ant for assets - to SDK see them properly, grale just pull assets from ant project)