#Skeletal Animation - Calculating the bindpose with data from a gltf file

14 messages · Page 1 of 1 (latest)

brittle rivet
#

this is the code i use to calculate the Bindpose: ```
void bindPose(std::vector<Joint>& joints, Model& model) {
model.skinMatrix.resize(joints.size());
joints[0].globalMatrix = joints[0].undeformedMatrix;
model.skinMatrix[joints[0].skinIndex] = joints[0].undeformedMatrix * joints[0].inverseBindMatrix;
std::cout << "\nskin.joints index: " << (uint16_t)joints[0].skinIndex <<"\nskinMatrix: " << glm::to_string(model.skinMatrix[joints[0].skinIndex]) << std::endl;

for (uint32_t i = 1; i < joints.size(); i++) {
    Joint& joint = joints[i];

    joint.globalMatrix = joints[joint.parentJoint].globalMatrix * joint.undeformedMatrix;
    model.skinMatrix[joint.skinIndex] = joint.globalMatrix * joint.inverseBindMatrix;
    std::cout << "\nskin.joints index: " << (uint16_t)joint.skinIndex << "\nskinMatrix: " << glm::to_string(model.skinMatrix[joint.skinIndex]) << std::endl;
}

}

cerulean shell
#

joints[joint.parentJoint].globalMatrix wouldn't work if the child is processed before the parent no?

#

Especially with a long hierarchy

brittle rivet
#

I order my joints with a Depth first search, this is the new hirachy:
Skin index 0 belongs to node: 2
Skin index 1 belongs to node: 3
Skin index 2 belongs to node: 4
Skin index 3 belongs to node: 5
Skin index 4 belongs to node: 6
Skin index 5 belongs to node: 7
Skin index 6 belongs to node: 8
Skin index 7 belongs to node: 9
Skin index 8 belongs to node: 10
Skin index 9 belongs to node: 11
Skin index 10 belongs to node: 12
Skin index 11 belongs to node: 13
Skin index 12 belongs to node: 14
Skin index 13 belongs to node: 15
Skin index 14 belongs to node: 16
Skin index 15 belongs to node: 17
Skin index 16 belongs to node: 18
Skin index 17 belongs to node: 19
Skin index 18 belongs to node: 20
Skin index 19 belongs to node: 21
Skin index 20 belongs to node: 22
Skin index 21 belongs to node: 23
Skin index 22 belongs to node: 24
Skin index 23 belongs to node: 25

cerulean shell
#

Ok so you can guarantee that the ordering is top to bottom?

brittle rivet
#

yes, i posted the ordering of the nodes in the array

#

Before i upload my JointMatrices to the shader, i order them in the skin.joints order in the array

#

also, undeformedMatrix is supposed to be the localMatrix

brittle rivet
#

i could try to add a line renderer for this

brittle rivet
#

@cerulean shell could it be, that maybe the joints use a diffrent coordinate space than the mesh?

cerulean shell
#

I don't remember this so I don't think so

brittle rivet
#

cuz vulkan has a different coordinate system that the gltf

#

its unlikely but this may explain it