HDK
|
#include <basisCurves.h>
Static Public Member Functions | |
static USDGEOM_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDGEOM_API UsdGeomBasisCurves | Get (const UsdStagePtr &stage, const SdfPath &path) |
static USDGEOM_API UsdGeomBasisCurves | Define (const UsdStagePtr &stage, const SdfPath &path) |
Static Public Member Functions inherited from UsdGeomCurves | |
static USDGEOM_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDGEOM_API UsdGeomCurves | Get (const UsdStagePtr &stage, const SdfPath &path) |
static USDGEOM_API bool | ComputeExtent (const VtVec3fArray &points, const VtFloatArray &widths, VtVec3fArray *extent) |
static USDGEOM_API bool | ComputeExtent (const VtVec3fArray &points, const VtFloatArray &widths, const GfMatrix4d &transform, VtVec3fArray *extent) |
Static Public Member Functions inherited from UsdGeomPointBased | |
static USDGEOM_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDGEOM_API UsdGeomPointBased | Get (const UsdStagePtr &stage, const SdfPath &path) |
static USDGEOM_API bool | ComputeExtent (const VtVec3fArray &points, VtVec3fArray *extent) |
static USDGEOM_API bool | ComputeExtent (const VtVec3fArray &points, const GfMatrix4d &transform, VtVec3fArray *extent) |
static USDGEOM_API bool | ComputePointsAtTime (VtArray< GfVec3f > *points, UsdStageWeakPtr &stage, UsdTimeCode time, const VtVec3fArray &positions, const VtVec3fArray &velocities, UsdTimeCode velocitiesSampleTime, const VtVec3fArray &accelerations, float velocityScale=1.0) |
Static Public Member Functions inherited from UsdGeomGprim | |
static USDGEOM_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDGEOM_API UsdGeomGprim | Get (const UsdStagePtr &stage, const SdfPath &path) |
Static Public Member Functions inherited from UsdGeomBoundable | |
static USDGEOM_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDGEOM_API UsdGeomBoundable | Get (const UsdStagePtr &stage, const SdfPath &path) |
static USDGEOM_API bool | ComputeExtentFromPlugins (const UsdGeomBoundable &boundable, const UsdTimeCode &time, VtVec3fArray *extent) |
static USDGEOM_API bool | ComputeExtentFromPlugins (const UsdGeomBoundable &boundable, const UsdTimeCode &time, const GfMatrix4d &transform, VtVec3fArray *extent) |
Static Public Member Functions inherited from UsdGeomXformable | |
static USDGEOM_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDGEOM_API UsdGeomXformable | Get (const UsdStagePtr &stage, const SdfPath &path) |
static USDGEOM_API bool | GetTimeSamples (std::vector< UsdGeomXformOp > const &orderedXformOps, std::vector< double > *times) |
static USDGEOM_API bool | GetTimeSamplesInInterval (std::vector< UsdGeomXformOp > const &orderedXformOps, const GfInterval &interval, std::vector< double > *times) |
static USDGEOM_API bool | GetLocalTransformation (GfMatrix4d *transform, std::vector< UsdGeomXformOp > const &ops, const UsdTimeCode time) |
static USDGEOM_API bool | IsTransformationAffectedByAttrNamed (const TfToken &attrName) |
Static Public Member Functions inherited from UsdGeomImageable | |
static USDGEOM_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USDGEOM_API UsdGeomImageable | Get (const UsdStagePtr &stage, const SdfPath &path) |
static USDGEOM_API const TfTokenVector & | GetOrderedPurposeTokens () |
Static Public Member Functions inherited from UsdTyped | |
static USD_API const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
static USD_API UsdTyped | Get (const UsdStagePtr &stage, const SdfPath &path) |
Static Public Member Functions inherited from UsdSchemaBase | |
static const TfTokenVector & | GetSchemaAttributeNames (bool includeInherited=true) |
Protected Member Functions | |
USDGEOM_API UsdSchemaKind | _GetSchemaKind () const override |
Protected Member Functions inherited from UsdGeomCurves | |
USDGEOM_API UsdSchemaKind | _GetSchemaKind () const override |
Protected Member Functions inherited from UsdGeomPointBased | |
USDGEOM_API UsdSchemaKind | _GetSchemaKind () const override |
Protected Member Functions inherited from UsdGeomXformable | |
USDGEOM_API UsdSchemaKind | _GetSchemaKind () const override |
Protected Member Functions inherited from UsdTyped | |
USD_API bool | _IsCompatible () const override |
Protected Member Functions inherited from UsdSchemaBase | |
virtual UsdSchemaKind | _GetSchemaType () const |
const TfType & | _GetType () const |
USD_API UsdAttribute | _CreateAttr (TfToken const &attrName, SdfValueTypeName const &typeName, bool custom, SdfVariability variability, VtValue const &defaultValue, bool writeSparsely) const |
Friends | |
class | UsdSchemaRegistry |
Helper functions for working with UsdGeomCurves | |
typedef std::vector< std::pair < TfToken, size_t > > | ComputeInterpolationInfo |
USDGEOM_API TfToken | ComputeInterpolationForSize (size_t n, const UsdTimeCode &timeCode, ComputeInterpolationInfo *info=NULL) const |
USDGEOM_API size_t | ComputeUniformDataSize (const UsdTimeCode &timeCode) const |
USDGEOM_API size_t | ComputeVaryingDataSize (const UsdTimeCode &timeCode) const |
USDGEOM_API size_t | ComputeVertexDataSize (const UsdTimeCode &timeCode) const |
BasisCurves are a batched curve representation analogous to the classic RIB definition via Basis and Curves statements. BasisCurves are often used to render dense aggregate geometry like hair or grass.
A 'matrix' and 'vstep' associated with the basis are used to interpolate the vertices of a cubic BasisCurves. (The basis attribute is unused for linear BasisCurves.)
A single prim may have many curves whose count is determined implicitly by the length of the curveVertexCounts vector. Each individual curve is composed of one or more segments. Each segment is defined by four vertices for cubic curves and two vertices for linear curves. See the next section for more information on how to map curve vertex counts to segment counts.
Interpolating a curve requires knowing how to decompose it into its individual segments.
The segments of a cubic curve are determined by the vertex count, the wrap (periodicity), and the vstep of the basis. For linear curves, the basis token is ignored and only the vertex count and wrap are needed.
cubic basis | vstep |
---|---|
bezier | 3 |
catmullRom | 1 |
bspline | 1 |
The first segment of a cubic (nonperiodic) curve is always defined by its first four points. The vstep is the increment used to determine what vertex indices define the next segment. For a two segment (nonperiodic) bspline basis curve (vstep = 1), the first segment will be defined by interpolating vertices [0, 1, 2, 3] and the second segment will be defined by [1, 2, 3, 4]. For a two segment bezier basis curve (vstep = 3), the first segment will be defined by interpolating vertices [0, 1, 2, 3] and the second segment will be defined by [3, 4, 5, 6]. If the vstep is not one, then you must take special care to make sure that the number of cvs properly divides by your vstep. (The indices described are relative to the initial vertex index for a batched curve.)
For periodic curves, at least one of the curve's initial vertices are repeated to close the curve. For cubic curves, the number of vertices repeated is '4 - vstep'. For linear curves, only one vertex is repeated to close the loop.
Pinned curves are a special case of nonperiodic curves that only affects the behavior of cubic Bspline and Catmull-Rom curves. To evaluate or render pinned curves, a client must effectively add 'phantom points' at the beginning and end of every curve in a batch. These phantom points are injected to ensure that the interpolated curve begins at P[0] and ends at P[n-1].
For a curve with initial point P[0] and last point P[n-1], the phantom points are defined as. P[-1] = 2 * P[0] - P[1] P[n] = 2 * P[n-1] - P[n-2]
Pinned cubic curves will (usually) have to be unpacked into the standard nonperiodic representation before rendering. This unpacking can add some additional overhead. However, using pinned curves reduces the amount of data recorded in a scene and (more importantly) better records the authors' intent for interchange.
Linear curve segments are defined by two vertices. A two segment linear curve's first segment would be defined by interpolating vertices [0, 1]. The second segment would be defined by vertices [1, 2]. (Again, for a batched curve, indices are relative to the initial vertex index.)
When validating curve topology, each renderable entry in the curveVertexCounts vector must pass this check.
type | wrap | validitity |
---|---|---|
linear | nonperiodic | curveVertexCounts[i] > 2 |
linear | periodic | curveVertexCounts[i] > 3 |
cubic | nonperiodic | (curveVertexCounts[i] - 4) % vstep == 0 |
cubic | periodic | (curveVertexCounts[i]) % vstep == 0 |
cubic | pinned (catmullRom/bspline) | (curveVertexCounts[i] - 2) >= 0 |
Linear interpolation is always used on curves of type linear. 't' with domain [0, 1], the curve is defined by the equation P0 * (1-t) + P1 * t. t at 0 describes the first point and t at 1 describes the end point.
For cubic curves, primvar data can be either interpolated cubically between vertices or linearly across segments. The corresponding token for cubic interpolation is 'vertex' and for linear interpolation is 'varying'. Per vertex data should be the same size as the number of vertices in your curve. Segment varying data is dependent on the wrap (periodicity) and number of segments in your curve. For linear curves, varying and vertex data would be interpolated the same way. By convention varying is the preferred interpolation because of the association of varying with linear interpolation.
To convert an entry in the curveVertexCounts vector into a segment count for an individual curve, apply these rules. Sum up all the results in order to compute how many total segments all curves have.
The following tables describe the expected segment count for the 'i'th curve in a curve batch as well as the entire batch. Python syntax like '[:]' (to describe all members of an array) and 'len(...)' (to describe the length of an array) are used.
type | wrap | curve segment count | batch segment count |
---|---|---|---|
linear | nonperiodic | curveVertexCounts[i] - 1 | sum(curveVertexCounts[:]) - len(curveVertexCounts) |
linear | periodic | curveVertexCounts[i] | sum(curveVertexCounts[:]) |
cubic | nonperiodic | (curveVertexCounts[i] - 4) / vstep + 1 | sum(curveVertexCounts[:] - 4) / vstep + len(curveVertexCounts) |
cubic | periodic | curveVertexCounts[i] / vstep | sum(curveVertexCounts[:]) / vstep |
cubic | pinned (catmullRom/bspline) | (curveVertexCounts[i] - 2) + 1 | sum(curveVertexCounts[:] - 2) + len(curveVertexCounts) |
The following table descrives the expected size of varying (linearly interpolated) data, derived from the segment counts computed above.
wrap | curve varying count | batch varying count |
---|---|---|
nonperiodic/pinned | segmentCounts[i] + 1 | sum(segmentCounts[:]) + len(curveVertexCounts) |
periodic | segmentCounts[i] | sum(segmentCounts[:]) |
Both curve types additionally define 'constant' interpolation for the entire prim and 'uniform' interpolation as per curve data.
As an example of deriving per curve segment and varying primvar data counts from the wrap, type, basis, and curveVertexCount, the following table is provided.
wrap | type | basis | curveVertexCount | curveSegmentCount | varyingDataCount |
---|---|---|---|---|---|
nonperiodic | linear | N/A | [2 3 2 5] | [1 2 1 4] | [2 3 2 5] |
nonperiodic | cubic | bezier | [4 7 10 4 7] | [1 2 3 1 2] | [2 3 4 2 3] |
nonperiodic | cubic | bspline | [5 4 6 7] | [2 1 3 4] | [3 2 4 5] |
periodic | cubic | bezier | [6 9 6] | [2 3 2] | [2 3 2] |
periodic | linear | N/A | [3 7] | [3 7] | [3 7] |
The strictest definition of a curve as an infinitely thin wire is not particularly useful for describing production scenes. The additional widths and normals attributes can be used to describe cylindrical tubes and or flat oriented ribbons.
Curves with only widths defined are imaged as tubes with radius 'width / 2'. Curves with both widths and normals are imaged as ribbons oriented in the direction of the interpolated normal vectors.
While not technically UsdGeomPrimvars, widths and normals also have interpolation metadata. It's common for authored widths to have constant, varying, or vertex interpolation (see UsdGeomCurves::GetWidthsInterpolation()). It's common for authored normals to have varying interpolation (see UsdGeomPointBased::GetNormalsInterpolation()).
The file used to generate these curves can be found in extras/usd/examples/usdGeomExamples/basisCurves.usda. It's provided as a reference on how to properly image both tubes and ribbons. The first row of curves are linear; the second are cubic bezier. (We aim in future releases of HdSt to fix the discontinuity seen with broken tangents to better match offline renderers like RenderMan.) The yellow and violet cubic curves represent cubic vertex width interpolation for which there is no equivalent for linear curves.
For any described attribute Fallback Value or Allowed Values below that are text/tokens, the actual token is published and defined in UsdGeomTokens. So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded as the value.
Definition at line 263 of file basisCurves.h.
typedef std::vector< std::pair<TfToken, size_t> > UsdGeomBasisCurves::ComputeInterpolationInfo |
Computes interpolation token for n
.
If this returns an empty token and info
was non-NULL, it'll contain the expected value for each token.
The topology is determined using timeCode
.
Definition at line 452 of file basisCurves.h.
Construct a UsdGeomBasisCurves on UsdPrim prim
. Equivalent to UsdGeomBasisCurves::Get(prim.GetStage(), prim.GetPath()) for a valid prim
, but will not immediately throw an error for an invalid prim
Definition at line 275 of file basisCurves.h.
|
inlineexplicit |
Construct a UsdGeomBasisCurves on the prim held by schemaObj
. Should be preferred over UsdGeomBasisCurves(schemaObj.GetPrim()), as it preserves SchemaBase state.
Definition at line 283 of file basisCurves.h.
|
virtual |
Destructor.
|
overrideprotectedvirtual |
Returns the kind of schema this class belongs to.
Reimplemented from UsdTyped.
USDGEOM_API TfToken UsdGeomBasisCurves::ComputeInterpolationForSize | ( | size_t | n, |
const UsdTimeCode & | timeCode, | ||
ComputeInterpolationInfo * | info = NULL |
||
) | const |
Computes interpolation token for n
.
If this returns an empty token and info
was non-NULL, it'll contain the expected value for each token.
The topology is determined using timeCode
.
USDGEOM_API size_t UsdGeomBasisCurves::ComputeUniformDataSize | ( | const UsdTimeCode & | timeCode | ) | const |
Computes the expected size for data with "uniform" interpolation.
If you're trying to determine what interpolation to use, it is more efficient to use ComputeInterpolationForSize
USDGEOM_API size_t UsdGeomBasisCurves::ComputeVaryingDataSize | ( | const UsdTimeCode & | timeCode | ) | const |
Computes the expected size for data with "varying" interpolation.
If you're trying to determine what interpolation to use, it is more efficient to use ComputeInterpolationForSize
USDGEOM_API size_t UsdGeomBasisCurves::ComputeVertexDataSize | ( | const UsdTimeCode & | timeCode | ) | const |
Computes the expected size for data with "vertex" interpolation.
If you're trying to determine what interpolation to use, it is more efficient to use ComputeInterpolationForSize
USDGEOM_API UsdAttribute UsdGeomBasisCurves::CreateBasisAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetBasisAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
USDGEOM_API UsdAttribute UsdGeomBasisCurves::CreateTypeAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetTypeAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
USDGEOM_API UsdAttribute UsdGeomBasisCurves::CreateWrapAttr | ( | VtValue const & | defaultValue = VtValue() , |
bool | writeSparsely = false |
||
) | const |
See GetWrapAttr(), and also Usd_Create_Or_Get_Property for when to use Get vs Create. If specified, author defaultValue
as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely
is true
- the default for writeSparsely
is false
.
|
static |
Attempt to ensure a UsdPrim adhering to this schema at path
is defined (according to UsdPrim::IsDefined()) on this stage.
If a prim adhering to this schema at path
is already defined on this stage, return that prim. Otherwise author an SdfPrimSpec with specifier == SdfSpecifierDef and this schema's prim type name for the prim at path
at the current EditTarget. Author SdfPrimSpec s with specifier
== SdfSpecifierDef and empty typeName at the current EditTarget for any nonexistent, or existing but not Defined ancestors.
The given path must be an absolute prim path that does not contain any variant selections.
If it is impossible to author any of the necessary PrimSpecs, (for example, in case path cannot map to the current UsdEditTarget's namespace) issue an error and return an invalid UsdPrim.
Note that this method may return a defined prim whose typeName does not specify this schema class, in case a stronger typeName opinion overrides the opinion at the current EditTarget.
|
static |
Return a UsdGeomBasisCurves holding the prim adhering to this schema at path
on stage
. If no prim exists at path
on stage
, or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:
USDGEOM_API UsdAttribute UsdGeomBasisCurves::GetBasisAttr | ( | ) | const |
The basis specifies the vstep and matrix used for cubic interpolation.
Declaration | uniform token basis = "bezier" |
C++ Type | TfToken |
Usd Type | SdfValueTypeNames->Token |
Variability | SdfVariabilityUniform |
Allowed Values | bezier, bspline, catmullRom |
|
static |
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes. Does not include attributes that may be authored by custom/extended methods of the schemas involved.
USDGEOM_API UsdAttribute UsdGeomBasisCurves::GetTypeAttr | ( | ) | const |
Linear curves interpolate linearly between two vertices. Cubic curves use a basis matrix with four vertices to interpolate a segment.
Declaration | uniform token type = "cubic" |
C++ Type | TfToken |
Usd Type | SdfValueTypeNames->Token |
Variability | SdfVariabilityUniform |
Allowed Values | linear, cubic |
USDGEOM_API UsdAttribute UsdGeomBasisCurves::GetWrapAttr | ( | ) | const |
If wrap is set to periodic, the curve when rendered will repeat the initial vertices (dependent on the vstep) to close the curve. If wrap is set to 'pinned', phantom points may be created to ensure that the curve interpolation starts at P[0] and ends at P[n-1].
Declaration | uniform token wrap = "nonperiodic" |
C++ Type | TfToken |
Usd Type | SdfValueTypeNames->Token |
Variability | SdfVariabilityUniform |
Allowed Values | nonperiodic, periodic, pinned |
|
friend |
Definition at line 347 of file basisCurves.h.
|
static |
Compile time constant representing what kind of schema this class is.
Definition at line 269 of file basisCurves.h.