Hello,
first of all I am aware of this topic http://en.esotericsoftware.com/forum/Spine-Unity-3-8-to-4-0-Upgrade-Guide-15981 and BAT script in your git repository, but it doesn't suite us well.
I was wondering if it's possible to convert exported skeletons in JSON format from 3.7 version to JSON usable by 4.1 run time.
I did some test exports in 3.7 and 4.1 to compare the results and it seems like most of the thing is just renaming keys and converting some objects into array etc., but got stopped by bezier curves. From run time source codes I see that it was converted from percentage change into absolute values in times but no luck with coming out with formula to convert them.
Could someone poke me right direction or is it not possible to convert them without opening the project itself? So far i was able to find cx1, cx2, cy1 and cy2, or at least it works with my test exports.
Here is my test animation from one of my 3.7 JSON exports and same animation in 4.1 version.
const testAnim = [
{ "time": 0, "x": 0, "y": 0, "curve": "stepped" },
{
"time": 0.35,
"x": 0,
"y": 0,
"curve": [ 0.102, 0.49, 0.603, 0.99 ]
},
{ "time": 0.6667, "x": -62.94, "y": 560.21 },
{ "time": 0.7667, "x": -92.76, "y": 586.53 },
{ "time": 0.8167, "x": -175.05, "y": 371.35 },
{ "time": 0.9, "x": -187.26, "y": 12.7 },
{
"time": 1.0833,
"x": 33.09,
"y": 134.88,
"curve": [ 0.081, 0.44, 0.75, 1 ]
},
{
"time": 1.2167,
"x": -6.67,
"y": 85.45,
"curve": [ 0.25, 0, 0.75, 1 ]
},
{ "time": 1.5833, "x": -8.49, "y": 58.03 }
];
const referenceAnim = [
{ "curve": "stepped" },
{
"time": 0.35,
"curve": [ 0.382, -31.11, 0.541, -62.13, 0.382, 276.88, 0.541, 553.03 ]
},
{ "time": 0.6667, "x": -62.94, "y": 560.21 },
{ "time": 0.7667, "x": -92.76, "y": 586.53 },
{ "time": 0.8167, "x": -175.05, "y": 371.35 },
{ "time": 0.9, "x": -187.26, "y": 12.7 },
{
"time": 1.0833,
"x": 33.09,
"y": 134.88,
"curve": [ 1.094, 15.65, 1.183, -6.67, 1.094, 113.2, 1.183, 85.45 ]
},
{
"time": 1.2167,
"x": -6.67,
"y": 85.45,
"curve": [ 1.308, -6.67, 1.492, -8.49, 1.308, 85.45, 1.492, 58.03 ]
},
{ "time": 1.5833, "x": -8.49, "y": 58.03 }
];
This works as far as 3.7 curve's cy1 and cy2 are 0 and 1. Where frame is testAnim[n] and nextFrame is testAnim[n + 1].
const curve41 = [
frame.time + (frame.curve[0] * (nextFrame.time - frame.time)), // cx1 for x value
frame.x, // cy1 for x value
frame.time + (frame.curve[0] * (nextFrame.time - frame.time)), // cx2 for x value
nextFrame.x, // cy2 for x value
frame.time + (frame.curve[0] * (nextFrame.time - frame.time)), // cx1 for y value
frame.y, // cy1 for y value
frame.time + (frame.curve[0] * (nextFrame.time - frame.time)), // cx2 for y value
nextFrame.y, // cy2 for y value
];
Thanks in advance.