- 編集済み
question about interpolation
I am adding Spine support and almost done. However, here is an interpolation problem and I need some advice.
I use example-animation.json for my demo, and here is animation definition for "right shoulder" bone:
"right shoulder": {
"rotate": {
"0": {
"angle": "20.89",
"curve": [ "0.264", "0", "0.75", "1" ]
},
"0.1333": {
"angle": "3.72",
"curve": [ "0.272", "0", "0.841", "1" ]
},
"0.6666": { "angle": "-278.28" },
"1.0666": { "angle": "20.89" }
},
"translate": {
"0": { "x": "-7.84", "y": "7.19" },
"0.1333": { "x": "-6.36", "y": "6.42" },
"0.6666": { "x": "-11.07", "y": "5.25" },
"1.0666": { "x": "-7.84", "y": "7.19" }
}
},
focus on the third rotate key frame: "0.6666": { "angle": "-278.28" }, its value is -278.28, previous key value is 3.72, so I interpolate between 3.72 and -278.28. However, the result is not correct, if I change -278.28 to 81.72(just add 360), everything goes ok. I understand -278.28 is same as 81.72, but it affects the interpolation. How do I know which value should be used?
After interpolation but before applying the rotation to the bind pose, use:
while (amount > 180)
amount -= 360;
while (amount < -180)
amount += 360;
Spine simplifies rotation by rotating the shorter distance. This means to control the spin direction for a rotation > 180 you will need 2 keys. Eg, to rotate 270 you'll need a key that rotates 100 and another that rotates 170.