Access Bones and Vertices Collision

Good evening together,

I’m on new challenges:

  1. What is the simplest way to make Rig/Armature (and its bones) accessible using .glb-files? Currently, I only get access by task.loadedSkeletons, when I use deform armature modifier on main mesh. The other meshes in the .glb-file linked to their bone parents. But if I remove armature modifier and link main mesh to its bone parent, the task.loadedSkeletons is an empty array.
  2. Is there a way to detect collision of certain vertices beside using more meshes i.e. by vertex group or area around bone (or its TransformNode)? I’m asking for a projectile that hits a certain area of a mesh, but I already have bone-TransformNodes at the center of those areas.
  3. Can you set up collision in Blender/.glb-file, that Babylonjs don’t need additional checkCollision = true statement?
  4. Can you set different groups of meshes that has different collision behavior like “no friendly fire”?

Adding @bghgary our own GLTF guru

1 Like

There are many different topics in your post. I can maybe address the first one, but can you send a playground of what you have so far (even if it doesn’t work)?

I reproduced it on playground, this is as far as i got: https://playground.babylonjs.com/#3ZJLP2#3

I used a Z-UP empty plain axis like on RiggedFigure, i assume this is common or useful in certain situations? Also there is automatically a root Y-UP created by glb-Exporter, which seems to suit Babylon standard World Axis?

The current problem in the playground is that the skeleton and its bones are not found because the meshes are only parented on bone and no armature modifier is used.
After that I need to see if the attached turret is aligned (fix rotation) correctly.

I’m not sure I understand what you are trying to do. You mentioned in the original question:

the task.loadedSkeletons is an empty array

But I don’t see any code that looks like this in the playground. Also, the playground throws an error in the console:

Uncaught (in promise) TypeError: submeshes is not iterable
at delayCreateScene (:36:26)

I’m not sure what to do with this PG.

I don’t see toAttach meshes. What do you mean?

I edited my post above, the submeshes are found now. Its the bones that are not found now.

Regarding the task.loadedSkeletons of AssetManager.addMeshTask gives same result for this small example as SceneLoader.ImportMeshAsync.

by toAttach meshes I mean the Turret and its Barrel which both are in one glb their parents are bones in the same glb’s Rig.

Sorry, I see this now:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'bones')
at delayCreateScene (<anonymous>:30:43)

This is what I get on https://playground.babylonjs.com/#3ZJLP2#4 :

Uncaught (in promise) TypeError: subbones.Turret_ROTATION is undefined
delayCreateScene https://playground.babylonjs.com/#3ZJLP2#4 line 2 > injectedScript:40

Like I wrote above, the problem seems to be that setting a bone as parent of a mesh, dont give access to this bone in Babylonjs. The only way I know is to use “Deform Armature”- Modifier which is not need by Turret and I don’t have a good workaround / solution for this.

The idea I had is bad, because adding an extra Mesh to Turret.glb just to apply an armature modifier on that unused Mesh is nothing I like to do, tbh. How do you do this when you don’t use armature modifier, but want access to bones that are parents of mesh in blender?

Sorry, I don’t really understand what you are doing or what you are saying. :frowning: None of the glb assets you are loading have skinning. The names you are referencing don’t exist in the glb.

You can use the inspector in the sandbox to look at what was loaded:

Babylon.js - Ship_example.glb (babylonjs.com)

Babylon.js - Turret_example.glb (babylonjs.com)

Yeah, that is what I was asking. How do I get a skin into .glb-file without using Armature Modifier in Blender. I assume I have to replace my addMeshTask with addContainerTask then I can access transformNodes that are bones in .glb-file.

With the Ship_example I was not sure if I am going to use the Armature Modifier, if I do the skin is accessible.

But the Turret_example has no Deformation, so there won’t be an armature modifier. I wanted to keep the same way to access on .glb-files. For now I have to go here with transformNodes.

I’m not sure I understand. The first sentence is about Blender which maybe someone who knows Blender here can help. I don’t know much about Blender. If there are no skins/skeletons in the glb after exporting from Blender, there is nothing we can do on the Babylon.js side to get bones as there are no bones and thus the rest doesn’t make much sense. Am I missing something?

You are right, I thought you made the RiggedFigure.glb in Blender and have rigging experience.

But one thing about babylonjs you might be able to tell me. What is the difference between using bone.getTransformNode() and the TransformNode (like above EVELATION) that actually was a bone in Blender and got made to TransformNode by gltf-exporter?

Edit: I managed to solve #1.

Edit2: #4 is cleared up, you can use objects/arrays as different groups and point targets to it and iterate through intersectsMesh.

My solution on #2 is adding an Box-Mesh for the node and use intersectsMesh on bullet rays.

Regarding #3, I’ve enabled collision physic property on main mesh, but the loadedMesh still got checkCollisions = false, even adding RigidBody gives same result. I think the way for me is to use to moveWithCollision-function.

1 Like