TinyXPD is a simple library to read/write XGen XPD cache file.
Currently reading/writing spline XPD data is implemented.
- C++11 compiler
- macOS
- Linux
- Windows(Visual Studio 2017 or later)
- Android
- iOS
- Big endian machine(e.g. POWER)
- XPD3(~Maya 2018)
+-----------------------------+ |\
| XPD header | |
+-----------------------------+ | XPD data
| | |
| XPD prim data | |
| | |
| | |
+-----------------------------+ |/
XPDHeader
contains header information and the list of data offset from the beginning of a XPD data.
Whole XPD data is supplied by the app user(ParseXPDHeaderFromMemory
API), or read from a file(ParseXPDFromFile
).
ParseXPDFromFile
API is handy but consumes memory.
If you want to open large XPD file(e.g. 1GB or more), consider using ParseXPDHeaderFromMemory
API(with mmap-ping a XPD data).
// Do this only in **one** .cc file.
#define TINY_XPD_IMPLEMENTATION
#include "tiny_xpd.h"
std::string filename = "sample.xpd";
XPDHeader xpd_header;
std::vector<uint8_t> xpd_data;
std::string err;
bool ret = ParseXPDFromFile(filename, &xpd_header, &xpd_data, &err);
// From memory(stream) version.
// Fill xpd_data by yourself in some way.
// xpd_data = ...
// bool ret = ParseXPDHeader(xpd_data.data(), xpd_data.size(), &xpd_header, &err);
if (!err.empty()) {
std::cerr << err << std::endl;
}
if (!ret) {
std::cerr << "Failed to parse XPD" << std::endl;
}
// See `xpd_reader_example.cc` for how to access primitive data.
- examples/simple_sprine_writer Simple spline XPD writer example.
You can use xgSplineDataToXpd
sample plug-in(located in /usr/autodesk/maya/plug-ins/xgen/plug-ins/
or write your own XPD writer plugin.
It looks legaxy XGen's From XPD File
feature expects that spline data layout is as defined in xgSplineDataToXpd
sample code.
Data layout used in xgSplineDataToXpd
example does not support exporting per-CV width. It can only support constant width over CVs(strand), and taper. width ramp
is not support.
If you need a spline curve with varying width, you may need to write your own XGen loader(generator) plugin, or bake
taper parameter to width ramp
value and export/import it in other data format(e.g. python + JSON).
- Curve(XGen interactive grooming splines)
- Point(xuv)
- Support xuv format.
MIT license.