Now that we have a format for packed images, we can use it for external tools.
While the format is defined by a Protobuf format file our TexturePacker exporter is actually just outputting raw text.
The format file is located here: tpinfo.proto
and we use that to read the .tpinfo
files.
There is also a tpatlas.proto if you wish to generate .tpatlas
files directly.
For instance if you wish to define a lot of animations up front.
If you write your own generator, please output valid information in the version
and description
fields.
This will make it a lot easier for everyone to determine which tool (and version thereof) generated the file, and helps when debugging.
The format supports using one or more pages. In the Defold engine, it is assumed that all pages have the same dimensions. Each page holds the corresponding list of Sprites.
Sprites hold the layout data for each page. Due to the nature of texture packing, there may be multiple sprites that refer to the same area in the texture page. Beware though that when generating the sprite layout data, there may be adjacent sprites occupying the texture, so make sure your sprite geometry doesn't intersect with other sprite geometry.
The fields of the Sprite struct (see tpinfo.proto), is heavily influenced by the TexturePacker exporter api. Documentation for each field is in our proto file, and for further explanation, we refer to their documentation.
Each sprite holds lists of vertices and indices as a result of polygonal packing.
The vertices are specified in source image space. I.e. in pixels, and not rotated.
The indices list holds indices into the vertices list, and every 3 indices form a CCW triangle.
If the vertices or indices list are empty, a rectangular geometry is automatically generated.