Blender export with atmature / animation

Hello guys, I am quite new to 3D modelling but I have read carefuly lot of topics here but was unable to find any relevant answer. For this reason I have to create another one - hopefuly it will help another 3D noobs too.

I have started to use Blender as my source of 3D models - I had some success as I was able to rig my model, create animation and texture, export it as GLTF and import it into Babylon. But there are several “details” that are really annoying and I cannot get rid of them on my own.

My ultimate goal is to create “monsters for my game” so each file should ideally be 1 mesh with 1 texture + set of animations which would then be 1 draw call per monster clone at the end of the day with possibility to run animations on each “clone” separately.

What problem then ?

  1. When I connect armatures with model in Blender, then always armatures are “parent” of that mesh. I cannot force Blender to do it otherwise - I want armature to be “child” of the model that is logical right ?

  2. When I import GLTF into Babylon, then I get object structure which I cannot work with (namely clone it and manipulate it effectively). It looks like this (I get two meshes)

Note: I using this for import: BABYLON.SceneLoader.LoadAssetContainer(“models/”, “orc.gltf”, scene, function(object)

And I get following object structure:

Mesh "Root"
               |_____  Armature (not sure about Babylon class)
                       |______ Bone (probably Bone class from Babylon)
                            |______ Children bones which is probably okay

Mesh "Orc Fighter" (this is the mesh I actually want - but it does not work on its own)

This “Orc” mesh does not have any children but it has parent which is something without name so I dont know what it actually is.

  1. When I import objects in this aforementioned structure, that it appears on screen and I can run animation on it. But I cannot move my mesh - to move “Orc Mesh” I have to set position of that “Root” mesh but that “Root” mesh apparently isnt´t parent to the Orc Mesh - but on the other hand when I want to set rotation, then I have to do so on that “Orc Mesh” directly. When I clone “Orc Mesh” then I get new mesh (with corrupted rotation and scale) that I cannot manipulate at all. It seems like that I have to clone and work with the whole bunch of objects and perform some operations on one and another on the others. This is really overwhelming and frustrating :frowning:

  2. Animations are somehow “outside” of the mesh in “Animation Groups” - I can run them via “object.animationGroups[i].play(true);” but it only apply to the one imported mesh. I cannot run these animations for clone of that mesh.

Long story short - I want to just import 1 mesh that will be root and has everything else as its “children” that will be cloneable and animatable independently. Is it possible from that GLTF file ? I believe that it will help to make armature as a child of mesh (see my first point) but I could not figure it out.

I have tried to use babylon exporter for blender, but it didnt work - it showed some long errors (some long stack trace that didnt tell me anything). I am now to Blender and thus I dont know what is wrong - my scene is really simple and exporter could not export it so I gave up on this (for this moment)

My blender file (217.6 KB) .

My exported GLTF file (137.4 KB)

Thanx in advance for any thought and insights and tips. Sad part is that I was able to rig, animate and texture my model relatively easily as well as importing it into my application, but further manipulation and real usage is what I am not able to do (which I didnt expect to be the difficult part).

1 Like

Maybe @Vinc3r can help?

I can try to help, but I don’t know too much about animation. That’s why I’ve asked on another forum what could be the classic workflow to animate a character for realtime applications, this topic can surely be interesting for you: Curious about character animation workflows — polycount

Now about your points:

  1. That’s how Blender works. Give a read on its doc
  2. I guess reading Blender gltf exporter documentation could help? And also, that’s how BJS gltf importer works I think.
  3. Rather than moving your mesh, why not moving your armature?

  1. don’t know (maybe docs linked above can help?)
1 Like

Thanx very much !! This inspector made it much more clear. I think that “Armature” object is the key here.

Probably using inspector I will be able to figure it out how to manipulate it and clone it. Maybe it will also help me to understand how to animate clones independently.

For this moment, thanx for these tips ! I didnt notice, that sandbox has inspector built-in :slight_smile:

1 Like

I had a quick look at your .blend file - and there are some issues. See images below.

Image 1 : With the armature selected the scale is 3.321 - will not work with .babylon export. Both mesh and armature need to be scale of 1 and rotation of zero. That is why you are getting :

some long errors (some long stack trace that didnt tell me anything)

Also there seems to be an animation on the mesh. No idea where you got that.

Image 2 : A view of the mesh when I open the file up - all kinds of unconnected vertices ( rough count 400+). Not sure what that will do to the weight painting and quality of the animation of the mesh (Image 3 - shows weight painting for a leg bone and part of hips where some duplicate vertices are present).

cheers, gryff :slight_smile:



1 Like

Hello Gryff !! Thank you very much for your insight !!! This was my first attempt to rig and animate that model thus there might be some problems on my side.

Now - I have started from scratch and it seems to be more “clear” than it previously was.

That model itself is something that I have downloaded from internet so these unconnected vertices might be present there. As you said there are some minor issues during animations - unconnected areas exactly where your pointers are. It is only minor trouble for me but … is there some SIMPLE way to connect these vertices properly to the rest of model ? I am sadly not modeller, I will use downloaded models and I will only rig them myself.

Thanx for that scaling info ! I will set it all to 1 and I will scale it properly on the Babylon side.

1 Like

I’m sure they are. It is always a risk when using someone else’s model from the internet. Always best to check vertices, normals, scaling etc. before you try rigging. You won’t be the first person to run into those problems.

You might want to follow this kind of workflow:

1 Load your mesh into Blender then check the mesh as I suggest above. Then scale to your game size scale . Apply scale, and any rotation. Make sure the origin of the mesh is at 0.0.0.

  1. Create your rig. You might want to add some IK bones (as you are creating “walk” animations) and make sure the “Deform” is unchecked on those IK bones. IK bones move other bones but do not deform the mesh themselves. Plenty of tutorials on YouTube, e.g. Sebastian Lague

  2. Make sure that the location, rotation of the rig are set to 0,0,0 and scale is 1,1,1.

  3. Now parent mesh to rig and create your animations.

  4. With @JCPalmer 's .babylon exporter you will get one long animation in the file but with multiple animations, however, “ranges” with the name of each animation used will be defined as well.

Not hard - but can be a little tedious

cheers, gryff :slight_smile:

1 Like

Hello guys, thanx for your updates, I have created fresh new GLTF file with reset scales and another transforsms, the result file seems to be clear now.

  • Scaling and rotation problems are now solved
  • I can create clones of imported mesh and work with them as I want

Issues that still remains are…

  1. I still cannot figure out, how to run animations on clones. I am cloning that armature object (of which mesh is a child). Some idea what to do with my original AnimationGroups ? These animations still only work on the original imported mesh but not on the clones.

I tried to clone animationGroup as well but I dont know how to “link it to my cloned meshes” thus it does not work. But I believe that it must be possible because all needed objects are evidently present.

  1. I am now also able to export to .babylon file via Blender to Babylon exporter. But the problem is that result file is 2x bigger and animations are corrupted - I can run those animations but they are totally deformed.

EDIT: Now I have read some post from 2 years ago where someone else had the same problem and it resulted in the fact, that best option is to reload model from file instead of cloning it. This is not ideal, but probably would solve my issue. Hopefully browser cache will do the job because otherwise it would be terrible experience.

What did you mean by that ? I cannot parent my mesh to the rig, because it always makes the rig to be parent of that mesh - I am unable to do it oherwise. When I “connect” rig with my mesh and select “automatic weihgts” then Blender always makes that rig to be parent of that mesh.

What you are doing is correct.

“parent mesh to rig” = “make the rig the parent of the mesh”. Just as you describe. It is just a turn of phrase that people use - see here

cheers, gryff :slight_smile:

Ok, then I understand you correctly :slight_smile: That action is really “parentig mesh to the rig” and the result of this action is “rig is parent to the mesh”. I was bit confused.

According to this thread, I will probably have to import data from file for each of my needed clone, probably there isnt simple way to clone imported objects from GLTF.

I don’t use GLTF export - reminds me too much of old VRML - so maybe others can answer this.

cheers, gryff :slight_smile:

What kind of export do you use ? I do not have to use GLTF, I am using it only because another format seemed to be bigger. If you can recommend another format, I will give it a try. I just need to get my animated mesh from Blender to Babylon :slight_smile: I dont have any special requirements.

I always use the .babylon export. I find that @JCPalmer 's exporter works really well and is very up-to-date. And the produced .babylon file can be opened in a text editor, is easy to read and the exporter produces a log file which helps understand what is going on. And JCP can point to problems from that log file.

cheers, gryff :slight_smile:

Thanx very much mister Gryff - I have tried that babylon exporter and it is MUCH EASIER ! To manipulate that imported mesh. Now I can clone it and animate it separately as I want without any problems. Now I see light at the end of tunnel finally.

But I have one issue - my animations are “corrupted”. When I exported into GLTF then I had similar problem that I solved by checking “Always sample animations” checkbox, but Babylon exporter doesnt seem to have anything like that.

These two files are both exported from the same Blender project - GLTF has ok animations, but Babylon does not :frowning: This is actually the only problem that I have with it, otherwise it works like a charm. (57.7 KB) (61.6 KB)

Tried fresh new Blender project, I kept everything as simple as possible and still - animation distorted in babylon format but ok in GLTF :frowning: there must be some setting that will fix it, otherwise it would have to happen to everyone :slight_smile: I have only like 12 bones and simple 4 frame animation.

Following zip contains blender project and both exports, I really dont know what I do wrong. It works in GLTF but I would much ratheru se Babylon format because of simpler follow-up work. (1.2 MB)