# How to handle temporal data in sdfFileFormat

**URL:** https://forum.aousd.org/t/how-to-handle-temporal-data-in-sdffileformat/1583
**Category:** USD
**Tags:** cpp
**Created:** [June 6, 2024, 5:39pm UTC](https://forum.aousd.org/t/how-to-handle-temporal-data-in-sdffileformat/1583 "2024-06-06T17:39:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![plattfot](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@plattfot](https://forum.aousd.org/u/plattfot)
#### Post date: [June 6, 2024, 5:39pm UTC](https://forum.aousd.org/t/how-to-handle-temporal-data-in-sdffileformat/1583/1 "2024-06-06T17:39:06Z")

</div>

Hi,

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.

Thanks!

---

<div class="post-metadata">

### Author: ![spiff](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.aousd.org/spiff/32/22_2.png) [@spiff](https://forum.aousd.org/u/spiff)
#### Post date: [June 7, 2024, 12:11am UTC](https://forum.aousd.org/t/how-to-handle-temporal-data-in-sdffileformat/1583/2 "2024-06-07T00:11:15Z")

</div>

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](https://github.com/PixarAnimationStudios/OpenUSD/tree/release/extras/usd/examples/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.

---

<div class="post-metadata">

### Author: ![plattfot](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@plattfot](https://forum.aousd.org/u/plattfot)
#### Post date: [June 7, 2024, 12:23am UTC](https://forum.aousd.org/t/how-to-handle-temporal-data-in-sdffileformat/1583/3 "2024-06-07T00:23:35Z")

</div>

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!
