XGen uses XPD files for per-primitive data baking. This format is specifically designed for use in the case where thousands, if not hundreds of thousands, of primitives need to have values stored. The format stresses space saving but also improves read performance. While writing the files is not slow, performance is definitely tweaked to provide the best possible read performance.
The XPD file is broken into four main pieces: header, face, block, and primitive. The header consists of data describing the contents of the file. It is laid out as follows:
Immediately following the header is the primitive data. The data is laid out in face order (as defined by the header). Within each face, the data is laid out in block order (as defined by the header). Each block must be present in each face and in the proper order. Within the block lies the primitives. The primitive itself is just a vector of floats. The writer provides the vector, and it knows the order of the data, as well as how to unpack it. The reader reads in a single primitive at a time and then, using the primitive version, knows how to unpack the data. There is no header per face or per block. In reality, after the file header, the file is a constant stream of primitive data.
When reading the file, you must find the face you want, find the block you want, and then read the primitives in order. Once you read all the primitives you want, you can then find the next block and read the primitive data that matches up with the previous block. The blocking structure allows an application (such as Paint3d) to export the data XGen needs in one block (for example, Location), but then export data it needs into its own block (for example, PointCloud ). XGen can then read only the data it needs and easily skip over the other data. Furthermore, both applications can own their data format without having to negotiate with the other.
There are a couple of programs available to help with using XPD files. One of these is xpd2txt. This program converts the binary data within the XPD file into a text format that is easily readable. This can also be used to convert the data to a form that can then be parsed and used by production scripts (for example, to convert the data to Inventor format, or read it into Maya). Another program is xpdcmp, which can compare two XPD files to verify if they are the same. This program compares the content of the files, which includes the number of faces, blocks, keys, primitives, and so forth, but does not compare actual primitive values. Therefore, it can be used to verify that a file is “compatible” with another, but not to see if the files are identical.
Five examples are provided in the XGen source code to read and write XPD files that hold primitives of type Point. This is also referred to as a XUV file. Typically, this type of file is created in Paint3d and used to drive either primitive locations (for example, using the PointGenerator ) or clump locations (that is, via the Clumping FX Module).
The examples can be found in the following Maya install directory: C:\Program Files\Autodesk\Maya<version>\plug-ins\xgen\devkit\xpdSamples.
Another special type of XPD file is the curve/guide file targeted for Paint3d consumption. This is a lighter file that contains the id, u, v, and CVs for each primitive, but does not contain any other XGen bake information that Paint3d does not need. This lighter format allows Paint3d to use a format that it can load without worrying about changes to XGen's baking format. This format can be detected by checking the blocks and finding one called “Paint3d”.