How to handle temporal data in sdfFileFormat


I’m continuing my adventure in writing plugins for our custom hair tool at work. This time a sdfFileFormat plugin that reads in hair data and then converts that to an UsdGeomBasisCurves. My initial implementation I just hard coded the time to zero to get everything working as I figured time should be easy to add later.

How wrong I was, I had just assumed USD worked similar to DCCs and I could just query the current time when USD calls my Read(…) function. But if I understand things correctly, USD expects Read(…) to give back the whole time slice that then clients can sample.

Which will be quite heavy and time consuming to do. Instead I would like to just stream the data to USD once something ask for it. I looked around for documentation and examples and found the alembic plugin. Which is kind of similar to what I want, just a lot more complexity to it.

Is the sdfAbstractData the way to go in this case? As it is used in usdAbc. Or is there something simpler that I overlooked? I just need to generate an UsdGeomBasisCurves primitive at each time sample.

I figured I better ask here before I venture too deep into this rabbit hole.


Hi @plattfot ,
You are correct that you’ll need to subclass SdfAbstractData to get “deferred data translation”. There may be additional resources folks can point to outside of the OpenUSD repo, but the best/simplest example I can point you at in the repo is the usdDancingCubesExample . Now that’s a “dynamic” file format, which it doesn’t sound like you need, but that is a small amount of code only in the FileFormat class - the data.cpp and dataImpl.cpp should give you most of what you need, in terms of handling deferred queries of individual timeSamples of data.

Hi @spiff,

Thanks for confirming that I was on the right track. And thank you for the usdDancingCubesExample a lot easier to read and understand than trying to parse the whole usdAbc plugin!