These utilities for the USD file format plugins define the following:
- Simple data structures that hold USD data.
- Functions that read/write said data from/to the USD layer.
- A custom package resolver interface.
- Geometry, material and image utilities (filesystem read/write, phong->PBR, caching).
- Test utilities.
A given file format plugin needs only define 2 things:
- The file format native reader/writer (possibly implemented by a third party library).
- Functions that translate between USD data and the file format's own data.
- Implement the custom package resolver interface to read texture data from the origin file.
Import example:
bool UsdObjFileFormat::Read(
SdfLayer* layer,
const std::string& resolvedPath,
bool metadataOnly
) const {
Obj obj;
UsdData usd;
readObj(obj, resolvedPath);
ImportObjOptions options;
importObj(options, obj, usd);
WriteLayerOptions layerOptions;
writeLayer(layerOptions, usd, layer, sourceFileType, debugTag);
return true;
}
Export example:
bool UsdObjFileFormat::WriteToFile(
const SdfLayer& layer,
const std::string& filename,
const std::string& comment,
const FileFormatArguments& args
) const {
Obj obj;
UsdData usd;
ReadLayerOptions layerOptions;
readLayer(layerOptions, layer, usd, debugTag);
ExportOptions options;
exportObj(options, usd, obj);
writeObj(obj, filename, false);
return true;
}