PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.45k stars 1.13k forks source link

Best way to create UV primvar on curves? #3041

Closed BrianHanke closed 1 month ago

BrianHanke commented 1 month ago

Howdy all, I'm currently working on a custom build of Blender with support for UVs on curves in the USD exporter. Everything is working great in general, but I've hit one speed bump.

There are many existing functions, such as CreateDisplayColorPrimvar, which make it easy to quickly add that particular primvar. However, there doesn't seem to be one for st and I can't figure out how to create a custom function for it.

Ideally, this should only take two lines in the Blender source:

pxr::UsdAttribute attr_st = usd_curves.CreateStPrimvar(); // hypothetical CreateStPrimvar function
usd_value_writer_.SetAttribute(attr_st, pxr::VtValue(st), timecode); 

Do you have any tips how best to do this? Thanks very much!

Update: figured it out! Curves UVs now supported in my build of Blender's USD exporter.

const pxr::UsdGeomPrimvarsAPI pvApi = pxr::UsdGeomPrimvarsAPI(usd_curves);
pxr::UsdGeomPrimvar attr_st = pvApi.CreatePrimvar(pxr::TfToken("primvars:st"), pxr::SdfValueTypeNames->Float2Array, pxr::UsdGeomTokens->varying);
usd_value_writer_.SetAttribute(attr_st, pxr::VtValue(st), timecode);