How to add clothing to character model

Yes, I mean there is no need to weight paint armor if OP wants to use attachment node.

1 Like

I have 2 errors

  1. boots move separately from the model in blender
  2. in jmonkey boots not move
character = assetManager.loadModel("Models/char.glb");
        rootNode.attachChild(character);
        character.setLocalTranslation(1.2311511f, -0.5f, 6.1211777f);
        character.setLocalScale(0.15f);
        character.rotate(0, -1.7f, 0);
        
        //AnimComposer animComposer = character.getControl(AnimComposer.class);
       // animComposer.setCurrentAction("run");
       Node charNode = (Node)character;
       Node armature = (Node)charNode.getChild("Armature");
       AnimComposer animComposer = armature.getControl(AnimComposer.class);
       animComposer.setCurrentAction("run");
       
        Spatial boots = assetManager.loadModel("Models/boots.glb");
        charNode.attachChild(boots);

where is the mistake?

Hmm, it seems to me they are not correctly weight painted to bones.

charNode.attachChild(boots);

change the above line to

armature.attachChild(boots);

and see if it makes any difference.

1 Like

charNode.attachChild(boots);

exported boots have a buildable skeleton
who made rpg tell me how please

If the boot are made properly and setup in their own j3o scene correctly, then they should work from simply attaching them to the node that contains the AnimComposer

That means:

  1. the boots should have proper vertex weights/groups

  2. the boots should be positioned so that they are overtop of the feet when you attach them

  3. the j3o file containting the boots model should not have an AnimComposer or Armature - its vertex groups are stored in the mesh, so there’s no need for any extra controls for the boots.

  4. The clothing and the model you’re attaching the armor/clothing to should have locataion/rotation/scale applied before export. Not sure if you did this but I see it hasn’t been mentioned in this thread so heres that info just in case: Importing models with animations from Blender - #9 by silentsword.

If you still have trouble, I can try to post a video showing how I attach a compatible clothing piece to my base character model in the Scene Composer, but if you have everything with the boots and character model set up its just as easy as attaching the boots to the Spatial that has the Armature…

Edit: one other thing to note: when i do this in the SDK scene composer, I have to close and reopen the scene for the animations to register after I’ve attached the clothing. At run-time I attach clothing prior to the model being attached to the rootNode, so attachment order seems to matter as well.

So, why not attaching the boots before the animation starts ? A better design would be creating a common node from the start and name it character and add the character body and the boot to it then create an armature animation for the common node.

And btw, i noticed that your animation runs only on the armature part, you should get another animcomposer for the boots and run it (if it has separate keyframes).

the boots have proper vertex weights/groups

in my presence there is a skeleton and animation, how to export without a skeleton and animation?

i apply rotation scale and location to models

new code

character = assetManager.loadModel("Models/char.glb");
        character.setLocalTranslation(1.2311511f, -0.5f, 6.1211777f);
        character.setLocalScale(0.15f);
        character.rotate(0, -1.7f, 0);
        
        //AnimComposer animComposer = character.getControl(AnimComposer.class);
       // animComposer.setCurrentAction("run");
       Node charNode = (Node)character;
       Node charArmature = (Node)charNode.getChild("Armature");
       
       
        Spatial boots = assetManager.loadModel("Models/boots.glb");
        charNode.attachChild(boots);
        
        rootNode.attachChild(character);
        
        
       AnimComposer animComposer = charArmature.getControl(AnimComposer.class);
       animComposer.setCurrentAction("run");

can you record video with glb example

i think character model have armature and boots attach to armature with animation

which animcomposer use?

An armature would have joints and joints or bones can run different animations, i will send an example for an armature control.

Character with boots boots.blend — Яндекс.Диск
Look please

I think you also need to apply them on the Armature.

Apply- not work :frowning:

I made a quick video showing how I do it in jme’s SDK so its easier to see what’s going on. But the same works at run-time with the code I posted above

I also convert my models from gltf/glb → j3o before working with them in the engine, so that allows me to edit them in the SDK’s scene composer like this. I actually didn’t even know it worked to load GLB at run-time, but in my case I still always convert to .j3o. Converting to j3o is as simlple as double-clicking (or right-click → convert) a gltf or glb file in the SDK.

4 Likes

thansk
can you test my model?

And how to expot glb without armature?

I think if you put the boots in their own .blend file and delete the animControl and bones in blender, then it should have no armature in jme. I would still suggets converting to j3o so you could view the base character model in the SDK and see if the Armature is potentially attached deeper than the scene’s rootNode, which could also be the problem. And then you can also delete the armature in the boots’ .j3o file too.

I have error with viewer (Open gl not started)

The boots.blend file seems to have lost the vertex groups data when I open it in Blender. Could you send over a version of the character with boots in .glb format instead?

1 Like

It looks like the boots also have no vertex groups. I manually assigned them since they matched each foot bone, and then I managed to get things working.

The export process from blender is a bit finicky, and I didn’t include that part in my video since I hadn’t done it in so long and forgot the details.

However, it appears as though I needed to export the boots from blender WITH the armature, and then in the SDK I removed the Armature and AnimComposer from the .j3o file of the boots, then attached that to the base character and it worked.

So it looks like you need to use the scene composer to edit the boots model in JME, or if the scene composer is not working you could probably also remove the Armature and AnimComposer from the boots with code before you attach the boots.