i20_Leikir

Hello,

I'm currently working on a tool and i'm stuck at understanding how the vertex data works in the json file.

Without getting into too much details, i would like to read data from the json file exported from spine to unity to rebuild the mesh in a 3D software using uv coordinates from the atlas generated by spine.

The goal is to bake several other textures using the same atlas coordinates from spine after the asset is done with animation.

I had no problem creating the card used for rigid parts of the assets and match the uvs but i have difficulties understanding vertices data for skinned geometry.

I seems to me that there is a sequence of 4 or 5 number:
2 int or sometime one which i think are bone influence,
then 2 floats which i think are x and y coordinates
and a float between 0 and 1, which i belive is weight between two bone influences ?
"vertices": [2, 2, -9.8, 103.38, 0.5, 4, 37.82, 27.79, 0.5, 2, 2, -3.82, 100.39, 0.5, 4, 42.16, 22.71, 0.5 ...
By ignoring what i think is bone influence data i can create a mesh that kinda have the expected shape, but there is much more vertices than in spine and triangle index is all wrong.

Is there an example somewhere so i can understand how to import vertex coordinates ? i tried looking into the unity plugin but i couldn't find where vertices are processed (i looked mainly into MeshGenerator.cs )

if i can't make sense of the vertices, i think i can make a simple bounding box with min and max coordinates because i don't need to import the complete animation and deformation, but it would be nicer to have a matching mesh.

Thank you for reading me :)

---

I made a little bit of progress, if i ignore sequences of vertices that start by a single int instead of two i almost have the correct geometry, except a couple random ones out of place.
i20_Leikir
  • Posts: 2

Harald

There is a JSON format documentation page available here:
Spine: JSON export format
Unfortunately, as Nate mentioned on this forum posting a week ago, we didn't get to update the JSON format documentation page from 4.0 to 4.1 yet. :wounded:

Regarding examples: the most reliable example would be the code in SkeletonJson.cs:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/spine-csharp/src/SkeletonJson.cs
I would recommend to set breakpoints in the relevant sections that you want to replicate and step through it, using your skeleton .json test file.
User avatar
Harald

Harri
  • Posts: 4459

i20_Leikir

Great !
I see in the doc that i wasn't that far off, i think that will do the trick
Thank you very much for pointing to the adequate resources !
i20_Leikir
  • Posts: 2

Harald

You're very welcome, glad it helped!
User avatar
Harald

Harri
  • Posts: 4459


Return to Unity