Convert mesh data exported from SpriteUV2 to a format that can be imported by Spine

I wrote a conversion program (python) like the title. There are some parts that are not good, but I will publish it because there seems to be demand now.

suv2spine https://github.com/harayoki/suv2spine

Prank

SpriteUV2 has an excellent function of integrating multiple Spine data, but it does not export the mesh data generated by itself as data that can be imported by Spine. (Why!) Well, I believe that it will be supported from now on, but when I check the contents of the json data to be written out for general purposes, it is relatively close to the data format that can be read by Spine, so it is possible to perform conversion processing with a simple program. I can do it.

The point to note here is that when comparing the two data

That's about it. The last item will be described later.

How to use

 2017-05-01 0.07.43.png First, generate a mesh with SpriteUV2 and export it as json data together with atlas data.

Download the python script on github (https://github.com/harayoki/suv2spine/blob/master/suv2spine.py), give execute permission, and then execute the conversion process.

./suv2spine hoge.json

hoge.json is a json file exported by SpriteUV2. This process will generate a converted file called hoge_out.json. (You can also specify the output file name with the -o option. For other options, refer to the README on the github side.)

 2017-05-01 0.29.16.png Launch Spine and select ʻimport Data` from the Spine menu.

 2017-05-01 0.28.11.png The import dialog will be displayed. Select the json output by the converter and press OK. You can also adjust the import size and specify the skeleton name after importing here. Now, if you want to add a skeleton to your current project instead of creating a new project, uncheck New Project.

 2017-05-01 0.28.51.png A warning will be displayed in a dialog like this here, but since this is the specification of this conversion program, it is OK as it is. The content of the warning is something like "It seems that the data of the mesh outline and mesh dividing line has not been exported, so it will be recreated automatically".

 2017-05-01 0.37.15.png The loading is completed like this. If the image is out of reference and only the mesh shape is displayed, please set it again manually. Reset the path to the Images folder, but select the mesh to change the displayed path.

Disclaimer

First of all, this converter does not support conversion of multiple meshes. Perform the conversion for each mesh. (If multiple meshes are included in the SpriteUV2 export data, only the first one will be converted.)

Also, if you load a very fine mesh, the outline shape may become strange. In this example as well, the shape on the left side of the head horn is strange.

 2017-05-01 0.44.10.png

If that happens, I think it will be necessary to adjust the mesh on the SpriteUV2 side or the Spine side. Also, although it is okay in the above, the gap between the legs was sometimes recognized as part of the mesh. It may be better to prepare the original image so that holes will not be opened when setting the mesh as much as possible.

The reason for this problem is that on the Spine side, in addition to the vertex data list, we expect that there will be a list of outer vertices (hull) and line segment (edges) data connecting the vertices. However, it is difficult to reproduce the data from the json that SpriteUV2 spits out. For the time being, they are not essential data, but data that can be automatically generated by Spine (the warning in the previous dialog that I will do it), so even in this case it will work like that, but automatic generation is If it doesn't work, it seems that the above situation will occur.

It's been about 10 years since I wrote decent Python code, so please keep an eye on it. mm

from now on

In the first place, it would be nice if Spine's automatic mesh generation function seems to work, or SpriteUV2 supports Spine data export. Regarding this tool, if there is demand, it may or may not support conversion of multiple meshes.

Recommended Posts

Convert mesh data exported from SpriteUV2 to a format that can be imported by Spine
Convert images from FlyCapture SDK to a form that can be used with openCV
Features that can be extracted from time series data
How to create a property of relations that can be prefetch_related by specific conditions
A mechanism to call a Ruby method from Python that can be done in 200 lines
Implement a thread that can be paused by exploiting yield
[Graduation from article scattering] I tried to develop a service that can list articles by purpose
Convert GRIB2 format weather data that cannot be opened with pygrib to netCDF and visualize it
Can I be a data scientist?
[Python] A program that finds a pair that can be divided by a specified value
I made a simple timer that can be started from the terminal
Convert xml format data to txt format data (yolov3)
How to easily convert format from Markdown
A memo for making a figure that can be posted to a journal with matplotlib
I want to create a priority queue that can be updated in Python (2.7)
Aggregate steps by day from iPhone healthcare data to create a CSV file
Convert json format data to txt (using yolo)
I tried to make a memo app that can be pomodoro, but a reflection record
From a book that programmers can learn: Converting characters that represent numbers to integer types