Connected objects to bones get scaled


#1

I am testing a bit with the bsframework and created a human model and a sword in Blender. I wrote a little program, so that the human should hold the sword.

You can see my try here:

In the code there a two line commented out (line 194 and 195), this first picture shows the result without these lines:

The second screenshot shows the result with line 195 commented in. The sword is now connected to the hand bone, but is scaled huge:

For the third screenshot I commented in line 194 and scaled the sword node:

Is there something I am missing, that the sword gets scaled if I connect it to the bone?

And second I am wondering about the scaling values. I had expected values smaller than 1. With values greater 1 I had expected the the object gets bigger.


#2

Is that model something you can share? If I can test locally I can give you a proper answer.

It is probably some combination of very large scale in the model itself, its bind pose and/or animation clips that doesn’t get properly applied to the bone. Scale of 100 is likely smaller than what’s given to it by animation. But in short it is almost certainly a bug somewhere in the framework.


#3

I’ve investigated your issue and I believe this is what’s happening:

Both human.fbx and sword.fbx have a scale of 100 in their root node. Their vertices are scaled to 0.01, so both of those cancel out in normal circumstances. So everything looks appropriately sized when they are used individually. Everything good so far.

However when you parent the sword to the human, it inherits the 100 scale, making the sword 100 times larger.

Setting the scale of the parent node to 100 fixes this because the re-parenting process will (by default) try to perserve the world transform of the child object. So in this code this happens:

	// Parent now has scale 100
	handRightNode->setScale(Vector3(100.0f, 100.0f, 100.0f));

	// Sword node has a scale of 1 before parenting, but when parented it will have a scale of 0.01
	// (because the parent has a scale of 100, and 100 & 0.01 cancel out, perserving the original scale of the sword node which is 1)
	swordNode->setParent(handRightNode)

Since the sword node now has a scale of 0.01, it now cancels out with the human’s root node scale of 100.

This would be the more intuitive, but equivalent, approach:

	swordNode->setParent(handRightNode);
	swordNode->setScale(Vector3(0.01f, 0.01f, 0.01f));

#4

Thanks for your investigation. Is is really an issue with the Blender FBX export.

There is an option “Apply Scalings” in the export dialog and one has to choose “FBX all” instead of the default “All local”. This seems OK for me.

Found in this article:


#5

Yes, you need to apply all transformations before exporting. This apply to any 3D tools and not just Blender. Cool to see you were still able to make it work directly out of code!