Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Joint Names? #371

Open
kklouzal opened this issue Aug 20, 2022 · 3 comments
Open

Extract Joint Names? #371

kklouzal opened this issue Aug 20, 2022 · 3 comments

Comments

@kklouzal
Copy link

I am using TinyGLTF to import GLTF files into my application and am in need of reading out the names of joints. I can pull indices and weights just fine, but do not see a straightforward way to pull the (string/char) name of each joint.

Page 5 of the gltf20-reference-guide appears to show that joint names are present inside a GLTF file, but does a poor job of explaining which accessor to use etc..

Is this possible?

@syoyo
Copy link
Owner

syoyo commented Aug 20, 2022

glTF itself has poor definition of Skinning feature and TinyGLTF also does not provide any helper functions for (easy) handling of Skinning hierarchy.

Probably you need to write your own scene traversal routine to get joint names, but still, you could only extract name of node as a joint name from glTF(if your glTF does not contain any extensions/extra data for Skinning).

Probably related issues in glTF:

KhronosGroup/glTF#1665
KhronosGroup/glTF#1270

@kklouzal
Copy link
Author

kklouzal commented Aug 20, 2022

Yes, a simple name is all that's required. This way I can pair the joint id with it's name for use elsewhere in my application.

I've tried a few different ways to try and extract the nodes name (I know it exists within the gltf file), but I cannot for the life of me find any way to pull it out.. Any clues?
image
Thank you.

@kklouzal
Copy link
Author

kklouzal commented Oct 3, 2022

https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.pdf
Section 3.7.3.2. Joint Hierarchy:

The joint hierarchy used for controlling skinned mesh pose is simply the node hierarchy, with each node designated as a joint by a reference from the skin.joints array
Which, from what I understand, means a skins joint id == node id.

for (size_t i = 0; i < model.skins.size(); i++)
{
    tinygltf::Skin _Skin = model.skins[i];

    for (auto& JointID : _Skin.joints)
    {
        std::string NodeName = model.nodes[JointID].name;
        int ID = JointID - _Skin.skeleton;
    }
}

Subtract _Skin.skeleton from each JointID in the event our skeleton root node is greater than 0. If you don't do this then your joint ID's will be skewed and won't match up with the inverse bind matrices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants