Problem with setting rotation of bones

skinned-mesh
transform

#1

Hello there,
I have a model of a rigged character (exported from Maya and imported with the GLTF loader).

I want to set the character into a pose without using animation and that means that I have to set the bone rotation manually. From Maya I have exported a .json file that includes all the local bone rotation of the pose.

So I search for the correct rotation info by iterate through the bones and set the rotation using:

allBones[i].rotateX(THREE.Math.degToRad(BoneArrayFromJson[j].X));
allBones[i].rotateY(THREE.Math.degToRad(BoneArrayFromJson[j].Y));
allBones[i].rotateZ(THREE.Math.degToRad(BoneArrayFromJson[j].Z));

I have to convert the from maya delivered degrees into radians.

However, my problem is that the pose looks wrong in the end.

This is how it looks like:
image

This is how it should look like:
image

What could be the problem? The json data is correct.

Maybe it is important to say that the local bones are not having a 0,0,0 rotation. For example, lets say the left upper leg has a rotation of -5,180,-160 (degree) in maya.

Here is a snippet of the .json data file:

...
"Bones": [
{
"name": "Root01",
"X": "3.178070001e-15",
"Y": "-1.256946762e-16",
"Z": "4.529807612"`
},
{
"name": "Root",
"X": "4.783768464e-16",
"Y": "1.00713629e-14",
"Z": "3.404273577"
}
]
...

Greets :slight_smile:


#2

Without looking extremely closely at your scene in Maya, the exported glTF, and the JSON, it’s hard to guess why this isn’t working or even whether it’s a safe approach. For example, the exporter may be making changes to the bones at export, so that they’re no longer ordered like they were in Maya. I’m not confident we can help you with that direction.

If you’re just trying to reach a pose, could you export that as a single-frame animation and apply it immediately rather than playing the animation? That sounds more robust to me; see discussion of animation workflows here: Gltf: Complex animation workflow?


#3

Hi, thank you for your reply. I do understand that you need more information.

I agree with you but what if I want to change the character ? I don’t want to set the pose animations in maya for every character. The json pose file should act like a pose database so that human rigged characters can just ask for their skeleton bone rotation.

How could I solve this ?

Greets


#4

It turned out that i had to change the order of rotation from xyz to zyx.

Greets :slight_smile: