BinaryCats

                Skeleton Merger Tool

Recently (and in the past), there has been quite a few threads of people wanting to merge two (or more) skeletons into one. Spine allows you to create multiple skeletons in one project. Unfortunately spine does not allow you to take bones from one skeleton and copy them across to another skeleton. Spine also restricts copying key frames, in that you can not paste key frames to another skeleton.

I bring to you, Skeleton Merger Tool!

Download(beta)

What does it do?
The Skeleton Merger Tool (SMT) will take two Spine skeletons and merge them into one skeleton.

Can't I Do This My Self... Why should I use this tool?
Sure you can! Lots of cases it can just be copy/paste of one json into another. The problem comes with meshes however, rearranging vertices would be pretty time consuming and annoying. (see next question)

Why isn't this officially supported by the Spine editor?
My best guess is that this could potentially take A LONG time, remapping vertices is probably the most expensive operation. Each vertices in SkinnedMeshs (mesh with weights) is tied to a bone ID, and the bone ID is related to the position of the bone in the bone list. As you are adding new bones to that list, all of those vertices bone ID need to change. And to make things worse those bone IDs are deeply nested in data types. Also Spine would need to deal with name conflicts on animations, bones, skins and slots.

If Spine supported this, it would also have to support splitting up of skeletons, which (im pretty sure) could take much more time.

How does Skeleton Merger Tool deal with name conflicts
If you have name conflicts between the two(on Bones, Slots, Skins or Animations), SMT will resolve them by adding a number at the end of the name, it will increase the number until the name is unique.

For Example:
Skeleton1
bone1
bone2

Skeleton2
bone1

Merged skeleton
bone1
bone2
bone3

I feel like this could be done in a better way, I am open to suggestions.

Can SMT Merge animations and skins?
Currently, no. The reason is, once both your skeletons are merged, you can copy keyframes to the original animation if you want. Or in the case for skins, apply two skins at runtime.

This being said, it is planned in a future update to add command flags to allow you to merge skins and animations.

Is there a preview window?
No, I felt like adding this would make the tool a little too much like the spine editor. If I get express permission from Esoteric Software I may add one. Although adding it will be low priority.

Can SMT Split skeletons into new skeletons?
No. Reason is, I feel like this would be a conflict of interest with my work. Can't go into detail, sorry. My work was kind enough to let me release this though :) .
(maybe in future though)

How do I use SMT?
  1. !!BACK UP!!
  2. Run the .exe
  3. Enter the directory of the skeleton you want to merge
  4. Enter the directory of the skeleton you want to merge to.
    (The output will be in the same directory)
  5. import merged skeleton .json

Any Future Plans / will this be supported?
I will be supporting it, however I have limited free time (sorry). If any major bugs pop up I will try to address them immediately.

Things I plan to do:
  1. Add support to merge skeletons from .spine file
  2. Add Merge Flags to merge animations/skins
  3. Better Bone Ordering

Things that I might do:
  1. Merge hierarchy of bones to a skeleton
  2. Load/Save skeletons/bones
  3. Add a GUI

Please feel free to request things and I will (probably) add them to the list.

Need something urgently? PM me and reply to this thread, maybe we can arrange something :happy: .

Will This be open source?
Hmmm, this one is unanswered. I would like to make it open source, but before that happens I need to finalise how the data is stored.

Download
Not yet, soon. [edit] I accidentally posted this, I meant to preview, rather than delete I will just update when I release the tool (should be a day or two....?). The current state of the tool is that it works, for bones, meshes, slots, attachments and skins. I'm currently working on getting animations to merge.

--
appendix
[i]The way I have read and stored the json file (skeleton to merge) means that the bones will be in a different order, their hierarchy should remain the same. This is not a problem for spine Versions 2.1.27 or 2.1.7. Any other version the merger may not work. I will update if this changes in V3.

I would also recommend that you always import to spine and do a fresh export before using the merged skeletons.
User avatar
BinaryCats
Posts: 1299

Xelnath

Keep at it! Awesome people who support stuff like this make development better for everyone!
Xelnath
Posts: 407

BinaryCats

        SMT 0.01 Download (beta)


Here is the first Release of the SMT: Download

(It is in beta as I have not tested the current version with spine, as I do not own a copy. I will remove the beta status on conformation that it is working as intended)
-- Just tested, This will work if you don't have any scales on your skeleton or images. Will fix tonight so it will write out the correct scale.

SMT 0.01 installer will install the program to the desktop. ( C:\Users\Public\Desktop\BinaryCats ). Inside the instillation folder will contain two sub folders (Input and Output) and the .exe. Inside the Input folder there will be an example .json file which you can test, that file is called SkeletonBasic.

To use SMT
  1. Place the skeleton(s) you want to merge in the Input directory - C:\Users\Public\Desktop\BinaryCats\Input
  2. Run the .exe - You may need to run as administrator if SMT does not output a file.
  3. Enter the first skeletons name - Do not include the file extension (.json)
  4. Enter the second skeletons name - Do not include the file extension (.json)
  5. Locate your merged file, and import it into spine.


Loading the first skeleton and info


Loading the second skeleton and outputtin

I want to add more usability to this program, if you have any suggestions, please let me know.


Avast Antivirus Users
It seems Avast has a 'deep screen' mode which targets unknown applications and prevents them from exporting. You may have to turn of the File system shield to allow SMT to output a file. From Avast Settings menu: Active Protection>File system shield>Off>10Mins .

I am aware that this isn't a solution and am currently working to resolve this issue. Sorry.
User avatar
BinaryCats
Posts: 1299

mfedorov

TY!
exe extentions is not good )
source language?
User avatar
mfedorov
Posts: 227

BinaryCats

[quote="mfedorov"][/quote]
Sorry I removed it from my drop box, then forgot to upload the new one. Check back in 3 hours when im home ands it will be uploaded (hopfully), I will zip the .exe up, hopfully it wont be flagged as a virus then :(

Language is c++, but I doubt the source will be released soon

---

updated Download link
User avatar
BinaryCats
Posts: 1299

DoobyDude

Has anyone tried using this?

I keep getting "Unable to write json file" errors, using the sample json file and a simple one of my own with 1 bone in it.

Is there any other way to merge 2 skeletons into one project (maybe each skeleton under a new master bone)?

I know I can Import them into a new project, but I need to be able to have them all within the same draworder to be able to go infront/behind/in between the other skeleton.
DoobyDude
Posts: 111

BinaryCats

DoobyDude wrote:Has anyone tried using this?

I keep getting "Unable to write json file" errors, using the sample json file and a simple one of my own with 1 bone in it.

Is there any other way to merge 2 skeletons into one project (maybe each skeleton under a new master bone)?

I know I can Import them into a new project, but I need to be able to have them all within the same draworder to be able to go infront/behind/in between the other skeleton.
Are you running in admin? (i.e. right click, run as admin)

Second question: you would need to edit the jsons manually, which is the purpose of this tool.
User avatar
BinaryCats
Posts: 1299

DoobyDude

BinaryCats wrote:Are you running in admin? (i.e. right click, run as admin)

Second question: you would need to edit the jsons manually, which is the purpose of this tool.
Ah no I wasn't - running as admin does indeed fix the error message.

Sadly, I am using Spine v1.6.42 so the exported file after merging will not import back into Spine as I think you said you only support back to v2.1.x.
DoobyDude
Posts: 111

BinaryCats

DoobyDude wrote:
BinaryCats wrote:Are you running in admin? (i.e. right click, run as admin)

Second question: you would need to edit the jsons manually, which is the purpose of this tool.
Ah no I wasn't - running as admin does indeed fix the error message.

Sadly, I am using Spine v1.6.42 so the exported file after merging will not import back into Spine as I think you said you only support back to v2.1.x.
It might work, I am just unable to test it :( .

(there is a known bug with meshes. I don't know what is causing it, yet, however. Sometimes it works, sometimes it doesn't (depending on the project :/). If it merges sucsessfully, but doesn't import try making meshes images, sorry I know this isn't a solution, but im trying to work on it)
User avatar
BinaryCats
Posts: 1299

DoobyDude

BinaryCats wrote:It might work, I am just unable to test it :( .

(there is a known bug with meshes. I don't know what is causing it, yet, however. Sometimes it works, sometimes it doesn't (depending on the project :/). If it merges sucsessfully, but doesn't import try making meshes images, sorry I know this isn't a solution, but im trying to work on it)
No it doesn't work - I did test before I posted.
To clarify - the merge works fine, but it then won't import back into Spine.

I don't use any meshes or anything like that as they aren't supported in my version - just images, bones and SRT.

This is probably why your merged json doesn't import correctly - there is too much extra information in the json that v1.6 just isn't expecting (meshes etc as you say)
DoobyDude
Posts: 111

BinaryCats

DoobyDude wrote:
BinaryCats wrote:It might work, I am just unable to test it :( .

(there is a known bug with meshes. I don't know what is causing it, yet, however. Sometimes it works, sometimes it doesn't (depending on the project :/). If it merges sucsessfully, but doesn't import try making meshes images, sorry I know this isn't a solution, but im trying to work on it)
No it doesn't work - I did test before I posted.
To clarify - the merge works fine, but it then won't import back into Spine.

I don't use any meshes or anything like that as they aren't supported in my version - just images, bones and SRT.

This is probably why your merged json doesn't import correctly - there is too much extra information in the json that v1.6 just isn't expecting (meshes etc as you say)
Im sorry to hear that. Would you mind posting the Merged.json, or pming it me? There may be an error I can fix :)
User avatar
BinaryCats
Posts: 1299

DoobyDude

BinaryCats wrote:Im sorry to hear that. Would you mind posting the Merged.json, or pming it me? There may be an error I can fix :)
I've PM'd you with a link to the files.
DoobyDude
Posts: 111

BinaryCats

seems to be some error with renamed bones and Animations, I will look into it tonight :) I have fixed the merged json and messaged it to you.

(although the animations will be borked. as the broken bone (in the data) was named toroot. Cut the root key frames and paste them onto the desired bone)
User avatar
BinaryCats
Posts: 1299

Octominion

Just used tool to merge 2 skeletons in one file - awesome time saver!!!!!!!!!
Octominion
Posts: 1

DoobyDude

BinaryCats wrote:seems to be some error with renamed bones and Animations, I will look into it tonight :)
That would be awesome!

Thanks for your time, I appreciate it.

---

BinaryCats, have you had chance to look into the error yet?
DoobyDude
Posts: 111

BinaryCats

I sent you the message :)

---

I have fixed a bug or two

https://www.dropbox.com/s/cgov80hw8htj3ee/Skeleton%20Merger%20Tool.zip?dl=1
User avatar
BinaryCats
Posts: 1299

DoobyDude

Thanks man, I will check when I get some time over the next few days and let you know how I get on.

I appreciate your time and help! :)

---

I've used the updated version of the tool to merge a few different json files now and everything seems to be working fine! :)

Only thing I don't like is all the spaces/tabs(?) inserted into the exported json when compared to the json output from Spine - but I've just realised this is a none-issue as you will be exporting from Spine after merging anyway lol!

Thanks for a great tool, it will save me a LOT of time as I have a lot of things I need to merge, so I will keep you updated as to how it performs and if I find any bugs or not.

Thanks again!
DoobyDude
Posts: 111

BinaryCats

Eh, that's because I exported it with pretty print on. So I could easily debug stuff. If you import into spine, and re-export it will go back to normal ( I recommend doing that anyway)

:) Thanks :)
User avatar
BinaryCats
Posts: 1299

DoobyDude

Haha yeah I realised a minute after I posted - idiot.

I think I spoke a little too soon, I have a crash trying to merge 2 files.

Both files work if I input them first, they report correct bones, animations etc, but when I add the second file the program crashes.
I have PM'd you a link to the offending files. :)
DoobyDude
Posts: 111

BinaryCats

Thanks, I'll look into it. I wish spine would give some proper documentation on their json exports :Z
User avatar
BinaryCats
Posts: 1299

mfedorov

Make some hard tests. Now merged with huge meshes is work with bugs.
User avatar
mfedorov
Posts: 227

BinaryCats

Development can be quite slow, due to the reason I do not own a copy of spine, so I have to wait until I get into work to test my changes. And I tested the tool with our most complicated skeletons at work, which work.
User avatar
BinaryCats
Posts: 1299

DoobyDude

Got a couple more files that break the merger.

Lots of green garbled text scrolling down the window accompanied by a beeping noise and an eventual crash.

Have PM'd the files :)
DoobyDude
Posts: 111

BinaryCats

DoobyDude wrote:Got a couple more files that break the merger.

Lots of green garbled text scrolling down the window accompanied by a beeping noise and an eventual crash.

Have PM'd the files :)
What?! That's not good! I'll fix straight way sorry

---

I have fixed the issues. Needs testing though. I do not own spine.
User avatar
BinaryCats
Posts: 1299

levallee

Any chance of a mac version of the Skeleton Merger Tool ? :)
levallee
Posts: 11


Return to Editor