22 #include <pxr/usd/usdGeom/basisCurves.h>
23 #include <pxr/usd/usdGeom/tokens.h>
39 if (cache ==
nullptr) {
48 curves.CreateBasisAttr(pxr::VtValue(pxr::UsdGeomTokens->bspline));
49 curves.CreateTypeAttr(pxr::VtValue(pxr::UsdGeomTokens->cubic));
51 pxr::VtArray<pxr::GfVec3f> points;
52 pxr::VtIntArray curve_point_counts;
53 curve_point_counts.reserve(psys->
totpart);
56 for (
int strand_index = 0; strand_index < psys->
totpart; ++strand_index) {
57 strand = cache[strand_index];
59 int point_count = strand->
segments + 1;
60 curve_point_counts.push_back(point_count);
62 for (
int point_index = 0; point_index < point_count; ++point_index, ++strand) {
63 points.push_back(pxr::GfVec3f(strand->
co));
67 pxr::UsdAttribute attr_points = curves.CreatePointsAttr(pxr::VtValue(),
true);
68 pxr::UsdAttribute attr_vertex_counts = curves.CreateCurveVertexCountsAttr(pxr::VtValue(),
true);
69 if (!attr_points.HasValue()) {
70 attr_points.Set(points, pxr::UsdTimeCode::Default());
71 attr_vertex_counts.Set(curve_point_counts, pxr::UsdTimeCode::Default());
74 usd_value_writer_.SetAttribute(attr_vertex_counts, pxr::VtValue(curve_point_counts), timecode);
77 pxr::VtArray<pxr::GfVec3f> colors;
78 colors.push_back(pxr::GfVec3f(cache[0]->
col));
79 curves.CreateDisplayColorAttr(pxr::VtValue(colors));
pxr::UsdTimeCode get_export_time_code() const
pxr::UsdUtilsSparseValueWriter usd_value_writer_
const USDExporterContext usd_export_context_
virtual bool check_is_animated(const HierarchyContext &context) const override
virtual void do_write(HierarchyContext &context) override
USDHairWriter(const USDExporterContext &ctx)
struct SELECTID_Context context
struct ParticleCacheKey ** pathcache
const pxr::SdfPath usd_path
const pxr::UsdStageRefPtr stage