Hello, I am trying to create a simple skeleton that consists of individual meshes that are attached to each bone, no weights. I’ve created a basic skeleton with pelvis, thigh and shin bones, but I’m not getting the result that I expect.
-
The skeletal viewer shows a strange visualization of bones, where they are all just pointing straight up. And, only the LINES visualization seems to display anything, the SPHERES and SPHERE_AND_SPURS style displays nothing.
-
I was expecting the lines between bones to be connected, and I thought setting the rest pose translations was all that’s necessary to achieve this.
The code for my example is available here:
https://playground.babylonjs.com/#AT1ZNB
Welcome aboard!
Have a look at this thread for a PG that creates a skeleton manually: Bones - Freeze transformations - #7 by reimund
Other threads related to bones and skeletons that may help:
1 Like
Thanks for the links, especially the playground by reimund.
Using the example, I was able to deduce that the problem for why the bones were all pointing up was:
Afterwards, I tried changing the visualizer to use SPHERE_AND_SPURS, but that resulted in no visualization at all. Making the following changes fixed this:
- Remove
setRestPose()
- Put the default transformation directly into the Bone constructor
Final code adjustments:
function make_bone(skeleton, parent, name, rest_pose, length) {
const bone = new BABYLON.Bone(name, skeleton, parent, rest_pose);
//const bone = new BABYLON.Bone(name, skeleton, parent);
//bone.setRestPose(rest_pose);
//bone.length = length;
return bone;
}
I’m not sure why these changes were necessary, would greatly appreciate an explanation.
Updated my playground: https://playground.babylonjs.com/#AT1ZNB#1
All I can tell is that when you pass your initial matrix (rest_pose) as the 4th parameter of the constructor, this matrix is used to generate an internal _invertedAbsoluteTransform
matrix which seems needed for the skeleton to generate the correct bone matrices used by the vertex shader.
Thanks anyway, at least I’ve solved my initial problem 