- 수정됨
"Persistently" modifiy animation file programmatically
I've had some animator draw and animate some characters for me. The project had some "difficulties", and so I chose to close it despite some "issues" with the end-result.
If I remember well, it says somewhere that Spine supports both a binary format and a text format. And there are multiple runtimes reading the Spine files (binary, text, both?).
My question is:
Is it possible, using one of the runtimes (official or third-party), to read the spine file, modify it programmatically, and save it again, as a "one time migration process"?
Specifically, the animator made the characters look to the left, while they should have looked to the right. I assume I could just fix this at runtime, by mirroring the animation, but I think that having to permanently keep in mind that everything is "backward" is going to raise the probability of errors while ordering more animations and characters from (other) animators, and while coding.
So my idea was to go over the graphics, and mirror each of them manually once, and then use some "script" that mirror the animations themselves, so that everything is consistent again.
My long-term "plan" was to have one single set of animation for all characters, and this brings up an additional similar issue. Once I have all my graphics and animations for "humans", I'd like to run some script on them that performs a non-proportional scaling, so that the animations can also be used on "dwarves" (same width, but shorter). This kind of manipulation can only work in certain situations, that is when the "direction" of the scaling matches exactly the "physical orientation of all original graphics files" (for examples, the arm texture has to have the arm point vertically, rather then horizontally). Therefore I don't expect this to become a Spine feature either.
That would be my second use-case for a programmatic manipulation of the Spine files, at "build time", if you will, rather then at run-time.
If it's possible, I'd greatly appreciate if someone knows of an example script/program that does something similar.
No comment on automation/scripting.
Also, your intention of flipping the character from left to right is not something that's been implemented. But I agree that it would be a nice in-editor feature, precisely for cases similar to what you mentioned: where the animator accidentally made the assets and Spine project and lots of progress with animations with the character facing left, where it should have been facing right for uniformity's sake. (I agree, flipping the character should also involve flipping the individual images, and that this process should be destructive/actually change the data in the skeleton and all animations.)
If you were to implement such a thing yourself for jsons, you could import it in the editor to save it back into the project and further edits can be made going forward. (I hope you understand the different file types the editor and the runtimes use.)
Currently, one (band-aid) solution is to use bone FlipX.
In setup mode in the editor, flipping the root bone should achieve a usable result as long as it stayed at (0,0).
Ok, so none of the runtimes have code to write JSON or binary. If I were to guess, I would suspect that there's a java version hidden with the editor source code.
So what I did was write a quick reader/writer utility:
https://github.com/jpoag/spine-process
It's not done. I got all the way through writing the SkeletonData and just stopped at the animation/events data. At this point, I would probably jump dump the previous JSON animation/events data although it would violate the spirit of an offline build time processing tool...