roundcrisis

Hi there

So I had some code that to scale something would do:
_skeleton.RootBone.ScaleX = scale;
_skeleton.RootBone.ScaleY = scale;
However this seems to not work anymore, ie if you try that on the XNA example the animation moves through X and Y :(
To scale instead you have to iterate over all the Bones and apply scaling like this
foreach (var bone in _skeleton.Bones)
{
bone.ScaleX = scaleTemp;
bone.ScaleY = scaleTemp;
}
This is the case since commit from 27/05/2013
6c784ec0cd17a232146e2b9092ea8250e15b3c7a

* Added bone inherit rotation and scale in csharp

Just mimicked the changes in spine-libgdx and your code pattern in c#.
Working fine in Unity.
It makes sense that the scaling is per bone but it caught me off guard , I would say is a potential source of many bugs, maybe there is a better way to express this in code simply, maybe adding a method in skeleton? ScaleAllBones(float scale) at least seeing the method in there would flag that this is the way to do this.

Cheers
roundcrisis
  • Сообщения: 12

Nate

inheritScale and inheritRotation are set to true in SkeletonJson unless they are set to false in the JSON. Setting a scale on the root should work fine. Doing so on the XNA example works correctly.
Аватара пользователя
Nate

Nate
  • Сообщения: 11260

roundcrisis

yes, it does work unless you set InheritScale to false (which we needed to do) , if you do and use
_skeleton.RootBone.ScaleX = scale;
_skeleton.RootBone.ScaleY = scale;
the animation will move along X and Y as opposed to scaling.
roundcrisis
  • Сообщения: 12

Nate

Well, the root bone will be scaled and the children won't if they don't inherit.
Аватара пользователя
Nate

Nate
  • Сообщения: 11260

BraveSirAndrew

We're having this problem too. The problem is that we need to apply a world scale to an entire skeleton depending on it's Z position in the scene, and we can't do that by simply applying a scale to the root bone because InheritScale is turned off on some of our animations. The reason it's turned off is that we have lots of torso twisting animations for which we use scaling between different frames to increase the illusion of twisting, but we don't want the arms to also have that scaling applied.

So in a nutshell, with the current runtime, how would we apply a world scale factor when InheritScale is false?
BraveSirAndrew
  • Сообщения: 1

Nate

Ah, makes sense. Seems like this would be a new feature:
https://trello.com/c/GnP77yOA/46-skelet ... e-rotation
Аватара пользователя
Nate

Nate
  • Сообщения: 11260

roundcrisis

Cool, good to know
roundcrisis
  • Сообщения: 12


Вернуться в Editor