add usd-21-11-win64_py39
This commit is contained in:
1 parent
41d23e71ba
commit
ba5e1f7e67
15684 files changed
+3069957
No files matched your search
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2017 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_API_H
|
||||
#define USDGEOM_API_H
|
||||
|
||||
#include "pxr/base/arch/export.h"
|
||||
|
||||
#if defined(PXR_STATIC)
|
||||
# define USDGEOM_API
|
||||
# define USDGEOM_API_TEMPLATE_CLASS(...)
|
||||
# define USDGEOM_API_TEMPLATE_STRUCT(...)
|
||||
# define USDGEOM_LOCAL
|
||||
#else
|
||||
# if defined(USDGEOM_EXPORTS)
|
||||
# define USDGEOM_API ARCH_EXPORT
|
||||
# define USDGEOM_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define USDGEOM_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# else
|
||||
# define USDGEOM_API ARCH_IMPORT
|
||||
# define USDGEOM_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define USDGEOM_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# endif
|
||||
# define USDGEOM_LOCAL ARCH_HIDDEN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,491 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_BASISCURVES_H
|
||||
#define USDGEOM_GENERATED_BASISCURVES_H
|
||||
|
||||
/// \file usdGeom/basisCurves.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/curves.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// BASISCURVES //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomBasisCurves
|
||||
///
|
||||
/// 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 \em 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 \em 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.
|
||||
///
|
||||
/// \section UsdGeomBasisCurves_Segment Segment Indexing
|
||||
/// 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 \em 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.
|
||||
///
|
||||
/// \note The additional phantom points mean that the minimum curve vertex
|
||||
/// count for cubic bspline and catmullRom curves is 2.
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
/// \section UsdGeomBasisCurves_BasisMatrix Cubic Vertex Interpolation
|
||||
///
|
||||
/// \image html USDCurveBasisMatrix.png width=750
|
||||
///
|
||||
/// \section UsdGeomBasisCurves_Linear Linear Vertex Interpolation
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// \section UsdGeomBasisCurves_PrimvarInterpolation Primvar Interpolation
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// \image html USDCurvePrimvars.png
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
///
|
||||
/// \note Take care when providing support for linearly interpolated data for
|
||||
/// cubic curves. Its shape doesn't provide a one to one mapping with either
|
||||
/// the number of curves (like 'uniform') or the number of vertices (like
|
||||
/// 'vertex') and so it is often overlooked. This is the only primitive in
|
||||
/// UsdGeom (as of this writing) where this is true. For meshes, while they
|
||||
/// use different interpolation methods, 'varying' and 'vertex' are both
|
||||
/// specified per point. It's common to assume that curves follow a similar
|
||||
/// pattern and build in structures and language for per primitive, per
|
||||
/// element, and per point data only to come upon these arrays that don't
|
||||
/// quite fit into either of those categories. It is
|
||||
/// also common to conflate 'varying' with being per segment data and use the
|
||||
/// segmentCount rules table instead of its neighboring varying data table
|
||||
/// rules. We suspect that this is because for the common case of
|
||||
/// nonperiodic cubic curves, both the provided segment count and varying data
|
||||
/// size formula end with '+ 1'. While debugging, users may look at the double
|
||||
/// '+ 1' as a mistake and try to remove it. We take this time to enumerate
|
||||
/// these issues because we've fallen into them before and hope that we save
|
||||
/// others time in their own implementations.
|
||||
///
|
||||
/// 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]
|
||||
///
|
||||
/// \section UsdGeomBasisCurves_TubesAndRibbons Tubes and Ribbons
|
||||
///
|
||||
/// The strictest definition of a curve as an infinitely thin wire is not
|
||||
/// particularly useful for describing production scenes. The additional
|
||||
/// \em widths and \em 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()).
|
||||
///
|
||||
/// \image html USDCurveHydra.png
|
||||
///
|
||||
/// The file used to generate these curves can be found in
|
||||
/// pxr/extras/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.
|
||||
///
|
||||
/// \note How did this prim type get its name? This prim is a portmanteau of
|
||||
/// two different statements in the original RenderMan specification:
|
||||
/// 'Basis' and 'Curves'.
|
||||
///
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomBasisCurves : public UsdGeomCurves
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomBasisCurves on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomBasisCurves::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomBasisCurves(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomCurves(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomBasisCurves on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomBasisCurves(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomBasisCurves(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomCurves(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomBasisCurves();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomBasisCurves holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomBasisCurves(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomBasisCurves
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomBasisCurves
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TYPE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// 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 |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | linear, cubic |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTypeAttr() const;
|
||||
|
||||
/// See GetTypeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTypeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// BASIS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The basis specifies the vstep and matrix used for cubic
|
||||
/// interpolation. \note The 'hermite' and 'power' tokens have been
|
||||
/// removed. We've provided UsdGeomHermiteCurves
|
||||
/// as an alternative for the 'hermite' basis.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token basis = "bezier"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | bezier, bspline, catmullRom |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetBasisAttr() const;
|
||||
|
||||
/// See GetBasisAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateBasisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// WRAP
|
||||
// --------------------------------------------------------------------- //
|
||||
/// 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 |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | nonperiodic, periodic, pinned |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetWrapAttr() const;
|
||||
|
||||
/// See GetWrapAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateWrapAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// \name Helper functions for working with UsdGeomCurves
|
||||
/// \{
|
||||
|
||||
typedef std::vector< std::pair<TfToken, size_t> > ComputeInterpolationInfo;
|
||||
|
||||
/// Computes interpolation token for \p n.
|
||||
///
|
||||
/// If this returns an empty token and \p info was non-NULL, it'll contain
|
||||
/// the expected value for each token.
|
||||
///
|
||||
/// The topology is determined using \p timeCode.
|
||||
USDGEOM_API
|
||||
TfToken ComputeInterpolationForSize(size_t n,
|
||||
const UsdTimeCode& timeCode,
|
||||
ComputeInterpolationInfo* info=NULL) 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 \c ComputeInterpolationForSize
|
||||
USDGEOM_API
|
||||
size_t ComputeUniformDataSize(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 \c ComputeInterpolationForSize
|
||||
USDGEOM_API
|
||||
size_t ComputeVaryingDataSize(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 \c ComputeInterpolationForSize
|
||||
USDGEOM_API
|
||||
size_t ComputeVertexDataSize(const UsdTimeCode& timeCode) const;
|
||||
|
||||
/// \}
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,556 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_BBOX_CACHE_H
|
||||
#define PXR_USD_USD_GEOM_BBOX_CACHE_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/xformCache.h"
|
||||
#include "pxr/usd/usdGeom/pointInstancer.h"
|
||||
#include "pxr/usd/usd/attributeQuery.h"
|
||||
#include "pxr/base/gf/bbox3d.h"
|
||||
#include "pxr/base/tf/hashmap.h"
|
||||
#include "pxr/base/work/dispatcher.h"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/shared_array.hpp>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
class UsdGeomModelAPI;
|
||||
|
||||
/// \class UsdGeomBBoxCache
|
||||
///
|
||||
/// Caches bounds by recursively computing and aggregating bounds of children in
|
||||
/// world space and aggregating the result back into local space.
|
||||
///
|
||||
/// The cache is configured for a specific time and
|
||||
/// \ref UsdGeomImageable::GetPurposeAttr() set of purposes. When querying a
|
||||
/// bound, transforms and extents are read either from the time specified or
|
||||
/// UsdTimeCode::Default(), following \ref Usd_ValueResolution standard
|
||||
/// time-sample value resolution. As noted in SetIncludedPurposes(), changing
|
||||
/// the included purposes does not invalidate the cache, because we cache
|
||||
/// purpose along with the geometric data.
|
||||
///
|
||||
/// Child prims that are invisible at the requested time are excluded when
|
||||
/// computing a prim's bounds. However, if a bound is requested directly for an
|
||||
/// excluded prim, it will be computed. Additionally, only prims deriving from
|
||||
/// UsdGeomImageable are included in child bounds computations.
|
||||
///
|
||||
/// Unlike standard UsdStage traversals, the traversal performed by the
|
||||
/// UsdGeomBBoxCache includes prims that are unloaded (see UsdPrim::IsLoaded()).
|
||||
/// This makes it possible to fetch bounds for a UsdStage that has been opened
|
||||
/// without \em forcePopulate , provided the unloaded model prims have authored
|
||||
/// extent hints (see UsdGeomModelAPI::GetExtentsHint()).
|
||||
///
|
||||
/// This class is optimized for computing tight <b>untransformed "object"
|
||||
/// space</b> bounds for component-models. In the absence of component models,
|
||||
/// bounds are optimized for world-space, since there is no other easily
|
||||
/// identifiable space for which to optimize, and we cannot optimize for every
|
||||
/// prim's local space without performing quadratic work.
|
||||
///
|
||||
/// The TfDebug flag, USDGEOM_BBOX, is provided for debugging.
|
||||
///
|
||||
/// Warnings:
|
||||
/// * This class should only be used with valid UsdPrim objects.
|
||||
///
|
||||
/// * This cache does not listen for change notifications; the user is
|
||||
/// responsible for clearing the cache when changes occur.
|
||||
///
|
||||
/// * Thread safety: instances of this class may not be used concurrently.
|
||||
///
|
||||
/// * Plugins may be loaded in order to compute extents for prim types provided
|
||||
/// by that plugin. See UsdGeomBoundable::ComputeExtentFromPlugins
|
||||
///
|
||||
class UsdGeomBBoxCache
|
||||
{
|
||||
public:
|
||||
/// Construct a new BBoxCache for a specific \p time and set of
|
||||
/// \p includedPurposes.
|
||||
///
|
||||
/// Only prims with a purpose that matches the \p includedPurposes will be
|
||||
/// considered when accumulating child bounds. See UsdGeomImageable for
|
||||
/// allowed purpose values.
|
||||
///
|
||||
/// If \p useExtentsHint is true, then when computing the bounds for any
|
||||
/// model-root prim, if the prim is visible at \p time, we will fetch its
|
||||
/// extents hint (via UsdGeomModelAPI::GetExtentsHint()). If it is authored,
|
||||
/// we use it to compute the bounding box for the selected combination of
|
||||
/// includedPurposes by combining bounding box hints that have been cached
|
||||
/// for various values of purposes.
|
||||
///
|
||||
/// If \p ignoreVisibility is true invisible prims will be included during
|
||||
/// bounds computations.
|
||||
///
|
||||
USDGEOM_API
|
||||
UsdGeomBBoxCache(UsdTimeCode time, TfTokenVector includedPurposes,
|
||||
bool useExtentsHint=false, bool ignoreVisibility=false);
|
||||
|
||||
/// Copy constructor.
|
||||
USDGEOM_API
|
||||
UsdGeomBBoxCache(UsdGeomBBoxCache const &other);
|
||||
|
||||
/// Copy assignment.
|
||||
USDGEOM_API
|
||||
UsdGeomBBoxCache &operator=(UsdGeomBBoxCache const &other);
|
||||
|
||||
/// Compute the bound of the given prim in world space, leveraging any
|
||||
/// pre-existing, cached bounds.
|
||||
///
|
||||
/// The bound of the prim is computed, including the transform (if any)
|
||||
/// authored on the node itself, and then transformed to world space.
|
||||
///
|
||||
/// Error handling note: No checking of \p prim validity is performed. If
|
||||
/// \p prim is invalid, this method will abort the program; therefore it is
|
||||
/// the client's responsibility to ensure \p prim is valid.
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeWorldBound(const UsdPrim& prim);
|
||||
|
||||
/// Compute the bound of the given prim in the space of an ancestor prim,
|
||||
/// \p relativeToAncestorPrim, leveraging any pre-existing cached bounds.
|
||||
///
|
||||
/// The computed bound excludes the local transform at
|
||||
/// \p relativeToAncestorPrim. The computed bound may be incorrect if
|
||||
/// \p relativeToAncestorPrim is not an ancestor of \p prim.
|
||||
///
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeRelativeBound(const UsdPrim &prim,
|
||||
const UsdPrim &relativeToAncestorPrim);
|
||||
|
||||
/// Computes the oriented bounding box of the given prim, leveraging any
|
||||
/// pre-existing, cached bounds.
|
||||
///
|
||||
/// The computed bound includes the transform authored on the prim itself,
|
||||
/// but does not include any ancestor transforms (it does not include the
|
||||
/// local-to-world transform).
|
||||
///
|
||||
/// See ComputeWorldBound() for notes on performance and error handling.
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeLocalBound(const UsdPrim& prim);
|
||||
|
||||
/// Computes the bound of the prim's children leveraging any pre-existing,
|
||||
/// cached bounds, but does not include the transform (if any) authored on
|
||||
/// the prim itself.
|
||||
///
|
||||
/// \b IMPORTANT: while the BBox does not contain the local transformation,
|
||||
/// in general it may still contain a non-identity transformation matrix to
|
||||
/// put the bounds in the correct space. Therefore, to obtain the correct
|
||||
/// axis-aligned bounding box, the client must call ComputeAlignedRange().
|
||||
///
|
||||
/// See ComputeWorldBound() for notes on performance and error handling.
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeUntransformedBound(const UsdPrim& prim);
|
||||
|
||||
/// \overload
|
||||
/// Computes the bound of the prim's descendents while excluding the
|
||||
/// subtrees rooted at the paths in \p pathsToSkip. Additionally, the
|
||||
/// parameter \p ctmOverrides is used to specify overrides to the CTM values
|
||||
/// of certain paths underneath the prim. The CTM values in the
|
||||
/// \p ctmOverrides map are in the space of the given prim, \p prim.
|
||||
///
|
||||
/// This leverages any pre-existing, cached bounds, but does not include the
|
||||
/// transform (if any) authored on the prim itself.
|
||||
///
|
||||
/// \b IMPORTANT: while the BBox does not contain the local transformation,
|
||||
/// in general it may still contain a non-identity transformation matrix to
|
||||
/// put the bounds in the correct space. Therefore, to obtain the correct
|
||||
/// axis-aligned bounding box, the client must call ComputeAlignedRange().
|
||||
///
|
||||
/// See ComputeWorldBound() for notes on performance and error handling.
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeUntransformedBound(
|
||||
const UsdPrim &prim,
|
||||
const SdfPathSet &pathsToSkip,
|
||||
const TfHashMap<SdfPath, GfMatrix4d, SdfPath::Hash> &ctmOverrides);
|
||||
|
||||
/// Compute the bound of the given point instances in world space.
|
||||
///
|
||||
/// The bounds of each instance is computed and then transformed to world
|
||||
/// space. The \p result pointer must point to \p numIds GfBBox3d instances
|
||||
/// to be filled.
|
||||
USDGEOM_API
|
||||
bool
|
||||
ComputePointInstanceWorldBounds(
|
||||
const UsdGeomPointInstancer& instancer,
|
||||
int64_t const *instanceIdBegin,
|
||||
size_t numIds,
|
||||
GfBBox3d *result);
|
||||
|
||||
/// Compute the bound of the given point instance in world space.
|
||||
///
|
||||
GfBBox3d
|
||||
ComputePointInstanceWorldBound(
|
||||
const UsdGeomPointInstancer& instancer, int64_t instanceId) {
|
||||
GfBBox3d ret;
|
||||
ComputePointInstanceWorldBounds(instancer, &instanceId, 1, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Compute the bounds of the given point instances in the space of an
|
||||
/// ancestor prim \p relativeToAncestorPrim. Write the results to
|
||||
/// \p result.
|
||||
///
|
||||
/// The computed bound excludes the local transform at
|
||||
/// \p relativeToAncestorPrim. The computed bound may be incorrect if
|
||||
/// \p relativeToAncestorPrim is not an ancestor of \p prim.
|
||||
///
|
||||
/// The \p result pointer must point to \p numIds GfBBox3d instances to be
|
||||
/// filled.
|
||||
USDGEOM_API
|
||||
bool
|
||||
ComputePointInstanceRelativeBounds(
|
||||
const UsdGeomPointInstancer &instancer,
|
||||
int64_t const *instanceIdBegin,
|
||||
size_t numIds,
|
||||
const UsdPrim &relativeToAncestorPrim,
|
||||
GfBBox3d *result);
|
||||
|
||||
/// Compute the bound of the given point instance in the space of an
|
||||
/// ancestor prim \p relativeToAncestorPrim.
|
||||
GfBBox3d
|
||||
ComputePointInstanceRelativeBound(
|
||||
const UsdGeomPointInstancer &instancer,
|
||||
int64_t instanceId,
|
||||
const UsdPrim &relativeToAncestorPrim) {
|
||||
GfBBox3d ret;
|
||||
ComputePointInstanceRelativeBounds(
|
||||
instancer, &instanceId, 1, relativeToAncestorPrim, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Compute the oriented bounding boxes of the given point instances.
|
||||
///
|
||||
/// The computed bounds include the transform authored on the instancer
|
||||
/// itself, but does not include any ancestor transforms (it does not
|
||||
/// include the local-to-world transform).
|
||||
///
|
||||
/// The \p result pointer must point to \p numIds GfBBox3d instances to be
|
||||
/// filled.
|
||||
USDGEOM_API
|
||||
bool
|
||||
ComputePointInstanceLocalBounds(
|
||||
const UsdGeomPointInstancer& instancer,
|
||||
int64_t const *instanceIdBegin,
|
||||
size_t numIds,
|
||||
GfBBox3d *result);
|
||||
|
||||
/// Compute the oriented bounding boxes of the given point instances.
|
||||
GfBBox3d
|
||||
ComputePointInstanceLocalBound(
|
||||
const UsdGeomPointInstancer& instancer,
|
||||
int64_t instanceId) {
|
||||
GfBBox3d ret;
|
||||
ComputePointInstanceLocalBounds(instancer, &instanceId, 1, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/// Computes the bound of the given point instances, but does not include
|
||||
/// the transform (if any) authored on the instancer itself.
|
||||
///
|
||||
/// \b IMPORTANT: while the BBox does not contain the local transformation,
|
||||
/// in general it may still contain a non-identity transformation matrix to
|
||||
/// put the bounds in the correct space. Therefore, to obtain the correct
|
||||
/// axis-aligned bounding box, the client must call ComputeAlignedRange().
|
||||
///
|
||||
/// The \p result pointer must point to \p numIds GfBBox3d instances to be
|
||||
/// filled.
|
||||
USDGEOM_API
|
||||
bool
|
||||
ComputePointInstanceUntransformedBounds(
|
||||
const UsdGeomPointInstancer& instancer,
|
||||
int64_t const *instanceIdBegin,
|
||||
size_t numIds,
|
||||
GfBBox3d *result);
|
||||
|
||||
/// Computes the bound of the given point instances, but does not include
|
||||
/// the instancer's transform.
|
||||
GfBBox3d
|
||||
ComputePointInstanceUntransformedBound(
|
||||
const UsdGeomPointInstancer& instancer,
|
||||
int64_t instanceId) {
|
||||
GfBBox3d ret;
|
||||
ComputePointInstanceUntransformedBounds(
|
||||
instancer, &instanceId, 1, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Clears all pre-cached values.
|
||||
USDGEOM_API
|
||||
void Clear();
|
||||
|
||||
/// Indicate the set of \p includedPurposes to use when resolving child
|
||||
/// bounds. Each child's purpose must match one of the elements of this set
|
||||
/// to be included in the computation; if it does not, child is excluded.
|
||||
///
|
||||
/// Note the use of *child* in the docs above, purpose is ignored for the
|
||||
/// prim for whose bounds are directly queried.
|
||||
///
|
||||
/// Changing this value <b>does not invalidate existing caches</b>.
|
||||
USDGEOM_API
|
||||
void SetIncludedPurposes(const TfTokenVector& includedPurposes);
|
||||
|
||||
/// Get the current set of included purposes.
|
||||
const TfTokenVector& GetIncludedPurposes() { return _includedPurposes; }
|
||||
|
||||
/// Returns whether authored extent hints are used to compute
|
||||
/// bounding boxes.
|
||||
bool GetUseExtentsHint() const {
|
||||
return _useExtentsHint;
|
||||
}
|
||||
|
||||
/// Returns whether prim visibility should be ignored when computing
|
||||
/// bounding boxes.
|
||||
bool GetIgnoreVisibility() const {
|
||||
return _ignoreVisibility;
|
||||
}
|
||||
|
||||
/// Use the new \p time when computing values and may clear any existing
|
||||
/// values cached for the previous time. Setting \p time to the current time
|
||||
/// is a no-op.
|
||||
USDGEOM_API
|
||||
void SetTime(UsdTimeCode time);
|
||||
|
||||
/// Get the current time from which this cache is reading values.
|
||||
UsdTimeCode GetTime() const { return _time; }
|
||||
|
||||
/// Set the base time value for this bbox cache. This value is used only
|
||||
/// when computing bboxes for point instancer instances (see
|
||||
/// ComputePointInstanceWorldBounds(), for example). See
|
||||
/// UsdGeomPointInstancer::ComputeExtentAtTime() for more information. If
|
||||
/// unset, the bbox cache uses its time (GetTime() / SetTime()) for this
|
||||
/// value.
|
||||
///
|
||||
/// Note that setting the base time does not invalidate any cache entries.
|
||||
void SetBaseTime(UsdTimeCode baseTime) {
|
||||
_baseTime = baseTime;
|
||||
}
|
||||
|
||||
/// Return the base time if set, otherwise GetTime(). Use HasBaseTime() to
|
||||
/// observe if a base time has been set.
|
||||
UsdTimeCode GetBaseTime() const {
|
||||
return _baseTime.get_value_or(GetTime());
|
||||
}
|
||||
|
||||
/// Clear this cache's baseTime if one has been set. After calling this,
|
||||
/// the cache will use its time as the baseTime value.
|
||||
void ClearBaseTime() {
|
||||
_baseTime = boost::none;
|
||||
}
|
||||
|
||||
/// Return true if this cache has a baseTime that's been explicitly set,
|
||||
/// false otherwise.
|
||||
bool HasBaseTime() const {
|
||||
return static_cast<bool>(_baseTime);
|
||||
}
|
||||
|
||||
private:
|
||||
// Worker task.
|
||||
class _BBoxTask;
|
||||
|
||||
// Helper object for computing bounding boxes for instance prototypes.
|
||||
class _PrototypeBBoxResolver;
|
||||
|
||||
// Map of purpose tokens to associated bboxes.
|
||||
typedef std::map<TfToken, GfBBox3d, TfTokenFastArbitraryLessThan>
|
||||
_PurposeToBBoxMap;
|
||||
|
||||
// Each individual prim will have it's own entry in the bbox cache. When
|
||||
// instancing is involved we store the prototype prims and their children in
|
||||
// the cache for use by each prim that instances each prototype. However,
|
||||
// because of the way we compute and inherit purpose, we may end up needed
|
||||
// to compute multitple different bboxes for prototypes and their children
|
||||
// if the prims that instance them would cause these prototypes to inherit a
|
||||
// different purpose value when the prims under the prototype don't have an
|
||||
// authored purpose of their own.
|
||||
//
|
||||
// This struct is here to represent a prim and the purpose that it would
|
||||
// inherit from the prim that instances it. It is used as the key for the
|
||||
// map of prim's to the cached entries, allowing prims in prototypes to have
|
||||
// more than one bbox cache entry for each distinct context needed to
|
||||
// appropriately compute for all instances. instanceInheritablePurpose will
|
||||
// always be empty for prims that aren't prototypes or children of
|
||||
// prototypes, meaning that prims not in prototypes will only have one
|
||||
// context each.
|
||||
struct _PrimContext {
|
||||
// The prim itself
|
||||
UsdPrim prim;
|
||||
|
||||
// The purpose that would be inherited from the instancing prim if this
|
||||
// prim does not have an explicit purpose.
|
||||
TfToken instanceInheritablePurpose;
|
||||
|
||||
_PrimContext() = default;
|
||||
explicit _PrimContext(const UsdPrim &prim_,
|
||||
const TfToken &purpose = TfToken())
|
||||
: prim(prim_), instanceInheritablePurpose(purpose) {};
|
||||
|
||||
bool operator==(const _PrimContext &rhs) const {
|
||||
return prim == rhs.prim &&
|
||||
instanceInheritablePurpose == rhs.instanceInheritablePurpose;
|
||||
}
|
||||
|
||||
// Convenience stringify for debugging.
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
bool
|
||||
_ComputePointInstanceBoundsHelper(
|
||||
const UsdGeomPointInstancer &instancer,
|
||||
int64_t const *instanceIdBegin,
|
||||
size_t numIds,
|
||||
GfMatrix4d const &xform,
|
||||
GfBBox3d *result);
|
||||
|
||||
// Returns true if the \p prim should be included during child bounds
|
||||
// accumulation.
|
||||
bool _ShouldIncludePrim(const UsdPrim& prim);
|
||||
|
||||
// True if \p attr or \p query may return different values given different
|
||||
// time queries. Note that a true result implies the attribute may have no
|
||||
// value, a default value or a single time sample value.
|
||||
bool _IsVarying(const UsdAttribute& attr);
|
||||
bool _IsVarying(const UsdAttributeQuery& query);
|
||||
|
||||
// Populate the local bbox for the requested prim, without the
|
||||
// local-to-world transform or local transform applied. Return true when
|
||||
// bbox volume > 0.
|
||||
bool _Resolve(const UsdPrim& prim, _PurposeToBBoxMap *bboxes);
|
||||
|
||||
// Compute the extent of a UsdGeomBoundable object. Return true if the
|
||||
// computation succeeds and false on failure.
|
||||
bool _ComputeExtent(
|
||||
const UsdGeomBoundable& boundableObj,
|
||||
VtVec3fArray* extent) const;
|
||||
|
||||
// Resolves a single prim. This method must be thread safe. Assumes the
|
||||
// cache entry has been created for \p prim.
|
||||
//
|
||||
// \p inverseComponentCtm is used to combine all the child bboxes in
|
||||
// component-relative space.
|
||||
void _ResolvePrim(_BBoxTask* task,
|
||||
const _PrimContext& prim,
|
||||
const GfMatrix4d &inverseComponentCtm);
|
||||
|
||||
struct _Entry {
|
||||
_Entry()
|
||||
: isComplete(false)
|
||||
, isVarying(false)
|
||||
, isIncluded(false)
|
||||
{ }
|
||||
|
||||
// The cached bboxes for the various values of purpose token.
|
||||
_PurposeToBBoxMap bboxes;
|
||||
|
||||
// True when data in the entry is valid.
|
||||
bool isComplete;
|
||||
|
||||
// True when the entry varies over time.
|
||||
bool isVarying;
|
||||
|
||||
// True when the entry is visible.
|
||||
bool isIncluded;
|
||||
|
||||
// Computed purpose info of the prim that's associated with the entry.
|
||||
// This data includes the prim's actual computed purpose as well as
|
||||
// whether this purpose is inheritable by child prims.
|
||||
UsdGeomImageable::PurposeInfo purposeInfo;
|
||||
|
||||
// Queries for attributes that need to be re-computed at each
|
||||
// time for this entry. This will be invalid for non-varying entries.
|
||||
boost::shared_array<UsdAttributeQuery> queries;
|
||||
};
|
||||
|
||||
// Returns the cache entry for the given \p prim if one already exists.
|
||||
// If no entry exists, creates (but does not resolve) entries for
|
||||
// \p prim and all of its descendents. In this case, the prototype prims
|
||||
// whose bounding boxes need to be resolved in order to resolve \p prim
|
||||
// will be returned in \p prototypePrimContexts.
|
||||
_Entry* _FindOrCreateEntriesForPrim(
|
||||
const _PrimContext& prim,
|
||||
std::vector<_PrimContext> *prototypePrimContexts);
|
||||
|
||||
// Returns the combined bounding box for the currently included set of
|
||||
// purposes given a _PurposeToBBoxMap.
|
||||
GfBBox3d _GetCombinedBBoxForIncludedPurposes(
|
||||
const _PurposeToBBoxMap &bboxes);
|
||||
|
||||
// Populates \p bbox with the bounding box computed from the authored
|
||||
// extents hint. Based on the included purposes, the extents in the
|
||||
// extentsHint attribute are combined together to compute the bounding box.
|
||||
bool _GetBBoxFromExtentsHint(
|
||||
const UsdGeomModelAPI &geomModel,
|
||||
const UsdAttributeQuery &extentsHintQuery,
|
||||
_PurposeToBBoxMap *bboxes);
|
||||
|
||||
// Returns whether the children of the given prim can be pruned
|
||||
// from the traversal to pre-populate entries.
|
||||
bool _ShouldPruneChildren(const UsdPrim &prim, _Entry *entry);
|
||||
|
||||
// Helper function for computing a prim's purpose info efficiently by
|
||||
// using the parent entry's cached computed purpose info and caching it
|
||||
// its cache entry.
|
||||
// Optionally this can recursively compute and cache the purposes for any
|
||||
// existing parent entries in the cache that haven't had their purposes
|
||||
// computed yet.
|
||||
template <bool IsRecursive>
|
||||
void _ComputePurposeInfo(_Entry *entry, const _PrimContext &prim);
|
||||
|
||||
// Helper to determine if we should use extents hints for \p prim.
|
||||
inline bool _UseExtentsHintForPrim(UsdPrim const &prim) const;
|
||||
|
||||
// Need hash_value for boost to key cache entries by prim context.
|
||||
friend size_t hash_value(const _PrimContext &key);
|
||||
|
||||
typedef boost::hash<_PrimContext> _PrimContextHash;
|
||||
typedef TfHashMap<_PrimContext, _Entry, _PrimContextHash> _PrimBBoxHashMap;
|
||||
|
||||
// Finds the cache entry for the prim context if it exists.
|
||||
_Entry *_FindEntry(const _PrimContext &primContext)
|
||||
{
|
||||
return TfMapLookupPtr(_bboxCache, primContext);
|
||||
}
|
||||
|
||||
// Returns the cache entry for the prim context, adding it if doesn't
|
||||
// exist.
|
||||
_Entry *_InsertEntry(const _PrimContext &primContext)
|
||||
{
|
||||
return &(_bboxCache[primContext]);
|
||||
}
|
||||
|
||||
WorkDispatcher _dispatcher;
|
||||
UsdTimeCode _time;
|
||||
boost::optional<UsdTimeCode> _baseTime;
|
||||
TfTokenVector _includedPurposes;
|
||||
UsdGeomXformCache _ctmCache;
|
||||
_PrimBBoxHashMap _bboxCache;
|
||||
bool _useExtentsHint;
|
||||
bool _ignoreVisibility;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_USD_GEOM_BBOX_CACHE_H
|
||||
@@ -0,0 +1,227 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_BOUNDABLE_H
|
||||
#define USDGEOM_GENERATED_BOUNDABLE_H
|
||||
|
||||
/// \file usdGeom/boundable.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/xformable.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// BOUNDABLE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomBoundable
|
||||
///
|
||||
/// Boundable introduces the ability for a prim to persistently
|
||||
/// cache a rectilinear, local-space, extent.
|
||||
///
|
||||
/// \section UsdGeom_Boundable_Extent Why Extent and not Bounds ?
|
||||
/// Boundable introduces the notion of "extent", which is a cached computation
|
||||
/// of a prim's local-space 3D range for its resolved attributes <b>at the
|
||||
/// layer and time in which extent is authored</b>. We have found that with
|
||||
/// composed scene description, attempting to cache pre-computed bounds at
|
||||
/// interior prims in a scene graph is very fragile, given the ease with which
|
||||
/// one can author a single attribute in a stronger layer that can invalidate
|
||||
/// many authored caches - or with which a re-published, referenced asset can
|
||||
/// do the same.
|
||||
///
|
||||
/// Therefore, we limit to precomputing (generally) leaf-prim extent, which
|
||||
/// avoids the need to read in large point arrays to compute bounds, and
|
||||
/// provides UsdGeomBBoxCache the means to efficiently compute and
|
||||
/// (session-only) cache intermediate bounds. You are free to compute and
|
||||
/// author intermediate bounds into your scenes, of course, which may work
|
||||
/// well if you have sufficient locks on your pipeline to guarantee that once
|
||||
/// authored, the geometry and transforms upon which they are based will
|
||||
/// remain unchanged, or if accuracy of the bounds is not an ironclad
|
||||
/// requisite.
|
||||
///
|
||||
/// When intermediate bounds are authored on Boundable parents, the child prims
|
||||
/// will be pruned from BBox computation; the authored extent is expected to
|
||||
/// incorporate all child bounds.
|
||||
///
|
||||
class UsdGeomBoundable : public UsdGeomXformable
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// Construct a UsdGeomBoundable on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomBoundable::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomBoundable(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomXformable(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomBoundable on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomBoundable(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomBoundable(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomXformable(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomBoundable();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomBoundable holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomBoundable(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomBoundable
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// EXTENT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Extent is a three dimensional range measuring the geometric
|
||||
/// extent of the authored gprim in its own local space (i.e. its own
|
||||
/// transform not applied), \em without accounting for any shader-induced
|
||||
/// displacement. Whenever any geometry-affecting attribute is authored
|
||||
/// for any gprim in a layer, extent must also be authored at the same
|
||||
/// timesample; failure to do so will result in incorrect bounds-computation.
|
||||
/// \sa \ref UsdGeom_Boundable_Extent.
|
||||
///
|
||||
/// An authored extent on a prim which has children is expected to include
|
||||
/// the extent of all children, as they will be pruned from BBox computation
|
||||
/// during traversal.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float3[] extent` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExtentAttr() const;
|
||||
|
||||
/// See GetExtentAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Compute the extent for the Boundable prim \p boundable at time
|
||||
/// \p time. If successful, populates \p extent with the result and
|
||||
/// returns \c true, otherwise returns \c false.
|
||||
///
|
||||
/// The extent computation is based on the concrete type of the prim
|
||||
/// represented by \p boundable. Plugins that provide a Boundable
|
||||
/// prim type may implement and register an extent computation for that
|
||||
/// type using #UsdGeomRegisterComputeExtentFunction.
|
||||
/// ComputeExtentFromPlugins will use this function to compute extents
|
||||
/// for all prims of that type. If no function has been registered for
|
||||
/// a prim type, but a function has been registered for one of its
|
||||
/// base types, that function will be used instead.
|
||||
///
|
||||
/// \note This function may load plugins in order to access the extent
|
||||
/// computation for a prim type.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtentFromPlugins(const UsdGeomBoundable &boundable,
|
||||
const UsdTimeCode &time,
|
||||
VtVec3fArray *extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtentFromPlugins(const UsdGeomBoundable &boundable,
|
||||
const UsdTimeCode &time,
|
||||
const GfMatrix4d &transform,
|
||||
VtVec3fArray *extent);
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// Copyright 2017 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_BOUNDABLE_COMPUTE_EXTENT_H
|
||||
#define PXR_USD_USD_GEOM_BOUNDABLE_COMPUTE_EXTENT_H
|
||||
|
||||
/// \file usdGeom/boundableComputeExtent.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/vt/array.h"
|
||||
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class UsdGeomBoundable;
|
||||
class UsdTimeCode;
|
||||
|
||||
/// Function registered with #UsdGeomRegisterComputeExtentFunction for
|
||||
/// computing extents for a Boundable prim at the given time and filling
|
||||
/// the given VtVec3fArray with the result. If an optional transform matrix is
|
||||
/// supplied, the extent is computed as if the object was first transformed by
|
||||
/// the matrix. If the transform matrix is nullptr, the extent is computed as if
|
||||
/// the identity matrix was passed.
|
||||
///
|
||||
/// The Boundable is guaranteed to be convertible to the prim type this
|
||||
/// function was registered with. The function must be thread-safe.
|
||||
/// It should return true on success, false on failure.
|
||||
using UsdGeomComputeExtentFunction = bool(*)(const UsdGeomBoundable&,
|
||||
const UsdTimeCode&,
|
||||
const GfMatrix4d*,
|
||||
VtVec3fArray*);
|
||||
|
||||
/// Registers \p fn as the function to use for computing extents for Boundable
|
||||
/// prims of type \p PrimType by UsdGeomBoundable::ComputeExtentFromPlugins.
|
||||
/// \p PrimType must derive from UsdGeomBoundable.
|
||||
///
|
||||
/// Plugins should generally call this function in a TF_REGISTRY_FUNCTION.
|
||||
/// For example:
|
||||
///
|
||||
/// \code
|
||||
/// TF_REGISTRY_FUNCTION(UsdGeomBoundable)
|
||||
/// {
|
||||
/// UsdGeomRegisterComputeExtentFunction<MyPrim>(MyComputeExtentFunction);
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// Plugins must also note that this function is implemented for a prim type
|
||||
/// in that type's schema definition. For example:
|
||||
///
|
||||
/// \code
|
||||
/// class "MyPrim" (
|
||||
/// ...
|
||||
/// customData = {
|
||||
/// dictionary extraPlugInfo = {
|
||||
/// bool implementsComputeExtent = true
|
||||
/// }
|
||||
/// }
|
||||
/// ...
|
||||
/// )
|
||||
/// { ... }
|
||||
/// \endcode
|
||||
///
|
||||
/// This allows the plugin system to discover this function dynamically
|
||||
/// and load the plugin if needed.
|
||||
template <class PrimType>
|
||||
inline void
|
||||
UsdGeomRegisterComputeExtentFunction(
|
||||
const UsdGeomComputeExtentFunction& fn)
|
||||
{
|
||||
static_assert(
|
||||
std::is_base_of<UsdGeomBoundable, PrimType>::value,
|
||||
"Prim type must derive from UsdGeomBoundable");
|
||||
|
||||
UsdGeomRegisterComputeExtentFunction(TfType::Find<PrimType>(), fn);
|
||||
}
|
||||
|
||||
/// \overload
|
||||
USDGEOM_API
|
||||
void
|
||||
UsdGeomRegisterComputeExtentFunction(
|
||||
const TfType& boundableType,
|
||||
const UsdGeomComputeExtentFunction& fn);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_USD_GEOM_BOUNDABLE_COMPUTE_EXTENT_H
|
||||
@@ -0,0 +1,541 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_CAMERA_H
|
||||
#define USDGEOM_GENERATED_CAMERA_H
|
||||
|
||||
/// \file usdGeom/camera.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/xformable.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/gf/camera.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// CAMERA //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomCamera
|
||||
///
|
||||
/// Transformable camera.
|
||||
///
|
||||
/// Describes optical properties of a camera via a common set of attributes
|
||||
/// that provide control over the camera's frustum as well as its depth of
|
||||
/// field. For stereo, the left and right camera are individual prims tagged
|
||||
/// through the \ref UsdGeomCamera::GetStereoRoleAttr() "stereoRole attribute".
|
||||
///
|
||||
/// There is a corresponding class GfCamera, which can hold the state of a
|
||||
/// camera (at a particular time). \ref UsdGeomCamera::GetCamera() and
|
||||
/// \ref UsdGeomCamera::SetFromCamera() convert between a USD camera prim and
|
||||
/// a GfCamera.
|
||||
///
|
||||
/// To obtain the camera's location in world space, call the following on a
|
||||
/// UsdGeomCamera 'camera':
|
||||
/// \code
|
||||
/// GfMatrix4d camXform = camera.ComputeLocalToWorldTransform(time);
|
||||
/// \endcode
|
||||
/// \note
|
||||
/// <b>Cameras in USD are always "Y up", regardless of the stage's orientation
|
||||
/// (i.e. UsdGeomGetStageUpAxis()).</b> This means that the inverse of
|
||||
/// 'camXform' (the VIEW half of the <A HREF="http://www.glprogramming.com/red/chapter03.html#name2">MODELVIEW transform in OpenGL parlance</A>)
|
||||
/// will transform the world such that the camera is at the origin, looking
|
||||
/// down the -Z axis, with +Y as the up axis, and +X pointing to the right.
|
||||
/// This describes a __right handed coordinate system__.
|
||||
///
|
||||
/// \sa \ref UsdGeom_LinAlgBasics
|
||||
///
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomCamera : public UsdGeomXformable
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomCamera on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomCamera::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomCamera(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomXformable(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomCamera on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomCamera(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomCamera(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomXformable(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomCamera();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomCamera holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomCamera(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCamera
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCamera
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// PROJECTION
|
||||
// --------------------------------------------------------------------- //
|
||||
///
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `token projection = "perspective"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | perspective, orthographic |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetProjectionAttr() const;
|
||||
|
||||
/// See GetProjectionAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateProjectionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// HORIZONTALAPERTURE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Horizontal aperture in millimeters (or, more general, tenths
|
||||
/// of a world unit).
|
||||
/// Defaults to the standard 35mm spherical projector aperture.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float horizontalAperture = 20.955` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetHorizontalApertureAttr() const;
|
||||
|
||||
/// See GetHorizontalApertureAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateHorizontalApertureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VERTICALAPERTURE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Vertical aperture in millimeters (or, more general, tenths of
|
||||
/// a world unit).
|
||||
/// Defaults to the standard 35mm spherical projector aperture.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float verticalAperture = 15.2908` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVerticalApertureAttr() const;
|
||||
|
||||
/// See GetVerticalApertureAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVerticalApertureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// HORIZONTALAPERTUREOFFSET
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Horizontal aperture offset in the same units as
|
||||
/// horizontalAperture. Defaults to 0.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float horizontalApertureOffset = 0` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetHorizontalApertureOffsetAttr() const;
|
||||
|
||||
/// See GetHorizontalApertureOffsetAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateHorizontalApertureOffsetAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VERTICALAPERTUREOFFSET
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Vertical aperture offset in the same units as
|
||||
/// verticalAperture. Defaults to 0.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float verticalApertureOffset = 0` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVerticalApertureOffsetAttr() const;
|
||||
|
||||
/// See GetVerticalApertureOffsetAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVerticalApertureOffsetAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// FOCALLENGTH
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Perspective focal length in millimeters (or, more general,
|
||||
/// tenths of a world unit).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float focalLength = 50` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetFocalLengthAttr() const;
|
||||
|
||||
/// See GetFocalLengthAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateFocalLengthAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CLIPPINGRANGE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Near and far clipping distances in centimeters (or, more
|
||||
/// general, world units).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float2 clippingRange = (1, 1000000)` |
|
||||
/// | C++ Type | GfVec2f |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float2 |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetClippingRangeAttr() const;
|
||||
|
||||
/// See GetClippingRangeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateClippingRangeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CLIPPINGPLANES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Additional, arbitrarily oriented clipping planes.
|
||||
/// A vector (a,b,c,d) encodes a clipping plane that cuts off
|
||||
/// (x,y,z) with a * x + b * y + c * z + d * 1 < 0 where (x,y,z)
|
||||
/// are the coordinates in the camera's space.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float4[] clippingPlanes = []` |
|
||||
/// | C++ Type | VtArray<GfVec4f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float4Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetClippingPlanesAttr() const;
|
||||
|
||||
/// See GetClippingPlanesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateClippingPlanesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// FSTOP
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Lens aperture. Defaults to 0.0, which turns off focusing.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float fStop = 0` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetFStopAttr() const;
|
||||
|
||||
/// See GetFStopAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateFStopAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// FOCUSDISTANCE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Distance from the camera to the focus plane in centimeters (or
|
||||
/// more general, world units).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float focusDistance = 0` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetFocusDistanceAttr() const;
|
||||
|
||||
/// See GetFocusDistanceAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateFocusDistanceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// STEREOROLE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// If different from mono, the camera is intended to be the left
|
||||
/// or right camera of a stereo setup.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token stereoRole = "mono"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | mono, left, right |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetStereoRoleAttr() const;
|
||||
|
||||
/// See GetStereoRoleAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateStereoRoleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// SHUTTEROPEN
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Frame relative shutter open time in UsdTimeCode units (negative
|
||||
/// value indicates that the shutter opens before the current
|
||||
/// frame time). Used for motion blur.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double shutter:open = 0` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetShutterOpenAttr() const;
|
||||
|
||||
/// See GetShutterOpenAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateShutterOpenAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// SHUTTERCLOSE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Frame relative shutter close time, analogous comments from
|
||||
/// shutter:open apply. A value greater or equal to shutter:open
|
||||
/// should be authored, otherwise there is no exposure and a
|
||||
/// renderer should produce a black image.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double shutter:close = 0` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetShutterCloseAttr() const;
|
||||
|
||||
/// See GetShutterCloseAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateShutterCloseAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// EXPOSURE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Exposure adjustment, as a log base-2 value. The default
|
||||
/// of 0.0 has no effect. A value of 1.0 will double the
|
||||
/// image-plane intensities in a rendered image; a value of
|
||||
/// -1.0 will halve them.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float exposure = 0` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExposureAttr() const;
|
||||
|
||||
/// See GetExposureAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateExposureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Creates a GfCamera object from the attribute values at \p time.
|
||||
///
|
||||
USDGEOM_API
|
||||
GfCamera GetCamera(const UsdTimeCode &time) const;
|
||||
|
||||
/// Write attribute values from \p camera for \p time.
|
||||
///
|
||||
USDGEOM_API
|
||||
void SetFromCamera(const GfCamera &camera, const UsdTimeCode &time);
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,292 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_CAPSULE_H
|
||||
#define USDGEOM_GENERATED_CAPSULE_H
|
||||
|
||||
/// \file usdGeom/capsule.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/gprim.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// CAPSULE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomCapsule
|
||||
///
|
||||
/// Defines a primitive capsule, i.e. a cylinder capped by two half
|
||||
/// spheres, centered at the origin, whose spine is along the specified
|
||||
/// \em axis.
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomCapsule : public UsdGeomGprim
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomCapsule on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomCapsule::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomCapsule(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomGprim(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomCapsule on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomCapsule(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomCapsule(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomGprim(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomCapsule();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomCapsule holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomCapsule(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCapsule
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCapsule
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// HEIGHT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The size of the capsule's spine along the specified
|
||||
/// \em axis excluding the size of the two half spheres, i.e.
|
||||
/// the size of the cylinder portion of the capsule.
|
||||
/// If you author \em height you must also author \em extent.
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double height = 1` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetHeightAttr() const;
|
||||
|
||||
/// See GetHeightAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateHeightAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// RADIUS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The radius of the capsule. If you
|
||||
/// author \em radius you must also author \em extent.
|
||||
///
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double radius = 0.5` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetRadiusAttr() const;
|
||||
|
||||
/// See GetRadiusAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateRadiusAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// AXIS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The axis along which the spine of the capsule is aligned
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token axis = "Z"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | X, Y, Z |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetAxisAttr() const;
|
||||
|
||||
/// See GetAxisAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateAxisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// EXTENT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Extent is re-defined on Capsule only to provide a fallback
|
||||
/// value. \sa UsdGeomGprim::GetExtentAttr().
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float3[] extent = [(-0.5, -0.5, -1), (0.5, 0.5, 1)]` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExtentAttr() const;
|
||||
|
||||
/// See GetExtentAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Compute the extent for the capsule defined by the height, radius, and
|
||||
/// axis.
|
||||
///
|
||||
/// \return true upon success, false if unable to calculate extent.
|
||||
///
|
||||
/// On success, extent will contain an approximate axis-aligned bounding
|
||||
/// box of the capsule defined by the height, radius, and axis.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double height, double radius, const TfToken& axis,
|
||||
VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double height, double radius, const TfToken& axis,
|
||||
const GfMatrix4d& transform, VtVec3fArray* extent);
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,294 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_CONE_H
|
||||
#define USDGEOM_GENERATED_CONE_H
|
||||
|
||||
/// \file usdGeom/cone.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/gprim.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// CONE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomCone
|
||||
///
|
||||
/// Defines a primitive cone, centered at the origin, whose spine
|
||||
/// is along the specified \em axis, with the apex of the cone pointing
|
||||
/// in the direction of the positive axis.
|
||||
///
|
||||
/// The fallback values for Cube, Sphere, Cone, and Cylinder are set so that
|
||||
/// they all pack into the same volume/bounds.
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomCone : public UsdGeomGprim
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomCone on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomCone::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomCone(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomGprim(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomCone on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomCone(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomCone(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomGprim(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomCone();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomCone holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomCone(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCone
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCone
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// HEIGHT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The size of the cone's spine along the specified
|
||||
/// \em axis. If you author \em height you must also author \em extent.
|
||||
///
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double height = 2` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetHeightAttr() const;
|
||||
|
||||
/// See GetHeightAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateHeightAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// RADIUS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The radius of the cone. If you
|
||||
/// author \em radius you must also author \em extent.
|
||||
///
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double radius = 1` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetRadiusAttr() const;
|
||||
|
||||
/// See GetRadiusAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateRadiusAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// AXIS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The axis along which the spine of the cone is aligned
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token axis = "Z"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | X, Y, Z |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetAxisAttr() const;
|
||||
|
||||
/// See GetAxisAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateAxisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// EXTENT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Extent is re-defined on Cone only to provide a fallback
|
||||
/// value. \sa UsdGeomGprim::GetExtentAttr().
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float3[] extent = [(-1, -1, -1), (1, 1, 1)]` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExtentAttr() const;
|
||||
|
||||
/// See GetExtentAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Compute the extent for the cone defined by the height, radius, and
|
||||
/// axis.
|
||||
///
|
||||
/// \return true upon success, false if unable to calculate extent.
|
||||
///
|
||||
/// On success, extent will contain an approximate axis-aligned bounding
|
||||
/// box of the cone defined by the height, radius, and axis.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double height, double radius, const TfToken& axis,
|
||||
VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double height, double radius, const TfToken& axis,
|
||||
const GfMatrix4d& transform, VtVec3fArray* extent);
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,176 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_CONSTRAINT_TARGET_H
|
||||
#define PXR_USD_USD_GEOM_CONSTRAINT_TARGET_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/attribute.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
class GfMatrix4d;
|
||||
class UsdGeomXformCache;
|
||||
|
||||
/// \class UsdGeomConstraintTarget
|
||||
///
|
||||
/// Schema wrapper for UsdAttribute for authoring and introspecting
|
||||
/// attributes that are constraint targets.
|
||||
///
|
||||
/// Constraint targets correspond roughly to what some DCC's call locators.
|
||||
/// They are coordinate frames, represented as (animated or static) GfMatrix4d
|
||||
/// values. We represent them as attributes in USD rather than transformable
|
||||
/// prims because generally we require no other coordinated information about
|
||||
/// a constraint target other than its name and its matrix value, and because
|
||||
/// attributes are more concise than prims.
|
||||
///
|
||||
/// Because consumer clients often care only about the identity and value of
|
||||
/// constraint targets and may be able to usefully consume them without caring
|
||||
/// about the actual geometry with which they may logically correspond,
|
||||
/// UsdGeom aggregates all constraint targets onto a model's root prim,
|
||||
/// assuming that an exporter will use property namespacing within the
|
||||
/// constraint target attribute's name to indicate a path to a prim within
|
||||
/// the model with which the constraint target may correspond.
|
||||
///
|
||||
/// To facilitate instancing, and also position-tweaking of baked assets, we
|
||||
/// stipulate that constraint target values always be recorded in
|
||||
/// <b>model-relative transformation space</b>. In other words, to get the
|
||||
/// world-space value of a constraint target, transform it by the
|
||||
/// local-to-world transformation of the prim on which it is recorded.
|
||||
/// ComputeInWorldSpace() will perform this calculation.
|
||||
///
|
||||
/// \todo Provide API for extracting prim or property path from a target's
|
||||
/// namespaced name.
|
||||
///
|
||||
class UsdGeomConstraintTarget
|
||||
{
|
||||
public:
|
||||
|
||||
// Default constructor returns an invalid ConstraintTarget. Exists for
|
||||
// container classes
|
||||
UsdGeomConstraintTarget()
|
||||
{
|
||||
/* NOTHING */
|
||||
}
|
||||
|
||||
/// Speculative constructor that will produce a valid
|
||||
/// UsdGeomConstraintTarget when \p attr already represents an attribute
|
||||
/// that is a UsdGeomConstraintTarget, and produces an \em invalid
|
||||
/// UsdGeomConstraintTarget otherwise (i.e.
|
||||
/// \ref UsdGeomConstraintTarget_explicit_bool will return false).
|
||||
///
|
||||
/// Calling \c UsdGeomConstraintTarget::IsValid(attr) will return the
|
||||
/// same truth value as the object returned by this constructor, but if
|
||||
/// you plan to subsequently use the ConstraintTarget anyways, just
|
||||
/// construct the object and bool-evaluate it before proceeding.
|
||||
USDGEOM_API
|
||||
explicit UsdGeomConstraintTarget(const UsdAttribute &attr);
|
||||
|
||||
/// Test whether a given UsdAttribute represents valid ConstraintTarget,
|
||||
/// which implies that creating a UsdGeomConstraintTarget from the attribute
|
||||
/// will succeed.
|
||||
///
|
||||
/// Success implies that \c attr.IsDefined() is true.
|
||||
USDGEOM_API
|
||||
static bool IsValid(const UsdAttribute &attr);
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/// \name UsdAttribute API
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/// Allow UsdGeomConstraintTarget to auto-convert to UsdAttribute, so you
|
||||
/// can pass a UsdGeomConstraintTarget to any function that accepts a
|
||||
/// UsdAttribute or const-ref thereto.
|
||||
operator UsdAttribute const& () const { return _attr; }
|
||||
|
||||
/// Explicit UsdAttribute extractor
|
||||
UsdAttribute const &GetAttr() const { return _attr; }
|
||||
|
||||
/// Return true if the wrapped UsdAttribute::IsDefined(), and in
|
||||
/// addition the attribute is identified as a ConstraintTarget.
|
||||
bool IsDefined() const { return IsValid(_attr); }
|
||||
|
||||
|
||||
/// \anchor UsdGeomConstraintTarget_explicit_bool
|
||||
/// Explicit bool conversion operator. A ConstraintTarget object converts
|
||||
/// to \c true iff it is valid for querying and authoring values and
|
||||
/// metadata (which is identically equivalent to IsDefined()). It converts
|
||||
/// to \c false otherwise.
|
||||
explicit operator bool() const {
|
||||
return IsDefined();
|
||||
}
|
||||
|
||||
/// Get the attribute value of the ConstraintTarget at \p time
|
||||
USDGEOM_API
|
||||
bool Get(GfMatrix4d* value, UsdTimeCode time = UsdTimeCode::Default())
|
||||
const;
|
||||
|
||||
/// Set the attribute value of the ConstraintTarget at \p time
|
||||
USDGEOM_API
|
||||
bool Set(const GfMatrix4d& value, UsdTimeCode time = UsdTimeCode::Default())
|
||||
const;
|
||||
|
||||
/// Get the stored identifier unique to the enclosing model's namespace for
|
||||
/// this constraint target.
|
||||
/// \sa SetIdentifier()
|
||||
USDGEOM_API
|
||||
TfToken GetIdentifier() const;
|
||||
|
||||
/// Explicitly sets the stored identifier to the given string. Clients are
|
||||
/// responsible for ensuring the uniqueness of this identifier within the
|
||||
/// enclosing model's namespace.
|
||||
USDGEOM_API
|
||||
void SetIdentifier(const TfToken &identifier);
|
||||
|
||||
/// Returns the fully namespaced constraint attribute name, given the
|
||||
/// constraint name.
|
||||
USDGEOM_API
|
||||
static TfToken GetConstraintAttrName(const std::string &constraintName);
|
||||
|
||||
/// Computes the value of the constraint target in world space.
|
||||
///
|
||||
/// If a valid UsdGeomXformCache is provided in the argument \p xfCache,
|
||||
/// it is used to evaluate the CTM of the model to which the constraint
|
||||
/// target belongs.
|
||||
///
|
||||
/// To get the constraint value in model-space (or local space), simply
|
||||
/// use UsdGeomConstraintTarget::Get(), since the authored values must
|
||||
/// already be in model-space.
|
||||
///
|
||||
USDGEOM_API
|
||||
GfMatrix4d ComputeInWorldSpace(UsdTimeCode time=UsdTimeCode::Default(),
|
||||
UsdGeomXformCache *xfCache=NULL) const;
|
||||
|
||||
private:
|
||||
|
||||
UsdAttribute _attr;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // USD_CONSTRAINT_TARGET_H
|
||||
@@ -0,0 +1,236 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_CUBE_H
|
||||
#define USDGEOM_GENERATED_CUBE_H
|
||||
|
||||
/// \file usdGeom/cube.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/gprim.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// CUBE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomCube
|
||||
///
|
||||
/// Defines a primitive rectilinear cube centered at the origin.
|
||||
///
|
||||
/// The fallback values for Cube, Sphere, Cone, and Cylinder are set so that
|
||||
/// they all pack into the same volume/bounds.
|
||||
///
|
||||
class UsdGeomCube : public UsdGeomGprim
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomCube on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomCube::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomCube(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomGprim(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomCube on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomCube(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomCube(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomGprim(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomCube();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomCube holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomCube(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCube
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCube
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// SIZE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Indicates the length of each edge of the cube. If you
|
||||
/// author \em size you must also author \em extent.
|
||||
///
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double size = 2` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetSizeAttr() const;
|
||||
|
||||
/// See GetSizeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateSizeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// EXTENT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Extent is re-defined on Cube only to provide a fallback value.
|
||||
/// \sa UsdGeomGprim::GetExtentAttr().
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float3[] extent = [(-1, -1, -1), (1, 1, 1)]` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExtentAttr() const;
|
||||
|
||||
/// See GetExtentAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Compute the extent for the cube defined by the size of each dimension.
|
||||
///
|
||||
/// \return true upon success, false if unable to calculate extent.
|
||||
///
|
||||
/// On success, extent will contain an approximate axis-aligned bounding
|
||||
/// box of the cube defined by the size of each dimension.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double size, VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double size, const GfMatrix4d& transform,
|
||||
VtVec3fArray* extent);
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,265 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_CURVES_H
|
||||
#define USDGEOM_GENERATED_CURVES_H
|
||||
|
||||
/// \file usdGeom/curves.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/pointBased.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// CURVES //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomCurves
|
||||
///
|
||||
/// Base class for UsdGeomBasisCurves, UsdGeomNurbsCurves, and
|
||||
/// UsdGeomHermiteCurves. The BasisCurves schema is designed to be
|
||||
/// analagous to offline renderers' notion of batched curves (such as
|
||||
/// the classical RIB definition via Basis and Curves statements),
|
||||
/// while the NurbsCurve schema is designed to be analgous to the
|
||||
/// NURBS curves found in packages like Maya and Houdini while
|
||||
/// retaining their consistency with the RenderMan specification for
|
||||
/// NURBS Patches. HermiteCurves are useful for the
|
||||
/// interchange of animation guides and paths.
|
||||
///
|
||||
/// It is safe to use the length of the curve vertex count to derive
|
||||
/// the number of curves and the number and layout of curve vertices,
|
||||
/// but this schema should NOT be used to derive the number of curve
|
||||
/// points. While vertex indices are implicit in all shipped
|
||||
/// descendent types of this schema, one should not assume that all
|
||||
/// internal or future shipped schemas will follow this pattern. Be
|
||||
/// sure to key any indexing behavior off the concrete type, not this
|
||||
/// abstract type.
|
||||
///
|
||||
///
|
||||
class UsdGeomCurves : public UsdGeomPointBased
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// Construct a UsdGeomCurves on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomCurves::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomCurves(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomPointBased(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomCurves on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomCurves(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomCurves(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomPointBased(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomCurves();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomCurves holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomCurves(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCurves
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CURVEVERTEXCOUNTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Curves-derived primitives can represent multiple distinct,
|
||||
/// potentially disconnected curves. The length of 'curveVertexCounts'
|
||||
/// gives the number of such curves, and each element describes the
|
||||
/// number of vertices in the corresponding curve
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] curveVertexCounts` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetCurveVertexCountsAttr() const;
|
||||
|
||||
/// See GetCurveVertexCountsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateCurveVertexCountsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// WIDTHS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Provides width specification for the curves, whose application
|
||||
/// will depend on whether the curve is oriented (normals are defined for
|
||||
/// it), in which case widths are "ribbon width", or unoriented, in which
|
||||
/// case widths are cylinder width. 'widths' is not a generic Primvar,
|
||||
/// but the number of elements in this attribute will be determined by
|
||||
/// its 'interpolation'. See \ref SetWidthsInterpolation() . If 'widths'
|
||||
/// and 'primvars:widths' are both specified, the latter has precedence.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float[] widths` |
|
||||
/// | C++ Type | VtArray<float> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetWidthsAttr() const;
|
||||
|
||||
/// See GetWidthsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateWidthsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Get the \ref Usd_InterpolationVals "interpolation" for the \em widths
|
||||
/// attribute.
|
||||
///
|
||||
/// Although 'widths' is not classified as a generic UsdGeomPrimvar (and
|
||||
/// will not be included in the results of UsdGeomImageable::GetPrimvars() )
|
||||
/// it does require an interpolation specification. The fallback
|
||||
/// interpolation, if left unspecified, is UsdGeomTokens->vertex ,
|
||||
/// which means a width value is specified at the end of each curve segment.
|
||||
USDGEOM_API
|
||||
TfToken GetWidthsInterpolation() const;
|
||||
|
||||
/// Set the \ref Usd_InterpolationVals "interpolation" for the \em widths
|
||||
/// attribute.
|
||||
///
|
||||
/// \return true upon success, false if \p interpolation is not a legal
|
||||
/// value as defined by UsdPrimvar::IsValidInterpolation(), or if there
|
||||
/// was a problem setting the value. No attempt is made to validate
|
||||
/// that the widths attr's value contains the right number of elements
|
||||
/// to match its interpolation to its prim's topology.
|
||||
///
|
||||
/// \sa GetWidthsInterpolation()
|
||||
USDGEOM_API
|
||||
bool SetWidthsInterpolation(TfToken const &interpolation);
|
||||
|
||||
/// Compute the extent for the curves defined by points and widths.
|
||||
///
|
||||
/// \return true upon success, false if unable to calculate extent.
|
||||
///
|
||||
/// On success, extent will contain an approximate axis-aligned bounding
|
||||
/// box of the curve defined by points with the given widths.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(const VtVec3fArray& points,
|
||||
const VtFloatArray& widths, VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(const VtVec3fArray& points,
|
||||
const VtFloatArray& widths, const GfMatrix4d& transform,
|
||||
VtVec3fArray* extent);
|
||||
|
||||
/// Returns the number of curves as defined by the size of the
|
||||
/// _curveVertexCounts_ array at _timeCode_.
|
||||
///
|
||||
/// \snippetdoc snippets.dox GetCount
|
||||
/// \sa GetCurveVertexCountsAttr()
|
||||
USDGEOM_API
|
||||
size_t GetCurveCount(UsdTimeCode timeCode = UsdTimeCode::Default()) const;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,295 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_CYLINDER_H
|
||||
#define USDGEOM_GENERATED_CYLINDER_H
|
||||
|
||||
/// \file usdGeom/cylinder.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/gprim.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// CYLINDER //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomCylinder
|
||||
///
|
||||
/// Defines a primitive cylinder with closed ends, centered at the
|
||||
/// origin, whose spine is along the specified \em axis.
|
||||
///
|
||||
/// The fallback values for Cube, Sphere, Cone, and Cylinder are set so that
|
||||
/// they all pack into the same volume/bounds.
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomCylinder : public UsdGeomGprim
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomCylinder on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomCylinder::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomCylinder(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomGprim(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomCylinder on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomCylinder(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomCylinder(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomGprim(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomCylinder();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomCylinder holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomCylinder(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCylinder
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomCylinder
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// HEIGHT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The size of the cylinder's spine along the specified
|
||||
/// \em axis. If you author \em height you must also author \em extent.
|
||||
///
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double height = 2` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetHeightAttr() const;
|
||||
|
||||
/// See GetHeightAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateHeightAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// RADIUS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The radius of the cylinder. If you author \em radius
|
||||
/// you must also author \em extent.
|
||||
///
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double radius = 1` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetRadiusAttr() const;
|
||||
|
||||
/// See GetRadiusAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateRadiusAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// AXIS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The axis along which the spine of the cylinder is aligned
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token axis = "Z"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | X, Y, Z |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetAxisAttr() const;
|
||||
|
||||
/// See GetAxisAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateAxisAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// EXTENT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Extent is re-defined on Cylinder only to provide a fallback
|
||||
/// value. \sa UsdGeomGprim::GetExtentAttr().
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float3[] extent = [(-1, -1, -1), (1, 1, 1)]` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExtentAttr() const;
|
||||
|
||||
/// See GetExtentAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Compute the extent for the cylinder defined by the height, radius, and
|
||||
/// axis.
|
||||
///
|
||||
/// \return true upon success, false if unable to calculate extent.
|
||||
///
|
||||
/// On success, extent will contain an approximate axis-aligned bounding
|
||||
/// box of the cylinder defined by the height, radius, and axis.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double height, double radius, const TfToken& axis,
|
||||
VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double height, double radius, const TfToken& axis,
|
||||
const GfMatrix4d& transform, VtVec3fArray* extent);
|
||||
};
|
||||
|
||||
#define USDGEOM_CYLINDER_API_VERSION 1
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // USDGEOM_GENERATED_CYLINDER_H
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_DEBUG_CODES_H
|
||||
#define PXR_USD_USD_GEOM_DEBUG_CODES_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/base/tf/debug.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
TF_DEBUG_CODES(
|
||||
|
||||
USDGEOM_BBOX,
|
||||
USDGEOM_XFORMCOMMONAPI
|
||||
);
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_USD_GEOM_DEBUG_CODES_H
|
||||
@@ -0,0 +1,299 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_GPRIM_H
|
||||
#define USDGEOM_GENERATED_GPRIM_H
|
||||
|
||||
/// \file usdGeom/gprim.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/boundable.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// GPRIM //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomGprim
|
||||
///
|
||||
/// Base class for all geometric primitives.
|
||||
///
|
||||
/// Gprim encodes basic graphical properties such as \em doubleSided and
|
||||
/// \em orientation, and provides primvars for "display color" and "display
|
||||
/// opacity" that travel with geometry to be used as shader overrides.
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomGprim : public UsdGeomBoundable
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// Construct a UsdGeomGprim on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomGprim::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomGprim(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomBoundable(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomGprim on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomGprim(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomGprim(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomBoundable(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomGprim();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomGprim holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomGprim(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomGprim
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// DISPLAYCOLOR
|
||||
// --------------------------------------------------------------------- //
|
||||
/// It is useful to have an "official" colorSet that can be used
|
||||
/// as a display or modeling color, even in the absence of any specified
|
||||
/// shader for a gprim. DisplayColor serves this role; because it is a
|
||||
/// UsdGeomPrimvar, it can also be used as a gprim override for any shader
|
||||
/// that consumes a \em displayColor parameter.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `color3f[] primvars:displayColor` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Color3fArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetDisplayColorAttr() const;
|
||||
|
||||
/// See GetDisplayColorAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateDisplayColorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// DISPLAYOPACITY
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Companion to \em displayColor that specifies opacity, broken
|
||||
/// out as an independent attribute rather than an rgba color, both so that
|
||||
/// each can be independently overridden, and because shaders rarely consume
|
||||
/// rgba parameters.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float[] primvars:displayOpacity` |
|
||||
/// | C++ Type | VtArray<float> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetDisplayOpacityAttr() const;
|
||||
|
||||
/// See GetDisplayOpacityAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateDisplayOpacityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// DOUBLESIDED
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Although some renderers treat all parametric or polygonal
|
||||
/// surfaces as if they were effectively laminae with outward-facing
|
||||
/// normals on both sides, some renderers derive significant optimizations
|
||||
/// by considering these surfaces to have only a single outward side,
|
||||
/// typically determined by control-point winding order and/or
|
||||
/// \em orientation. By doing so they can perform "backface culling" to
|
||||
/// avoid drawing the many polygons of most closed surfaces that face away
|
||||
/// from the viewer.
|
||||
///
|
||||
/// However, it is often advantageous to model thin objects such as paper
|
||||
/// and cloth as single, open surfaces that must be viewable from both
|
||||
/// sides, always. Setting a gprim's \em doubleSided attribute to
|
||||
/// \c true instructs all renderers to disable optimizations such as
|
||||
/// backface culling for the gprim, and attempt (not all renderers are able
|
||||
/// to do so, but the USD reference GL renderer always will) to provide
|
||||
/// forward-facing normals on each side of the surface for lighting
|
||||
/// calculations.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform bool doubleSided = 0` |
|
||||
/// | C++ Type | bool |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetDoubleSidedAttr() const;
|
||||
|
||||
/// See GetDoubleSidedAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateDoubleSidedAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// ORIENTATION
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Orientation specifies whether the gprim's surface normal
|
||||
/// should be computed using the right hand rule, or the left hand rule.
|
||||
/// Please see \ref UsdGeom_WindingOrder for a deeper explanation and
|
||||
/// generalization of orientation to composed scenes with transformation
|
||||
/// hierarchies.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token orientation = "rightHanded"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | rightHanded, leftHanded |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetOrientationAttr() const;
|
||||
|
||||
/// See GetOrientationAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateOrientationAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Convenience function to get the displayColor Attribute as a Primvar.
|
||||
///
|
||||
/// \sa GetDisplayColorAttr(), CreateDisplayColorPrimvar()
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar GetDisplayColorPrimvar() const;
|
||||
|
||||
/// Convenience function to create the displayColor primvar, optionally
|
||||
/// specifying interpolation and elementSize
|
||||
///
|
||||
/// \sa CreateDisplayColorAttr(), GetDisplayColorPrimvar()
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar CreateDisplayColorPrimvar(
|
||||
const TfToken& interpolation = TfToken(),
|
||||
int elementSize = -1) const;
|
||||
|
||||
/// Convenience function to get the displayOpacity Attribute as a Primvar.
|
||||
///
|
||||
/// \sa GetDisplayOpacityAttr(), CreateDisplayOpacityPrimvar()
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar GetDisplayOpacityPrimvar() const;
|
||||
|
||||
/// Convenience function to create the displayOpacity primvar, optionally
|
||||
/// specifying interpolation and elementSize
|
||||
///
|
||||
/// \sa CreateDisplayOpacityAttr(), GetDisplayOpacityPrimvar()
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar CreateDisplayOpacityPrimvar(
|
||||
const TfToken& interpolation = TfToken(),
|
||||
int elementSize = -1) const;
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,286 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_HERMITECURVES_H
|
||||
#define USDGEOM_GENERATED_HERMITECURVES_H
|
||||
|
||||
/// \file usdGeom/hermiteCurves.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/curves.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// HERMITECURVES //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomHermiteCurves
|
||||
///
|
||||
/// This schema specifies a cubic hermite interpolated curve batch as
|
||||
/// sometimes used for defining guides for animation. While hermite curves can
|
||||
/// be useful because they interpolate through their control points, they are
|
||||
/// not well supported by high-end renderers for imaging. Therefore, while we
|
||||
/// include this schema for interchange, we strongly recommend the use of
|
||||
/// UsdGeomBasisCurves as the representation of curves intended to be rendered
|
||||
/// (ie. hair or grass). Hermite curves can be converted to a Bezier
|
||||
/// representation (though not from Bezier back to Hermite in general).
|
||||
///
|
||||
/// \section UsdGeomHermiteCurves_Interpolation Point Interpolation
|
||||
///
|
||||
/// The initial cubic curve segment is defined by the first two points and
|
||||
/// first two tangents. Additional segments are defined by additional
|
||||
/// point / tangent pairs. The number of segments for each non-batched hermite
|
||||
/// curve would be len(curve.points) - 1. The total number of segments
|
||||
/// for the batched UsdGeomHermiteCurves representation is
|
||||
/// len(points) - len(curveVertexCounts).
|
||||
///
|
||||
/// \section UsdGeomHermiteCurves_Primvars Primvar, Width, and Normal Interpolation
|
||||
///
|
||||
/// Primvar interpolation is not well specified for this type as it is not
|
||||
/// intended as a rendering representation. We suggest that per point
|
||||
/// primvars would be linearly interpolated across each segment and should
|
||||
/// be tagged as 'varying'.
|
||||
///
|
||||
/// It is not immediately clear how to specify cubic or 'vertex' interpolation
|
||||
/// for this type, as we lack a specification for primvar tangents. This
|
||||
/// also means that width and normal interpolation should be restricted to
|
||||
/// varying (linear), uniform (per curve element), or constant (per prim).
|
||||
///
|
||||
///
|
||||
class UsdGeomHermiteCurves : public UsdGeomCurves
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomHermiteCurves on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomHermiteCurves::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomHermiteCurves(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomCurves(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomHermiteCurves on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomHermiteCurves(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomHermiteCurves(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomCurves(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomHermiteCurves();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomHermiteCurves holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomHermiteCurves(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomHermiteCurves
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomHermiteCurves
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TANGENTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Defines the outgoing trajectory tangent for each point.
|
||||
/// Tangents should be the same size as the points attribute.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `vector3f[] tangents = []` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3fArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTangentsAttr() const;
|
||||
|
||||
/// See GetTangentsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTangentsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Represents points and tangents of the same size.
|
||||
///
|
||||
/// Utility to interleave point and tangent data. This class is immutable.
|
||||
class PointAndTangentArrays {
|
||||
VtArray<GfVec3f> _points;
|
||||
VtArray<GfVec3f> _tangents;
|
||||
|
||||
explicit PointAndTangentArrays(const VtVec3fArray& interleaved);
|
||||
|
||||
public:
|
||||
|
||||
/// Construct empty points and tangents arrays
|
||||
PointAndTangentArrays() = default;
|
||||
PointAndTangentArrays(const PointAndTangentArrays&) = default;
|
||||
PointAndTangentArrays(PointAndTangentArrays&&) = default;
|
||||
PointAndTangentArrays& operator=(const PointAndTangentArrays&) =
|
||||
default;
|
||||
PointAndTangentArrays& operator=(PointAndTangentArrays&&) = default;
|
||||
|
||||
/// Initializes \p points and \p tangents if they are the same size.
|
||||
///
|
||||
/// If points and tangents are not the same size, an empty container
|
||||
/// is created.
|
||||
PointAndTangentArrays(const VtVec3fArray& points,
|
||||
const VtVec3fArray& tangents)
|
||||
: _points(points), _tangents(tangents) {
|
||||
if (_points.size() != _tangents.size()) {
|
||||
TF_RUNTIME_ERROR("Points and tangents must be the same size.");
|
||||
_points.clear();
|
||||
_tangents.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// Given an \p interleaved points and tangents arrays (P0, T0, ..., Pn,
|
||||
/// Tn), separates them into two arrays (P0, ..., PN) and (T0, ..., Tn).
|
||||
USDGEOM_API static PointAndTangentArrays Separate(const VtVec3fArray& interleaved) {
|
||||
return PointAndTangentArrays(interleaved);
|
||||
}
|
||||
|
||||
/// Interleaves points (P0, ..., Pn) and tangents (T0, ..., Tn) into
|
||||
/// one array (P0, T0, ..., Pn, Tn).
|
||||
USDGEOM_API VtVec3fArray Interleave() const;
|
||||
|
||||
/// Returns true if the containers are empty
|
||||
bool IsEmpty() const {
|
||||
// we only need to check the points, as we've verified on
|
||||
// construction that _points and _tangents have the same size
|
||||
return _points.empty();
|
||||
}
|
||||
|
||||
/// Returns true if there are values
|
||||
explicit operator bool() const { return !IsEmpty(); }
|
||||
|
||||
/// Get separated points array
|
||||
const VtVec3fArray& GetPoints() const { return _points; }
|
||||
|
||||
/// Get separated tangents array
|
||||
const VtVec3fArray& GetTangents() const { return _tangents; }
|
||||
|
||||
bool operator==(const PointAndTangentArrays& other) {
|
||||
return (GetPoints() == other.GetPoints()) &&
|
||||
(GetTangents() == other.GetTangents());
|
||||
}
|
||||
bool operator!=(const PointAndTangentArrays& other) {
|
||||
return !((*this) == other);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,636 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_IMAGEABLE_H
|
||||
#define USDGEOM_GENERATED_IMAGEABLE_H
|
||||
|
||||
/// \file usdGeom/imageable.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/typed.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/gf/bbox3d.h"
|
||||
#include "pxr/usd/usdGeom/primvar.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// IMAGEABLE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomImageable
|
||||
///
|
||||
/// Base class for all prims that may require rendering or
|
||||
/// visualization of some sort. The primary attributes of Imageable
|
||||
/// are \em visibility and \em purpose, which each provide instructions for
|
||||
/// what geometry should be included for processing by rendering and other
|
||||
/// computations.
|
||||
///
|
||||
/// \deprecated Imageable also provides API for accessing primvars, which
|
||||
/// has been moved to the UsdGeomPrimvarsAPI schema, because primvars can now
|
||||
/// be applied on non-Imageable prim types. This API is planned
|
||||
/// to be removed, UsdGeomPrimvarsAPI should be used directly instead.
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomImageable : public UsdTyped
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// Construct a UsdGeomImageable on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomImageable::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomImageable(const UsdPrim& prim=UsdPrim())
|
||||
: UsdTyped(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomImageable on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomImageable(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomImageable(const UsdSchemaBase& schemaObj)
|
||||
: UsdTyped(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomImageable();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomImageable holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomImageable(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomImageable
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VISIBILITY
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Visibility is meant to be the simplest form of "pruning"
|
||||
/// visibility that is supported by most DCC apps. Visibility is
|
||||
/// animatable, allowing a sub-tree of geometry to be present for some
|
||||
/// segment of a shot, and absent from others; unlike the action of
|
||||
/// deactivating geometry prims, invisible geometry is still
|
||||
/// available for inspection, for positioning, for defining volumes, etc.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `token visibility = "inherited"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | inherited, invisible |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVisibilityAttr() const;
|
||||
|
||||
/// See GetVisibilityAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVisibilityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// PURPOSE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Purpose is a classification of geometry into categories that
|
||||
/// can each be independently included or excluded from traversals of prims
|
||||
/// on a stage, such as rendering or bounding-box computation traversals.
|
||||
///
|
||||
/// See \ref UsdGeom_ImageablePurpose for more detail about how
|
||||
/// \em purpose is computed and used.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token purpose = "default"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | default, render, proxy, guide |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetPurposeAttr() const;
|
||||
|
||||
/// See GetPurposeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreatePurposeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// PROXYPRIM
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The \em proxyPrim relationship allows us to link a
|
||||
/// prim whose \em purpose is "render" to its (single target)
|
||||
/// purpose="proxy" prim. This is entirely optional, but can be
|
||||
/// useful in several scenarios:
|
||||
///
|
||||
/// \li In a pipeline that does pruning (for complexity management)
|
||||
/// by deactivating prims composed from asset references, when we
|
||||
/// deactivate a purpose="render" prim, we will be able to discover
|
||||
/// and additionally deactivate its associated purpose="proxy" prim,
|
||||
/// so that preview renders reflect the pruning accurately.
|
||||
///
|
||||
/// \li DCC importers may be able to make more aggressive optimizations
|
||||
/// for interactive processing and display if they can discover the proxy
|
||||
/// for a given render prim.
|
||||
///
|
||||
/// \li With a little more work, a Hydra-based application will be able
|
||||
/// to map a picked proxy prim back to its render geometry for selection.
|
||||
///
|
||||
/// \note It is only valid to author the proxyPrim relationship on
|
||||
/// prims whose purpose is "render".
|
||||
///
|
||||
USDGEOM_API
|
||||
UsdRelationship GetProxyPrimRel() const;
|
||||
|
||||
/// See GetProxyPrimRel(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create
|
||||
USDGEOM_API
|
||||
UsdRelationship CreateProxyPrimRel() const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
|
||||
// --------------------------------------------------------------------- //
|
||||
/// \name Primvar Creation and Introspection
|
||||
/// @{
|
||||
// --------------------------------------------------------------------- //
|
||||
|
||||
/// \deprecated Please use UsdGeomPrimvarsAPI::CreatePrimvar() instead.
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar CreatePrimvar(const TfToken& attrName,
|
||||
const SdfValueTypeName &typeName,
|
||||
const TfToken& interpolation = TfToken(),
|
||||
int elementSize = -1) const;
|
||||
|
||||
/// \deprecated Please use UsdGeomPrimvarsAPI::GetPrimvar() instead.
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar GetPrimvar(const TfToken &name) const;
|
||||
|
||||
/// \deprecated Please use UsdGeomPrimvarsAPI::GetPrimvars() instead.
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> GetPrimvars() const;
|
||||
|
||||
/// \deprecated Please use UsdGeomPrimvarsAPI::GetAuthoredPrimvars() instead.
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> GetAuthoredPrimvars() const;
|
||||
|
||||
/// \deprecated Please use UsdGeomPrimvarsAPI::HasPrimvar() instead.
|
||||
USDGEOM_API
|
||||
bool HasPrimvar(const TfToken &name) const;
|
||||
|
||||
|
||||
/// Returns an ordered list of allowed values of the purpose attribute.
|
||||
///
|
||||
/// The ordering is important because it defines the protocol between
|
||||
/// UsdGeomModelAPI and UsdGeomBBoxCache for caching and retrieving extents
|
||||
/// hints by purpose.
|
||||
///
|
||||
/// The order is: [default, render, proxy, guide]
|
||||
///
|
||||
/// See \sa UsdGeomModelAPI::GetExtentsHint().
|
||||
///
|
||||
/// \sa GetOrderedPurposeTokens()
|
||||
USDGEOM_API
|
||||
static const TfTokenVector &GetOrderedPurposeTokens();
|
||||
|
||||
// --------------------------------------------------------------------- //
|
||||
/// \name Visibility Authoring Helpers
|
||||
/// \anchor usdGeom_Visibility_Authoring_Helpers
|
||||
/// Convenience API for making an imageable visible or invisible.
|
||||
/// @{
|
||||
// --------------------------------------------------------------------- //
|
||||
|
||||
/// Make the imageable visible if it is invisible at the given time.
|
||||
///
|
||||
/// Since visibility is pruning, this may need to override some
|
||||
/// ancestor's visibility and all-but-one of the ancestor's children's
|
||||
/// visibility, for all the ancestors of this prim up to the highest
|
||||
/// ancestor that is explicitly invisible, to preserve the visibility state.
|
||||
///
|
||||
/// If MakeVisible() (or MakeInvisible()) is going to be applied to all
|
||||
/// the prims on a stage, ancestors must be processed prior to descendants
|
||||
/// to get the correct behavior.
|
||||
///
|
||||
/// \note When visibility is animated, this only works when it is
|
||||
/// invoked sequentially at increasing time samples. If visibility is
|
||||
/// already authored and animated in the scene, calling MakeVisible() at
|
||||
/// an arbitrary (in-between) frame isn't guaranteed to work.
|
||||
///
|
||||
/// \note This will only work properly if all ancestor prims of the
|
||||
/// imageable are <b>defined</b>, as the imageable schema is only valid on
|
||||
/// defined prims.
|
||||
///
|
||||
/// \note Be sure to set the edit target to the layer containing the
|
||||
/// strongest visibility opinion or to a stronger layer.
|
||||
///
|
||||
/// \sa MakeInvisible()
|
||||
/// \sa ComputeVisibility()
|
||||
///
|
||||
USDGEOM_API
|
||||
void MakeVisible(const UsdTimeCode &time=UsdTimeCode::Default()) const;
|
||||
|
||||
/// Makes the imageable invisible if it is visible at the given time.
|
||||
///
|
||||
/// \note When visibility is animated, this only works when it is
|
||||
/// invoked sequentially at increasing time samples. If visibility is
|
||||
/// already authored and animated in the scene, calling MakeVisible() at
|
||||
/// an arbitrary (in-between) frame isn't guaranteed to work.
|
||||
///
|
||||
/// \note Be sure to set the edit target to the layer containing the
|
||||
/// strongest visibility opinion or to a stronger layer.
|
||||
///
|
||||
/// \sa MakeVisible()
|
||||
/// \sa ComputeVisibility()
|
||||
///
|
||||
USDGEOM_API
|
||||
void MakeInvisible(const UsdTimeCode &time=UsdTimeCode::Default()) const;
|
||||
|
||||
///@}
|
||||
|
||||
// --------------------------------------------------------------------- //
|
||||
/// \name Computed Attribute Helpers
|
||||
/// \anchor usdGeom_Computed_Attribute_Helpers
|
||||
/// Visbility, Purpose, Bounds (World, Local, and Untransformed), and
|
||||
/// Transform (LocalToWorld and ParentToWorld) are all qualities of a
|
||||
/// prim's location in namespace that require non-local data and
|
||||
/// computation. Computing these efficiently requires a stage-level
|
||||
/// cache, but when performance is not a concern, it is convenient to
|
||||
/// query these quantities directly on a prim, so we provide convenience
|
||||
/// API here for doing so.
|
||||
/// @{
|
||||
// --------------------------------------------------------------------- //
|
||||
|
||||
/// Calculate the effective visibility of this prim, as defined by its
|
||||
/// most ancestral authored "invisible" opinion, if any.
|
||||
///
|
||||
/// A prim is considered visible at the current \p time if none of its
|
||||
/// Imageable ancestors express an authored "invisible" opinion, which is
|
||||
/// what leads to the "simple pruning" behavior described in
|
||||
/// GetVisibilityAttr().
|
||||
///
|
||||
/// This function should be considered a reference implementation for
|
||||
/// correctness. <b>If called on each prim in the context of a traversal
|
||||
/// we will perform massive overcomputation, because sibling prims share
|
||||
/// sub-problems in the query that can be efficiently cached, but are not
|
||||
/// (cannot be) by this simple implementation.</b> If you have control of
|
||||
/// your traversal, it will be far more efficient to manage visibility
|
||||
/// on a stack as you traverse.
|
||||
///
|
||||
/// \sa GetVisibilityAttr()
|
||||
USDGEOM_API
|
||||
TfToken ComputeVisibility(UsdTimeCode const &time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// Return the attribute that is used for expressing visibility opinions
|
||||
/// for the given \p purpose.
|
||||
///
|
||||
/// For "default" purpose, return the overall *visibility* attribute.
|
||||
/// Otherwise, return *guideVisibility*, *proxyVisibility*, or
|
||||
/// *renderVisibility*.
|
||||
///
|
||||
/// \sa UsdGeomVisibilityAPI
|
||||
USDGEOM_API
|
||||
UsdAttribute GetPurposeVisibilityAttr(
|
||||
const TfToken &purpose = UsdGeomTokens->default_) const;
|
||||
|
||||
/// Calculate the effective purpose visibility of this prim for the
|
||||
/// given \p purpose, taking into account opinions for the corresponding
|
||||
/// purpose attribute, along with overall visibility opinions.
|
||||
///
|
||||
/// If ComputeVisibility() returns "invisible", then
|
||||
/// ComputeEffectiveVisibility() is "invisible" for all purpose
|
||||
/// values. Otherwise, ComputeEffectiveVisibility() returns the value of
|
||||
/// the nearest ancestral authored opinion for the corresponding purpose
|
||||
/// visibility attribute, as retured by
|
||||
/// GetPurposeVisibilityAttr(purpose).
|
||||
///
|
||||
/// Note that the value returned here can be "invisible" (indicating the
|
||||
/// prim is invisible for the given purpose), "visible" (indicating that
|
||||
/// it's visible), or "inherited" (indicating that the purpose visibility
|
||||
/// is context-dependent and the fallback behavior must be determined by
|
||||
/// the caller.
|
||||
///
|
||||
/// This function should be considered a reference implementation for
|
||||
/// correctness. <b>If called on each prim in the context of a traversal
|
||||
/// we will perform massive overcomputation, because sibling prims share
|
||||
/// sub-problems in the query that can be efficiently cached, but are not
|
||||
/// (cannot be) by this simple implementation.</b> If you have control of
|
||||
/// your traversal, it will be far more efficient to manage visibility
|
||||
/// on a stack as you traverse.
|
||||
///
|
||||
/// \sa UsdGeomVisibilityAPI
|
||||
/// \sa GetPurposeVisibilityAttr()
|
||||
/// \sa ComputeVisibility()
|
||||
USDGEOM_API
|
||||
TfToken ComputeEffectiveVisibility(
|
||||
const TfToken &purpose = UsdGeomTokens->default_,
|
||||
const UsdTimeCode &time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// Value type containing information about a prim's computed effective
|
||||
/// purpose as well as storing whether the prim's purpose value can be
|
||||
/// inherited by namespace children if necessary. This provides the purpose
|
||||
/// information necessary for efficiently computing and caching the purposes
|
||||
/// of a hierarchy of prims.
|
||||
/// \sa GetPurposeAttr(), \ref UsdGeom_ImageablePurpose
|
||||
struct PurposeInfo {
|
||||
constexpr PurposeInfo() = default;
|
||||
|
||||
PurposeInfo(const TfToken &purpose_, bool isInheritable_) :
|
||||
purpose(purpose_), isInheritable(isInheritable_) {}
|
||||
|
||||
/// The computed purpose. An empty purpose indicates that this
|
||||
/// represents a purpose that hasn't been computed yet.
|
||||
TfToken purpose;
|
||||
|
||||
/// Whether this purpose should be inherited by namespace children
|
||||
/// that do not have their own authored purpose value.
|
||||
bool isInheritable = false;
|
||||
|
||||
/// Returns true if this represents a purpose that has been computed.
|
||||
explicit operator bool() const { return !purpose.IsEmpty(); }
|
||||
|
||||
bool operator==(const PurposeInfo &rhs) {
|
||||
return purpose == rhs.purpose && isInheritable == rhs.isInheritable;
|
||||
}
|
||||
|
||||
bool operator!=(const PurposeInfo &rhs) {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
/// Returns the purpose if it's inheritable, returns empty if it is not.
|
||||
const TfToken &GetInheritablePurpose() const {
|
||||
static const TfToken empty;
|
||||
return isInheritable ? purpose : empty;
|
||||
}
|
||||
};
|
||||
|
||||
/// Calculate the effective purpose information about this prim which
|
||||
/// includes final computed purpose value of the prim as well as whether
|
||||
/// the purpose value should be inherited by namespace children without
|
||||
/// their own purpose opinions.
|
||||
///
|
||||
/// This function should be considered a reference implementation for
|
||||
/// correctness. <b>If called on each prim in the context of a traversal
|
||||
/// we will perform massive overcomputation, because sibling prims share
|
||||
/// sub-problems in the query that can be efficiently cached, but are not
|
||||
/// (cannot be) by this simple implementation.</b> If you have control of
|
||||
/// your traversal, it will be far more efficient to manage purpose, along
|
||||
/// with visibility, on a stack as you traverse.
|
||||
///
|
||||
/// \sa GetPurposeAttr(), \ref UsdGeom_ImageablePurpose
|
||||
USDGEOM_API
|
||||
PurposeInfo ComputePurposeInfo() const;
|
||||
|
||||
/// \overload
|
||||
/// Calculates the effective purpose information about this prim, given the
|
||||
/// computed purpose information of its parent prim. This can be much more
|
||||
/// efficient than using CommputePurposeInfo() when PurposeInfo values are
|
||||
/// properly computed and cached for a hierarchy of prims using this
|
||||
/// function.
|
||||
///
|
||||
/// \sa GetPurposeAttr(), \ref UsdGeom_ImageablePurpose
|
||||
USDGEOM_API
|
||||
PurposeInfo ComputePurposeInfo(const PurposeInfo &parentPurposeInfo) const;
|
||||
|
||||
/// Calculate the effective purpose information about this prim. This is
|
||||
/// equivalent to extracting the purpose from the value returned by
|
||||
/// ComputePurposeInfo().
|
||||
///
|
||||
/// This function should be considered a reference implementation for
|
||||
/// correctness. <b>If called on each prim in the context of a traversal
|
||||
/// we will perform massive overcomputation, because sibling prims share
|
||||
/// sub-problems in the query that can be efficiently cached, but are not
|
||||
/// (cannot be) by this simple implementation.</b> If you have control of
|
||||
/// your traversal, it will be far more efficient to manage purpose, along
|
||||
/// with visibility, on a stack as you traverse.
|
||||
///
|
||||
/// \sa GetPurposeAttr(), \ref UsdGeom_ImageablePurpose
|
||||
USDGEOM_API
|
||||
TfToken ComputePurpose() const;
|
||||
|
||||
/// Find the prim whose purpose is \em proxy that serves as the proxy
|
||||
/// for this prim, as established by the GetProxyPrimRel(), or an
|
||||
/// invalid UsdPrim if this prim has no proxy.
|
||||
///
|
||||
/// This method will find the proxy for \em any prim whose computed
|
||||
/// purpose (see ComputePurpose()) is \em render. If provided and a proxy
|
||||
/// was found, we will set *renderPrim to the root of the \em render
|
||||
/// subtree upon which the renderProxy relationship was authored.
|
||||
///
|
||||
/// If the renderProxy relationship has more than one target, we will
|
||||
/// issue a warning and return an invalid UsdPrim. If the targeted prim
|
||||
/// does not have a resolved purpose of \em proxy, we will warn and
|
||||
/// return an invalid prim.
|
||||
///
|
||||
/// This function should be considered a reference implementation for
|
||||
/// correctness. <b>If called on each prim in the context of a traversal
|
||||
/// we will perform massive overcomputation, because sibling prims share
|
||||
/// sub-problems in the query that can be efficiently cached, but are not
|
||||
/// (cannot be) by this simple implementation.</b> If you have control of
|
||||
/// your traversal, it will be far more efficient to compute proxy-prims
|
||||
/// on a stack as you traverse.
|
||||
///
|
||||
/// \note Currently the returned prim will not contain any instancing
|
||||
/// context if it is inside a prototype - its path will be relative to the
|
||||
/// prototype's root. Once UsdPrim is instancing-aware in the core, we can
|
||||
/// change this method to return a context-aware result.
|
||||
///
|
||||
/// \sa SetProxyPrim(), GetProxyPrimRel()
|
||||
USDGEOM_API
|
||||
UsdPrim ComputeProxyPrim(UsdPrim *renderPrim=NULL) const;
|
||||
|
||||
/// Convenience function for authoring the \em renderProxy rel on this
|
||||
/// prim to target the given \p proxy prim.
|
||||
///
|
||||
/// To facilitate authoring on sparse or unloaded stages, we do not
|
||||
/// perform any validation of this prim's purpose or the type or
|
||||
/// purpose of the specified prim.
|
||||
///
|
||||
/// \sa ComputeProxyPrim(), GetProxyPrimRel()
|
||||
USDGEOM_API
|
||||
bool SetProxyPrim(const UsdPrim &proxy) const;
|
||||
|
||||
/// \overload that takes any UsdSchemaBase-derived object
|
||||
USDGEOM_API
|
||||
bool SetProxyPrim(const UsdSchemaBase &proxy) const;
|
||||
|
||||
/// Compute the bound of this prim in world space, at the specified
|
||||
/// \p time, and for the specified purposes.
|
||||
///
|
||||
/// The bound of the prim is computed, including the transform (if any)
|
||||
/// authored on the node itself, and then transformed to world space.
|
||||
///
|
||||
/// It is an error to not specify any purposes, which will result in the
|
||||
/// return of an empty box.
|
||||
///
|
||||
/// <b>If you need to compute bounds for multiple prims on a stage, it
|
||||
/// will be much, much more efficient to instantiate a UsdGeomBBoxCache
|
||||
/// and query it directly; doing so will reuse sub-computations shared
|
||||
/// by the prims.</b>
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeWorldBound(UsdTimeCode const& time,
|
||||
TfToken const &purpose1=TfToken(),
|
||||
TfToken const &purpose2=TfToken(),
|
||||
TfToken const &purpose3=TfToken(),
|
||||
TfToken const &purpose4=TfToken()) const;
|
||||
|
||||
|
||||
/// Compute the bound of this prim in local space, at the specified
|
||||
/// \p time, and for the specified purposes.
|
||||
///
|
||||
/// The bound of the prim is computed, including the transform (if any)
|
||||
/// authored on the node itself.
|
||||
///
|
||||
/// It is an error to not specify any purposes, which will result in the
|
||||
/// return of an empty box.
|
||||
///
|
||||
/// <b>If you need to compute bounds for multiple prims on a stage, it
|
||||
/// will be much, much more efficient to instantiate a UsdGeomBBoxCache
|
||||
/// and query it directly; doing so will reuse sub-computations shared
|
||||
/// by the prims.</b>
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeLocalBound(UsdTimeCode const& time,
|
||||
TfToken const &purpose1=TfToken(),
|
||||
TfToken const &purpose2=TfToken(),
|
||||
TfToken const &purpose3=TfToken(),
|
||||
TfToken const &purpose4=TfToken()) const;
|
||||
|
||||
/// Compute the untransformed bound of this prim, at the specified
|
||||
/// \p time, and for the specified purposes.
|
||||
///
|
||||
/// The bound of the prim is computed in its object space, ignoring
|
||||
/// any transforms authored on or above the prim.
|
||||
///
|
||||
/// It is an error to not specify any purposes, which will result in the
|
||||
/// return of an empty box.
|
||||
///
|
||||
/// <b>If you need to compute bounds for multiple prims on a stage, it
|
||||
/// will be much, much more efficient to instantiate a UsdGeomBBoxCache
|
||||
/// and query it directly; doing so will reuse sub-computations shared
|
||||
/// by the prims.</b>
|
||||
USDGEOM_API
|
||||
GfBBox3d ComputeUntransformedBound(UsdTimeCode const& time,
|
||||
TfToken const &purpose1=TfToken(),
|
||||
TfToken const &purpose2=TfToken(),
|
||||
TfToken const &purpose3=TfToken(),
|
||||
TfToken const &purpose4=TfToken()) const;
|
||||
|
||||
/// Compute the transformation matrix for this prim at the given time,
|
||||
/// including the transform authored on the Prim itself, if present.
|
||||
///
|
||||
/// <b>If you need to compute the transform for multiple prims on a
|
||||
/// stage, it will be much, much more efficient to instantiate a
|
||||
/// UsdGeomXformCache and query it directly; doing so will reuse
|
||||
/// sub-computations shared by the prims.</b>
|
||||
USDGEOM_API
|
||||
GfMatrix4d ComputeLocalToWorldTransform(UsdTimeCode const &time) const;
|
||||
|
||||
/// Compute the transformation matrix for this prim at the given time,
|
||||
/// \em NOT including the transform authored on the prim itself.
|
||||
///
|
||||
/// <b>If you need to compute the transform for multiple prims on a
|
||||
/// stage, it will be much, much more efficient to instantiate a
|
||||
/// UsdGeomXformCache and query it directly; doing so will reuse
|
||||
/// sub-computations shared by the prims.</b>
|
||||
USDGEOM_API
|
||||
GfMatrix4d ComputeParentToWorldTransform(UsdTimeCode const &time) const;
|
||||
|
||||
/// @}
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,633 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_MESH_H
|
||||
#define USDGEOM_GENERATED_MESH_H
|
||||
|
||||
/// \file usdGeom/mesh.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/pointBased.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/usd/usd/timeCode.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// MESH //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomMesh
|
||||
///
|
||||
/// Encodes a mesh with optional subdivision properties and features.
|
||||
///
|
||||
/// As a point-based primitive, meshes are defined in terms of points that
|
||||
/// are connected into edges and faces. Many references to meshes use the
|
||||
/// term 'vertex' in place of or interchangeably with 'points', while some
|
||||
/// use 'vertex' to refer to the 'face-vertices' that define a face. To
|
||||
/// avoid confusion, the term 'vertex' is intentionally avoided in favor of
|
||||
/// 'points' or 'face-vertices'.
|
||||
///
|
||||
/// The connectivity between points, edges and faces is encoded using a
|
||||
/// common minimal topological description of the faces of the mesh. Each
|
||||
/// face is defined by a set of face-vertices using indices into the Mesh's
|
||||
/// _points_ array (inherited from UsdGeomPointBased) and laid out in a
|
||||
/// single linear _faceVertexIndices_ array for efficiency. A companion
|
||||
/// _faceVertexCounts_ array provides, for each face, the number of
|
||||
/// consecutive face-vertices in _faceVertexIndices_ that define the face.
|
||||
/// No additional connectivity information is required or constructed, so
|
||||
/// no adjacency or neighborhood queries are available.
|
||||
///
|
||||
/// A key property of this mesh schema is that it encodes both subdivision
|
||||
/// surfaces and simpler polygonal meshes. This is achieved by varying the
|
||||
/// _subdivisionScheme_ attribute, which is set to specify Catmull-Clark
|
||||
/// subdivision by default, so polygonal meshes must always be explicitly
|
||||
/// declared. The available subdivision schemes and additional subdivision
|
||||
/// features encoded in optional attributes conform to the feature set of
|
||||
/// OpenSubdiv
|
||||
/// (https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html).
|
||||
///
|
||||
/// \anchor UsdGeom_Mesh_Primvars
|
||||
/// __A Note About Primvars__
|
||||
///
|
||||
/// The following list clarifies the number of elements for and the
|
||||
/// interpolation behavior of the different primvar interpolation types
|
||||
/// for meshes:
|
||||
///
|
||||
/// - __constant__: One element for the entire mesh; no interpolation.
|
||||
/// - __uniform__: One element for each face of the mesh; elements are
|
||||
/// typically not interpolated but are inherited by other faces derived
|
||||
/// from a given face (via subdivision, tessellation, etc.).
|
||||
/// - __varying__: One element for each point of the mesh;
|
||||
/// interpolation of point data is always linear.
|
||||
/// - __vertex__: One element for each point of the mesh;
|
||||
/// interpolation of point data is applied according to the
|
||||
/// _subdivisionScheme_ attribute.
|
||||
/// - __faceVarying__: One element for each of the face-vertices that
|
||||
/// define the mesh topology; interpolation of face-vertex data may
|
||||
/// be smooth or linear, according to the _subdivisionScheme_ and
|
||||
/// _faceVaryingLinearInterpolation_ attributes.
|
||||
///
|
||||
/// Primvar interpolation types and related utilities are described more
|
||||
/// generally in \ref Usd_InterpolationVals.
|
||||
///
|
||||
/// \anchor UsdGeom_Mesh_Normals
|
||||
/// __A Note About Normals__
|
||||
///
|
||||
/// Normals should not be authored on a subdivision mesh, since subdivision
|
||||
/// algorithms define their own normals. They should only be authored for
|
||||
/// polygonal meshes (_subdivisionScheme_ = "none").
|
||||
///
|
||||
/// The _normals_ attribute inherited from UsdGeomPointBased is not a generic
|
||||
/// primvar, but the number of elements in this attribute will be determined by
|
||||
/// its _interpolation_. See \ref UsdGeomPointBased::GetNormalsInterpolation() .
|
||||
/// If _normals_ and _primvars:normals_ are both specified, the latter has
|
||||
/// precedence. If a polygonal mesh specifies __neither__ _normals_ nor
|
||||
/// _primvars:normals_, then it should be treated and rendered as faceted,
|
||||
/// with no attempt to compute smooth normals.
|
||||
///
|
||||
/// The normals generated for smooth subdivision schemes, e.g. Catmull-Clark
|
||||
/// and Loop, will likewise be smooth, but others, e.g. Bilinear, may be
|
||||
/// discontinuous between faces and/or within non-planar irregular faces.
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomMesh : public UsdGeomPointBased
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomMesh on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomMesh::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomMesh(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomPointBased(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomMesh on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomMesh(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomMesh(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomPointBased(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomMesh();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomMesh holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomMesh(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomMesh
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomMesh
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// FACEVERTEXINDICES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Flat list of the index (into the _points_ attribute) of each
|
||||
/// vertex of each face in the mesh. If this attribute has more than
|
||||
/// one timeSample, the mesh is considered to be topologically varying.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] faceVertexIndices` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetFaceVertexIndicesAttr() const;
|
||||
|
||||
/// See GetFaceVertexIndicesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateFaceVertexIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// FACEVERTEXCOUNTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Provides the number of vertices in each face of the mesh,
|
||||
/// which is also the number of consecutive indices in _faceVertexIndices_
|
||||
/// that define the face. The length of this attribute is the number of
|
||||
/// faces in the mesh. If this attribute has more than
|
||||
/// one timeSample, the mesh is considered to be topologically varying.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] faceVertexCounts` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetFaceVertexCountsAttr() const;
|
||||
|
||||
/// See GetFaceVertexCountsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateFaceVertexCountsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// SUBDIVISIONSCHEME
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The subdivision scheme to be applied to the surface.
|
||||
/// Valid values are:
|
||||
///
|
||||
/// - __catmullClark__: The default, Catmull-Clark subdivision; preferred
|
||||
/// for quad-dominant meshes (generalizes B-splines); interpolation
|
||||
/// of point data is smooth (non-linear)
|
||||
/// - __loop__: Loop subdivision; preferred for purely triangular meshes;
|
||||
/// interpolation of point data is smooth (non-linear)
|
||||
/// - __bilinear__: Subdivision reduces all faces to quads (topologically
|
||||
/// similar to "catmullClark"); interpolation of point data is bilinear
|
||||
/// - __none__: No subdivision, i.e. a simple polygonal mesh; interpolation
|
||||
/// of point data is linear
|
||||
///
|
||||
/// Polygonal meshes are typically lighter weight and faster to render,
|
||||
/// depending on renderer and render mode. Use of "bilinear" will produce
|
||||
/// a similar shape to a polygonal mesh and may offer additional guarantees
|
||||
/// of watertightness and additional subdivision features (e.g. holes) but
|
||||
/// may also not respect authored normals.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token subdivisionScheme = "catmullClark"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | catmullClark, loop, bilinear, none |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetSubdivisionSchemeAttr() const;
|
||||
|
||||
/// See GetSubdivisionSchemeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateSubdivisionSchemeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// INTERPOLATEBOUNDARY
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Specifies how subdivision is applied for faces adjacent to
|
||||
/// boundary edges and boundary points. Valid values correspond to choices
|
||||
/// available in OpenSubdiv:
|
||||
///
|
||||
/// - __none__: No boundary interpolation is applied and boundary faces are
|
||||
/// effectively treated as holes
|
||||
/// - __edgeOnly__: A sequence of boundary edges defines a smooth curve to
|
||||
/// which the edges of subdivided boundary faces converge
|
||||
/// - __edgeAndCorner__: The default, similar to "edgeOnly" but the smooth
|
||||
/// boundary curve is made sharp at corner points
|
||||
///
|
||||
/// These are illustrated and described in more detail in the OpenSubdiv
|
||||
/// documentation:
|
||||
/// https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#boundary-interpolation-rules
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `token interpolateBoundary = "edgeAndCorner"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | none, edgeOnly, edgeAndCorner |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetInterpolateBoundaryAttr() const;
|
||||
|
||||
/// See GetInterpolateBoundaryAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateInterpolateBoundaryAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// FACEVARYINGLINEARINTERPOLATION
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Specifies how elements of a primvar of interpolation type
|
||||
/// "faceVarying" are interpolated for subdivision surfaces. Interpolation
|
||||
/// can be as smooth as a "vertex" primvar or constrained to be linear at
|
||||
/// features specified by several options. Valid values correspond to
|
||||
/// choices available in OpenSubdiv:
|
||||
///
|
||||
/// - __none__: No linear constraints or sharpening, smooth everywhere
|
||||
/// - __cornersOnly__: Sharpen corners of discontinuous boundaries only,
|
||||
/// smooth everywhere else
|
||||
/// - __cornersPlus1__: The default, same as "cornersOnly" plus additional
|
||||
/// sharpening at points where three or more distinct face-varying
|
||||
/// values occur
|
||||
/// - __cornersPlus2__: Same as "cornersPlus1" plus additional sharpening
|
||||
/// at points with at least one discontinuous boundary corner or
|
||||
/// only one discontinuous boundary edge (a dart)
|
||||
/// - __boundaries__: Piecewise linear along discontinuous boundaries,
|
||||
/// smooth interior
|
||||
/// - __all__: Piecewise linear everywhere
|
||||
///
|
||||
/// These are illustrated and described in more detail in the OpenSubdiv
|
||||
/// documentation:
|
||||
/// https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#face-varying-interpolation-rules
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `token faceVaryingLinearInterpolation = "cornersPlus1"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | none, cornersOnly, cornersPlus1, cornersPlus2, boundaries, all |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetFaceVaryingLinearInterpolationAttr() const;
|
||||
|
||||
/// See GetFaceVaryingLinearInterpolationAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateFaceVaryingLinearInterpolationAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TRIANGLESUBDIVISIONRULE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Specifies an option to the subdivision rules for the
|
||||
/// Catmull-Clark scheme to try and improve undesirable artifacts when
|
||||
/// subdividing triangles. Valid values are "catmullClark" for the
|
||||
/// standard rules (the default) and "smooth" for the improvement.
|
||||
///
|
||||
/// See https://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#triangle-subdivision-rule
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `token triangleSubdivisionRule = "catmullClark"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | catmullClark, smooth |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTriangleSubdivisionRuleAttr() const;
|
||||
|
||||
/// See GetTriangleSubdivisionRuleAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTriangleSubdivisionRuleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// HOLEINDICES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The indices of all faces that should be treated as holes,
|
||||
/// i.e. made invisible. This is traditionally a feature of subdivision
|
||||
/// surfaces and not generally applied to polygonal meshes.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] holeIndices = []` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetHoleIndicesAttr() const;
|
||||
|
||||
/// See GetHoleIndicesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateHoleIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CORNERINDICES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The indices of points for which a corresponding sharpness
|
||||
/// value is specified in _cornerSharpnesses_ (so the size of this array
|
||||
/// must match that of _cornerSharpnesses_).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] cornerIndices = []` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetCornerIndicesAttr() const;
|
||||
|
||||
/// See GetCornerIndicesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateCornerIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CORNERSHARPNESSES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The sharpness values associated with a corresponding set of
|
||||
/// points specified in _cornerIndices_ (so the size of this array must
|
||||
/// match that of _cornerIndices_). Use the constant `SHARPNESS_INFINITE`
|
||||
/// for a perfectly sharp corner.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float[] cornerSharpnesses = []` |
|
||||
/// | C++ Type | VtArray<float> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetCornerSharpnessesAttr() const;
|
||||
|
||||
/// See GetCornerSharpnessesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateCornerSharpnessesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CREASEINDICES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The indices of points grouped into sets of successive pairs
|
||||
/// that identify edges to be creased. The size of this array must be
|
||||
/// equal to the sum of all elements of the _creaseLengths_ attribute.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] creaseIndices = []` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetCreaseIndicesAttr() const;
|
||||
|
||||
/// See GetCreaseIndicesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateCreaseIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CREASELENGTHS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The length of this array specifies the number of creases
|
||||
/// (sets of adjacent sharpened edges) on the mesh. Each element gives
|
||||
/// the number of points of each crease, whose indices are successively
|
||||
/// laid out in the _creaseIndices_ attribute. Since each crease must
|
||||
/// be at least one edge long, each element of this array must be at
|
||||
/// least two.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] creaseLengths = []` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetCreaseLengthsAttr() const;
|
||||
|
||||
/// See GetCreaseLengthsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateCreaseLengthsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// CREASESHARPNESSES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The per-crease or per-edge sharpness values for all creases.
|
||||
/// Since _creaseLengths_ encodes the number of points in each crease,
|
||||
/// the number of elements in this array will be either len(creaseLengths)
|
||||
/// or the sum over all X of (creaseLengths[X] - 1). Note that while
|
||||
/// the RI spec allows each crease to have either a single sharpness
|
||||
/// or a value per-edge, USD will encode either a single sharpness
|
||||
/// per crease on a mesh, or sharpnesses for all edges making up
|
||||
/// the creases on a mesh. Use the constant `SHARPNESS_INFINITE` for a
|
||||
/// perfectly sharp crease.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float[] creaseSharpnesses = []` |
|
||||
/// | C++ Type | VtArray<float> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetCreaseSharpnessesAttr() const;
|
||||
|
||||
/// See GetCreaseSharpnessesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateCreaseSharpnessesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Validate the topology of a mesh.
|
||||
/// This validates that the sum of \p faceVertexCounts is equal to the size
|
||||
/// of the \p faceVertexIndices array, and that all face vertex indices in
|
||||
/// the \p faceVertexIndices array are in the range [0, numPoints).
|
||||
/// Returns true if the topology is valid, or false otherwise.
|
||||
/// If the topology is invalid and \p reason is non-null, an error message
|
||||
/// describing the validation error will be set.
|
||||
USDGEOM_API
|
||||
static bool ValidateTopology(const VtIntArray& faceVertexIndices,
|
||||
const VtIntArray& faceVertexCounts,
|
||||
size_t numPoints,
|
||||
std::string* reason=nullptr);
|
||||
|
||||
public:
|
||||
|
||||
/// Returns whether or not \p sharpness is considered infinite.
|
||||
///
|
||||
/// The \p sharpness value is usually intended for 'creaseSharpness' or
|
||||
/// 'cornerSharpness' arrays and a return value of \c true indicates that
|
||||
/// the crease or corner is perfectly sharp.
|
||||
USDGEOM_API
|
||||
static bool IsSharpnessInfinite(const float sharpness);
|
||||
|
||||
/// \var const float SHARPNESS_INFINITE
|
||||
/// As an element of a 'creaseSharpness' or 'cornerSharpness' array,
|
||||
/// indicates that the crease or corner is perfectly sharp.
|
||||
USDGEOM_API
|
||||
static const float SHARPNESS_INFINITE;
|
||||
|
||||
/// Returns the number of faces as defined by the size of the
|
||||
/// _faceVertexCounts_ array at _timeCode_.
|
||||
///
|
||||
/// \snippetdoc snippets.dox GetCount
|
||||
/// \sa GetFaceVertexCountsAttr()
|
||||
USDGEOM_API
|
||||
size_t GetFaceCount(UsdTimeCode timeCode = UsdTimeCode::Default()) const;
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,219 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_METRICS_H
|
||||
#define PXR_USD_USD_GEOM_METRICS_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/usd/usd/common.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
/// \file usdGeom/metrics.h
|
||||
///
|
||||
/// Schema and utilities for encoding various spatial and geometric metrics of
|
||||
/// a UsdStage and its contents.
|
||||
///
|
||||
/// \defgroup UsdGeomUpAxis_group Encoding Stage UpAxis
|
||||
///
|
||||
/// Even if all UsdGeomCamera objects in a scene are encoded with a
|
||||
/// transformation that assumes the Y axis is up, that cannot always imply
|
||||
/// that the geometry contained in the scene was modeled with the Y axis
|
||||
/// pointing up, since some modeling applications assume Z is up, and others
|
||||
/// allow you to configure whether Y or Z is up. Rather than impose one axis
|
||||
/// or the other on all UsdGeom scenes - which would require either
|
||||
/// transposing point coordinates into and out of some applications, or making
|
||||
/// assumptions about where a -90 degree rotation has been applied and
|
||||
/// effectively, mysteriously swapping the roles of Y and Z coordinates -
|
||||
/// we allow each stage to carry, in its root layer, a declaration of the
|
||||
/// up axis for all the geometry contained in the stage, and require
|
||||
/// applications to consult it if they wish to create new cameras to view
|
||||
/// the scene in its intended orientation.
|
||||
///
|
||||
/// Note that because you can make only a Stage-level declaration of up axis,
|
||||
/// it must hold true for all referenced geometry and assets. A conscientious
|
||||
/// set/environment-construction tool could examine the up axis of referenced
|
||||
/// assets as they are being referenced, and apply a corrective rotation
|
||||
/// on the referencing prim as it is being added to the scene, when the
|
||||
/// referenced up axis differs from the set's.
|
||||
///
|
||||
/// We provide free functions for setting (UsdGeomSetStageUpAxis()),
|
||||
/// retrieving (UsdGeomGetStageUpAxis()), and declaring a site-level
|
||||
/// fallback up axis (UsdGeomGetFallbackUpAxis()) that can be configured
|
||||
/// with a PlugPlugin plugInfo.json file. See the individual methods for
|
||||
/// details.
|
||||
///
|
||||
/// The stage up axis is encoded as stage metadatum \em upAxis, whose legal
|
||||
/// values are "Y" and "Z", as represented by UsdGeomTokens->y and
|
||||
/// UsdGeomTokens->z. Of course, constructing a correct camera view of a
|
||||
/// scene depends not only on the up axis, but also on the handedness of the
|
||||
/// coordinate system. Like OpenGL and the fallback for
|
||||
/// UsdGeomGprim::GetOrientationAttr(), <b>UsdGeom stipulates a right-handed
|
||||
/// coordinate system.</b> Therefore, when viewing a UsdStage with a "Y" up
|
||||
/// axis, the stage's Z axis will be pointing out of the screen, and when
|
||||
/// viewing a UsdStage with a "Z" up axis, the stage's Y axis will be
|
||||
/// pointing into the screen.
|
||||
///
|
||||
/// @{
|
||||
|
||||
/// Fetch and return \p stage 's upAxis. If unauthored, will return the
|
||||
/// value provided by UsdGeomGetFallbackUpAxis(). Exporters, however, are
|
||||
/// strongly encouraged to always set the upAxis for every USD file they create.
|
||||
///
|
||||
/// \return one of: UsdGeomTokens->y or UsdGeomTokens->z, unless there was
|
||||
/// an error, in which case returns an empty TfToken
|
||||
///
|
||||
/// \sa UsdGeomUpAxis_group
|
||||
USDGEOM_API
|
||||
TfToken UsdGeomGetStageUpAxis(const UsdStageWeakPtr &stage);
|
||||
|
||||
/// Set \p stage 's upAxis to \p axis, which must be one of UsdGeomTokens->y
|
||||
/// or UsdGeomTokens->z
|
||||
///
|
||||
/// UpAxis is stage-level metadata, therefore see UsdStage::SetMetadata().
|
||||
///
|
||||
/// \return true if upAxis was successfully set. The stage's UsdEditTarget
|
||||
/// must be either its root layer or session layer.
|
||||
/// \sa UsdGeomUpAxis_group
|
||||
USDGEOM_API
|
||||
bool UsdGeomSetStageUpAxis(const UsdStageWeakPtr &stage, const TfToken &axis);
|
||||
|
||||
/// Return the site-level fallback up axis as a TfToken.
|
||||
///
|
||||
/// In a generic installation of USD, the fallback will be "Y". This can be
|
||||
/// changed to "Z" by adding, in a plugInfo.json file discoverable by USD's
|
||||
/// PlugPlugin mechanism:
|
||||
/// \code{json}
|
||||
/// "UsdGeomMetrics": {
|
||||
/// "upAxis": "Z"
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// If more than one such entry is discovered and the values for upAxis differ,
|
||||
/// we will issue a warning during the first call to this function, and ignore
|
||||
/// all of them, so that we devolve to deterministic behavior of Y up axis
|
||||
/// until the problem is rectified.
|
||||
USDGEOM_API
|
||||
TfToken UsdGeomGetFallbackUpAxis();
|
||||
|
||||
/// @}
|
||||
|
||||
/// \defgroup UsdGeomLinearUnits_group Encoding Stage Linear Units
|
||||
///
|
||||
/// As with \ref UsdGeomUpAxis_group, we restrict the encoding of linear
|
||||
/// units to be stage-wide; if assembling assets of different metrics, it is
|
||||
/// the assembler's responsibility to apply suitable correctives to the
|
||||
/// referenced data to bring it into the referencing stage's metric.
|
||||
///
|
||||
/// We encode linear measure as **meters per unit** (stage-level metadata
|
||||
/// *metersPerUnit*) rather than units-per-meter because it makes it easier
|
||||
/// to encode precise imperial units (one imperial foot = 0.3048 meters exactly).
|
||||
///
|
||||
/// If a UsdStage has no authored *metersPerUnit* we fall back to the value
|
||||
/// \ref UsdGeomLinearUnits "UsdGeomLinearUnits::centimeters", i.e. 0.01.
|
||||
///
|
||||
/// The specified *metersPerUnit* metric should only be applied to
|
||||
/// **world space** (i.e. fully transformed) attributes of types:
|
||||
/// - point3{h,f,d} (and Arrays thereof)
|
||||
/// - vector3{h,f,d} (and Arrays thereof)
|
||||
/// - schema attributes that define a length, such as Sphere.radius
|
||||
/// and Boundable.extent
|
||||
///
|
||||
/// It may be tempting to interpret raw attribute values, and even
|
||||
/// xformOp:translate values in the *metersPerUnit* metric, but because any
|
||||
/// xformOp:scale transformations will change the metric of the authored
|
||||
/// attribute, and in fact we *require* this sort of scale change when
|
||||
/// referencing assets of differing metrics, it is unreliable to do so.
|
||||
|
||||
/// @{
|
||||
|
||||
/// Return *stage*'s authored *metersPerUnit*, or 0.01 if unauthored.
|
||||
/// \sa UsdGeomLinearUnits_group
|
||||
USDGEOM_API
|
||||
double UsdGeomGetStageMetersPerUnit(const UsdStageWeakPtr &stage);
|
||||
|
||||
/// Return whether *stage* has an authored *metersPerUnit*.
|
||||
/// \sa UsdGeomLinearUnits_group
|
||||
USDGEOM_API
|
||||
bool UsdGeomStageHasAuthoredMetersPerUnit(const UsdStageWeakPtr &stage);
|
||||
|
||||
/// Author *stage*'s *metersPerUnit*.
|
||||
///
|
||||
/// \return true if metersPerUnit was successfully set. The stage's
|
||||
/// UsdEditTarget must be either its root layer or session layer.
|
||||
/// \sa UsdGeomLinearUnits_group
|
||||
USDGEOM_API
|
||||
bool UsdGeomSetStageMetersPerUnit(const UsdStageWeakPtr &stage,
|
||||
double metersPerUnit);
|
||||
|
||||
/// Return *true* if the two given metrics are within the provided
|
||||
/// relative *epsilon* of each other, when you need to know an absolute
|
||||
/// metric rather than a scaling factor.
|
||||
///
|
||||
/// Use like so:
|
||||
/// \code
|
||||
/// double stageUnits = UsdGeomGetStageMetersPerUnit(stage);
|
||||
///
|
||||
/// if (UsdGeomLinearUnitsAre(stageUnits, UsdGeomLinearUnits::meters))
|
||||
/// // do something for meters
|
||||
/// else if (UsdGeomLinearUnitsAre(stageUnits, UsdGeomLinearUnits::feet))
|
||||
/// // do something for feet
|
||||
/// \endcode
|
||||
///
|
||||
/// \return *false* if either input is zero or negative, otherwise relative
|
||||
/// floating-point comparison between the two inputs.
|
||||
/// \sa UsdGeomLinearUnits_group
|
||||
USDGEOM_API
|
||||
bool UsdGeomLinearUnitsAre(double authoredUnits, double standardUnits,
|
||||
double epsilon = 1e-5);
|
||||
|
||||
/// \class UsdGeomLinearUnits
|
||||
/// Container class for static double-precision symbols representing common
|
||||
/// units of measure expressed in meters.
|
||||
/// \sa UsdGeomLinearUnits_group
|
||||
class UsdGeomLinearUnits {
|
||||
public:
|
||||
static constexpr double nanometers = 1e-9;
|
||||
static constexpr double micrometers = 1e-6;
|
||||
static constexpr double millimeters = 0.001;
|
||||
static constexpr double centimeters = 0.01;
|
||||
static constexpr double meters = 1.0;
|
||||
static constexpr double kilometers = 1000;
|
||||
|
||||
/// Measured for one year = 365.25 days
|
||||
static constexpr double lightYears = 9.4607304725808e15;
|
||||
|
||||
static constexpr double inches = 0.0254;
|
||||
static constexpr double feet = 0.3048;
|
||||
static constexpr double yards = 0.9144;
|
||||
static constexpr double miles = 1609.344;
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_USD_GEOM_METRICS_H
|
||||
@@ -0,0 +1,647 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_MODELAPI_H
|
||||
#define USDGEOM_GENERATED_MODELAPI_H
|
||||
|
||||
/// \file usdGeom/modelAPI.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/apiSchemaBase.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/usd/usdGeom/bboxCache.h"
|
||||
#include "pxr/usd/usdGeom/constraintTarget.h"
|
||||
#include "pxr/usd/usdGeom/imageable.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// GEOMMODELAPI //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomModelAPI
|
||||
///
|
||||
/// UsdGeomModelAPI extends the generic UsdModelAPI schema with
|
||||
/// geometry specific concepts such as cached extents for the entire model,
|
||||
/// constraint targets, and geometry-inspired extensions to the payload
|
||||
/// lofting process.
|
||||
///
|
||||
/// As described in GetExtentsHint() below, it is useful to cache extents
|
||||
/// at the model level. UsdGeomModelAPI provides schema for computing and
|
||||
/// storing these cached extents, which can be consumed by UsdGeomBBoxCache to
|
||||
/// provide fast access to precomputed extents that will be used as the model's
|
||||
/// bounds ( see UsdGeomBBoxCache::UsdGeomBBoxCache() ).
|
||||
///
|
||||
/// \section UsdGeomModelAPI_drawMode Draw Modes
|
||||
///
|
||||
/// Draw modes provide optional alternate imaging behavior for USD subtrees with
|
||||
/// kind model. \em model:drawMode (which is inheritable) and
|
||||
/// \em model:applyDrawMode (which is not) are resolved into a decision to stop
|
||||
/// traversing the scene graph at a certain point, and replace a USD subtree
|
||||
/// with proxy geometry.
|
||||
///
|
||||
/// The value of \em model:drawMode determines the type of proxy geometry:
|
||||
/// - \em origin - Draw the model-space basis vectors of the replaced prim.
|
||||
/// - \em bounds - Draw the model-space bounding box of the replaced prim.
|
||||
/// - \em cards - Draw textured quads as a placeholder for the replaced prim.
|
||||
/// - \em default - An explicit opinion to draw the USD subtree as normal.
|
||||
/// - \em inherited - Defer to the parent opinion.
|
||||
///
|
||||
/// \em model:drawMode falls back to _inherited_ so that a whole scene,
|
||||
/// a large group, or all prototypes of a model hierarchy PointInstancer can
|
||||
/// be assigned a draw mode with a single attribute edit. If no draw mode is
|
||||
/// explicitly set in a hierarchy, the resolved value is _default_.
|
||||
///
|
||||
/// \em model:applyDrawMode is meant to be written when an asset is authored,
|
||||
/// and provides flexibility for different asset types. For example,
|
||||
/// a character assembly (composed of character, clothes, etc) might have
|
||||
/// \em model:applyDrawMode set at the top of the subtree so the whole group
|
||||
/// can be drawn as a single card object. An effects subtree might have
|
||||
/// \em model:applyDrawMode set at a lower level so each particle
|
||||
/// group draws individually.
|
||||
///
|
||||
/// Models of kind component are treated as if \em model:applyDrawMode
|
||||
/// were true. This means a prim is drawn with proxy geometry when: the
|
||||
/// prim has kind component, and/or \em model:applyDrawMode is set; and
|
||||
/// the prim's resolved value for \em model:drawMode is not _default_.
|
||||
///
|
||||
/// \section UsdGeomModelAPI_cardGeometry Cards Geometry
|
||||
///
|
||||
/// The specific geometry used in cards mode is controlled by the
|
||||
/// \em model:cardGeometry attribute:
|
||||
/// - \em cross - Generate a quad normal to each basis direction and negative.
|
||||
/// Locate each quad so that it bisects the model extents.
|
||||
/// - \em box - Generate a quad normal to each basis direction and negative.
|
||||
/// Locate each quad on a face of the model extents, facing out.
|
||||
/// - \em fromTexture - Generate a quad for each supplied texture from
|
||||
/// attributes stored in that texture's metadata.
|
||||
///
|
||||
/// For \em cross and \em box mode, the extents are calculated for purposes
|
||||
/// \em default, \em proxy, and \em render, at their earliest authored time.
|
||||
/// If the model has no textures, all six card faces are rendered using
|
||||
/// \em model:drawModeColor. If one or more textures are present, only axes
|
||||
/// with one or more textures assigned are drawn. For each axis, if both
|
||||
/// textures (positive and negative) are specified, they'll be used on the
|
||||
/// corresponding card faces; if only one texture is specified, it will be
|
||||
/// mapped to the opposite card face after being flipped on the texture's
|
||||
/// s-axis. Any card faces with invalid asset paths will be drawn with
|
||||
/// \em model:drawModeColor.
|
||||
///
|
||||
/// Both \em model:cardGeometry and \em model:drawModeColor should be
|
||||
/// authored on the prim where the draw mode takes effect, since these
|
||||
/// attributes are not inherited.
|
||||
///
|
||||
/// For \em fromTexture mode, only card faces with valid textures assigned
|
||||
/// are drawn. The geometry is generated by pulling the \em worldtoscreen
|
||||
/// attribute out of texture metadata. This is expected to be a 4x4 matrix
|
||||
/// mapping the model-space position of the card quad to the clip-space quad
|
||||
/// with corners (-1,-1,0) and (1,1,0). The card vertices are generated by
|
||||
/// transforming the clip-space corners by the inverse of \em worldtoscreen.
|
||||
/// Textures are mapped so that (s) and (t) map to (+x) and (+y) in clip space.
|
||||
/// If the metadata cannot be read in the right format, or the matrix can't
|
||||
/// be inverted, the card face is not drawn.
|
||||
///
|
||||
/// All card faces are drawn and textured as single-sided.
|
||||
///
|
||||
/// \todo CreatePayload()
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomModelAPI : public UsdAPISchemaBase
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
|
||||
|
||||
/// Construct a UsdGeomModelAPI on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomModelAPI::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomModelAPI(const UsdPrim& prim=UsdPrim())
|
||||
: UsdAPISchemaBase(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomModelAPI on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomModelAPI(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomModelAPI(const UsdSchemaBase& schemaObj)
|
||||
: UsdAPISchemaBase(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomModelAPI();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomModelAPI holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomModelAPI(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomModelAPI
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
/// Returns true if this <b>single-apply</b> API schema can be applied to
|
||||
/// the given \p prim. If this schema can not be a applied to the prim,
|
||||
/// this returns false and, if provided, populates \p whyNot with the
|
||||
/// reason it can not be applied.
|
||||
///
|
||||
/// Note that if CanApply returns false, that does not necessarily imply
|
||||
/// that calling Apply will fail. Callers are expected to call CanApply
|
||||
/// before calling Apply if they want to ensure that it is valid to
|
||||
/// apply a schema.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool
|
||||
CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
|
||||
|
||||
/// Applies this <b>single-apply</b> API schema to the given \p prim.
|
||||
/// This information is stored by adding "GeomModelAPI" to the
|
||||
/// token-valued, listOp metadata \em apiSchemas on the prim.
|
||||
///
|
||||
/// \return A valid UsdGeomModelAPI object is returned upon success.
|
||||
/// An invalid (or empty) UsdGeomModelAPI object is returned upon
|
||||
/// failure. See \ref UsdPrim::ApplyAPI() for conditions
|
||||
/// resulting in failure.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomModelAPI
|
||||
Apply(const UsdPrim &prim);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELDRAWMODE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Alternate imaging mode; applied to this prim or child prims
|
||||
/// where \em model:applyDrawMode is true, or where the prim
|
||||
/// has kind \em component. See \ref UsdGeomModelAPI_drawMode
|
||||
/// for mode descriptions.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token model:drawMode = "inherited"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | origin, bounds, cards, default, inherited |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelDrawModeAttr() const;
|
||||
|
||||
/// See GetModelDrawModeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelDrawModeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELAPPLYDRAWMODE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// If true, and the resolved value of \em model:drawMode is
|
||||
/// non-default, apply an alternate imaging mode to this prim. See
|
||||
/// \ref UsdGeomModelAPI_drawMode.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform bool model:applyDrawMode = 0` |
|
||||
/// | C++ Type | bool |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelApplyDrawModeAttr() const;
|
||||
|
||||
/// See GetModelApplyDrawModeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelApplyDrawModeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELDRAWMODECOLOR
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The base color of imaging prims inserted for alternate
|
||||
/// imaging modes. For \em origin and \em bounds modes, this
|
||||
/// controls line color; for \em cards mode, this controls the
|
||||
/// fallback quad color.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform float3 model:drawModeColor = (0.18, 0.18, 0.18)` |
|
||||
/// | C++ Type | GfVec3f |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3 |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelDrawModeColorAttr() const;
|
||||
|
||||
/// See GetModelDrawModeColorAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelDrawModeColorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELCARDGEOMETRY
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The geometry to generate for imaging prims inserted for \em
|
||||
/// cards imaging mode. See \ref UsdGeomModelAPI_cardGeometry for
|
||||
/// geometry descriptions.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token model:cardGeometry = "cross"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | cross, box, fromTexture |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelCardGeometryAttr() const;
|
||||
|
||||
/// See GetModelCardGeometryAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelCardGeometryAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELCARDTEXTUREXPOS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// In \em cards imaging mode, the texture applied to the X+ quad.
|
||||
/// The texture axes (s,t) are mapped to model-space axes (-y, -z).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `asset model:cardTextureXPos` |
|
||||
/// | C++ Type | SdfAssetPath |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelCardTextureXPosAttr() const;
|
||||
|
||||
/// See GetModelCardTextureXPosAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelCardTextureXPosAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELCARDTEXTUREYPOS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// In \em cards imaging mode, the texture applied to the Y+ quad.
|
||||
/// The texture axes (s,t) are mapped to model-space axes (x, -z).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `asset model:cardTextureYPos` |
|
||||
/// | C++ Type | SdfAssetPath |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelCardTextureYPosAttr() const;
|
||||
|
||||
/// See GetModelCardTextureYPosAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelCardTextureYPosAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELCARDTEXTUREZPOS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// In \em cards imaging mode, the texture applied to the Z+ quad.
|
||||
/// The texture axes (s,t) are mapped to model-space axes (x, -y).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `asset model:cardTextureZPos` |
|
||||
/// | C++ Type | SdfAssetPath |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelCardTextureZPosAttr() const;
|
||||
|
||||
/// See GetModelCardTextureZPosAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelCardTextureZPosAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELCARDTEXTUREXNEG
|
||||
// --------------------------------------------------------------------- //
|
||||
/// In \em cards imaging mode, the texture applied to the X- quad.
|
||||
/// The texture axes (s,t) are mapped to model-space axes (y, -z).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `asset model:cardTextureXNeg` |
|
||||
/// | C++ Type | SdfAssetPath |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelCardTextureXNegAttr() const;
|
||||
|
||||
/// See GetModelCardTextureXNegAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelCardTextureXNegAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELCARDTEXTUREYNEG
|
||||
// --------------------------------------------------------------------- //
|
||||
/// In \em cards imaging mode, the texture applied to the Y- quad.
|
||||
/// The texture axes (s,t) are mapped to model-space axes (-x, -z).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `asset model:cardTextureYNeg` |
|
||||
/// | C++ Type | SdfAssetPath |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelCardTextureYNegAttr() const;
|
||||
|
||||
/// See GetModelCardTextureYNegAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelCardTextureYNegAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// MODELCARDTEXTUREZNEG
|
||||
// --------------------------------------------------------------------- //
|
||||
/// In \em cards imaging mode, the texture applied to the Z- quad.
|
||||
/// The texture axes (s,t) are mapped to model-space axes (-x, -y).
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `asset model:cardTextureZNeg` |
|
||||
/// | C++ Type | SdfAssetPath |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Asset |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetModelCardTextureZNegAttr() const;
|
||||
|
||||
/// See GetModelCardTextureZNegAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateModelCardTextureZNegAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// \anchor UsdGeomModelAPIExtentsHint
|
||||
/// \name Model Extents Hint API
|
||||
///
|
||||
/// Methods for querying, authoring and computing the model's
|
||||
/// "extentsHint".
|
||||
/// @{
|
||||
|
||||
/// Retrieve the authored value (if any) of this model's "extentsHint"
|
||||
///
|
||||
/// Persistent caching of bounds in USD is a potentially perilous endeavor,
|
||||
/// given that:
|
||||
/// \li It is very easy to add overrides in new super-layers that
|
||||
/// invalidate the cached bounds, and no practical way to automatically
|
||||
/// detect when this happens
|
||||
/// \li It is possible for references to be allowed to "float", so that
|
||||
/// asset updates can flow directly into cached scenes. Such changes in
|
||||
/// referenced scene description can also invalidate cached bounds in
|
||||
/// referencing layers.
|
||||
///
|
||||
/// For these reasons, as a general rule, we only persistently cache
|
||||
/// leaf gprim extents in object space. However, even with cached gprim
|
||||
/// extents, computing bounds can be expensive. Since model-level bounds
|
||||
/// are so useful to many graphics applications, we make an exception,
|
||||
/// with some caveats. The "extentsHint" should be considered entirely
|
||||
/// optional (whereas gprim extent is not); if authored, it should
|
||||
/// contains the extents for various values of gprim purposes.
|
||||
/// The extents for different values of purpose are stored in a linear Vec3f
|
||||
/// array as pairs of GfVec3f values in the order specified by
|
||||
/// UsdGeomImageable::GetOrderedPurposeTokens(). This list is trimmed to
|
||||
/// only include non-empty extents. i.e., if a model has only default and
|
||||
/// render geoms, then it will only have 4 GfVec3f values in its
|
||||
/// extentsHint array. We do not skip over zero extents, so if a model
|
||||
/// has only default and proxy geom, we will author six GfVec3f's, the
|
||||
/// middle two representing an zero extent for render geometry.
|
||||
///
|
||||
/// A UsdGeomBBoxCache can be configured to first consult the cached
|
||||
/// extents when evaluating model roots, rather than descending into the
|
||||
/// models for the full computation. This is not the default behavior,
|
||||
/// and gives us a convenient way to validate that the cached
|
||||
/// extentsHint is still valid.
|
||||
///
|
||||
/// \return \c true if a value was fetched; \c false if no value was
|
||||
/// authored, or on error. It is an error to make this query of a prim
|
||||
/// that is not a model root.
|
||||
///
|
||||
/// \sa UsdGeomImageable::GetPurposeAttr(),
|
||||
/// UsdGeomImageable::GetOrderedPurposeTokens()
|
||||
///
|
||||
USDGEOM_API
|
||||
bool GetExtentsHint(VtVec3fArray *extents,
|
||||
const UsdTimeCode &time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// Authors the extentsHint array for this model at the given time.
|
||||
///
|
||||
/// \sa GetExtentsHint()
|
||||
///
|
||||
USDGEOM_API
|
||||
bool SetExtentsHint(VtVec3fArray const &extents,
|
||||
const UsdTimeCode &time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// Returns the custom 'extentsHint' attribute if it exits.
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExtentsHintAttr() const;
|
||||
|
||||
/// For the given model, compute the value for the extents hint with the
|
||||
/// given \p bboxCache. \p bboxCache should be setup with the
|
||||
/// appropriate time. After calling this function, the \p bboxCache may
|
||||
/// have it's included purposes changed.
|
||||
///
|
||||
/// \note \p bboxCache should not be in use by any other thread while
|
||||
/// this method is using it in a thread.
|
||||
USDGEOM_API
|
||||
VtVec3fArray ComputeExtentsHint(UsdGeomBBoxCache& bboxCache) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \anchor UsdGeomModelAPIConstraintTargets
|
||||
/// \name Model Constraint Targets API
|
||||
///
|
||||
/// Methods for adding and listing constraint targets.
|
||||
///
|
||||
/// @{
|
||||
|
||||
/// Get the constraint target with the given name, \p constraintName.
|
||||
///
|
||||
/// If the requested constraint target does not exist, then an invalid
|
||||
/// UsdConstraintTarget object is returned.
|
||||
///
|
||||
USDGEOM_API
|
||||
UsdGeomConstraintTarget GetConstraintTarget(
|
||||
const std::string &constraintName) const;
|
||||
|
||||
/// Creates a new constraint target with the given name, \p constraintName.
|
||||
///
|
||||
/// If the constraint target already exists, then the existing target is
|
||||
/// returned. If it does not exist, a new one is created and returned.
|
||||
///
|
||||
USDGEOM_API
|
||||
UsdGeomConstraintTarget CreateConstraintTarget(
|
||||
const std::string &constraintName) const;
|
||||
|
||||
/// Returns all the constraint targets belonging to the model.
|
||||
///
|
||||
/// Only valid constraint targets in the "constraintTargets" namespace
|
||||
/// are returned by this method.
|
||||
///
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomConstraintTarget> GetConstraintTargets() const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// Calculate the effective model:drawMode of this prim.
|
||||
///
|
||||
/// If the draw mode is authored on this prim, it's used. Otherwise,
|
||||
/// the fallback value is "inherited", which defers to the parent opinion.
|
||||
/// The first non-inherited opinion found walking from this prim towards
|
||||
/// the root is used. If the attribute isn't set on any ancestors, we
|
||||
/// return "default" (meaning, disable "drawMode" geometry).
|
||||
///
|
||||
/// If this function is being called in a traversal context to compute
|
||||
/// the draw mode of an entire hierarchy of prims, it would be beneficial
|
||||
/// to cache and pass in the computed parent draw-mode via the
|
||||
/// \p parentDrawMode parameter. This avoids repeated upward traversal to
|
||||
/// look for ancestor opinions.
|
||||
///
|
||||
/// When \p parentDrawMode is empty (or unspecified), this function does
|
||||
/// an upward traversal to find the closest ancestor with an authored
|
||||
/// model:drawMode.
|
||||
///
|
||||
/// \sa GetModelDrawModeAttr()
|
||||
USDGEOM_API
|
||||
TfToken ComputeModelDrawMode(const TfToken &parentDrawMode=TfToken()) const;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,234 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_MOTIONAPI_H
|
||||
#define USDGEOM_GENERATED_MOTIONAPI_H
|
||||
|
||||
/// \file usdGeom/motionAPI.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/apiSchemaBase.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// MOTIONAPI //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomMotionAPI
|
||||
///
|
||||
/// UsdGeomMotionAPI encodes data that can live on any prim that
|
||||
/// may affect computations involving:
|
||||
/// - computed motion for motion blur
|
||||
/// - sampling for motion blur
|
||||
///
|
||||
/// For example, UsdGeomMotionAPI provides *velocityScale*
|
||||
/// (GetVelocityScaleAttr()) for controlling how motion-blur samples should
|
||||
/// be computed by velocity-consuming schemas.
|
||||
///
|
||||
class UsdGeomMotionAPI : public UsdAPISchemaBase
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
|
||||
|
||||
/// Construct a UsdGeomMotionAPI on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomMotionAPI::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomMotionAPI(const UsdPrim& prim=UsdPrim())
|
||||
: UsdAPISchemaBase(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomMotionAPI on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomMotionAPI(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomMotionAPI(const UsdSchemaBase& schemaObj)
|
||||
: UsdAPISchemaBase(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomMotionAPI();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomMotionAPI holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomMotionAPI(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomMotionAPI
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
/// Returns true if this <b>single-apply</b> API schema can be applied to
|
||||
/// the given \p prim. If this schema can not be a applied to the prim,
|
||||
/// this returns false and, if provided, populates \p whyNot with the
|
||||
/// reason it can not be applied.
|
||||
///
|
||||
/// Note that if CanApply returns false, that does not necessarily imply
|
||||
/// that calling Apply will fail. Callers are expected to call CanApply
|
||||
/// before calling Apply if they want to ensure that it is valid to
|
||||
/// apply a schema.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool
|
||||
CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
|
||||
|
||||
/// Applies this <b>single-apply</b> API schema to the given \p prim.
|
||||
/// This information is stored by adding "MotionAPI" to the
|
||||
/// token-valued, listOp metadata \em apiSchemas on the prim.
|
||||
///
|
||||
/// \return A valid UsdGeomMotionAPI object is returned upon success.
|
||||
/// An invalid (or empty) UsdGeomMotionAPI object is returned upon
|
||||
/// failure. See \ref UsdPrim::ApplyAPI() for conditions
|
||||
/// resulting in failure.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomMotionAPI
|
||||
Apply(const UsdPrim &prim);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VELOCITYSCALE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// VelocityScale is an **inherited** float attribute that
|
||||
/// velocity-based schemas (e.g. PointBased, PointInstancer) can consume
|
||||
/// to compute interpolated positions and orientations by applying
|
||||
/// velocity and angularVelocity, which is required for interpolating
|
||||
/// between samples when topology is varying over time. Although these
|
||||
/// quantities are generally physically computed by a simulator, sometimes
|
||||
/// we require more or less motion-blur to achieve the desired look.
|
||||
/// VelocityScale allows artists to dial-in, as a post-sim correction,
|
||||
/// a scale factor to be applied to the velocity prior to computing
|
||||
/// interpolated positions from it.
|
||||
///
|
||||
/// See also ComputeVelocityScale()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float motion:velocityScale = 1` |
|
||||
/// | C++ Type | float |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVelocityScaleAttr() const;
|
||||
|
||||
/// See GetVelocityScaleAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVelocityScaleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Compute the inherited value of *velocityScale* at \p time, i.e. the
|
||||
/// authored value on the prim closest to this prim in namespace, resolved
|
||||
/// upwards through its ancestors in namespace.
|
||||
///
|
||||
/// \return the inherited value, or 1.0 if neither the prim nor any
|
||||
/// of its ancestors possesses an authored value.
|
||||
///
|
||||
/// \note this is a reference implementation that is not particularly
|
||||
/// efficient if evaluating over many prims, because it does not share
|
||||
/// inherited results.
|
||||
USDGEOM_API
|
||||
float ComputeVelocityScale(UsdTimeCode time = UsdTimeCode::Default()) const;
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,263 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_NURBSCURVES_H
|
||||
#define USDGEOM_GENERATED_NURBSCURVES_H
|
||||
|
||||
/// \file usdGeom/nurbsCurves.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/curves.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// NURBSCURVES //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomNurbsCurves
|
||||
///
|
||||
/// This schema is analagous to NURBS Curves in packages like Maya
|
||||
/// and Houdini, often used for interchange of rigging and modeling curves.
|
||||
/// Unlike Maya, this curve spec supports batching of multiple curves into a
|
||||
/// single prim, widths, and normals in the schema. Additionally, we require
|
||||
/// 'numSegments + 2 * degree + 1' knots (2 more than maya does). This is to
|
||||
/// be more consistent with RenderMan's NURBS patch specification.
|
||||
///
|
||||
/// To express a periodic curve:
|
||||
/// - knot[0] = knot[1] - (knots[-2] - knots[-3];
|
||||
/// - knot[-1] = knot[-2] + (knot[2] - knots[1]);
|
||||
///
|
||||
/// To express a nonperiodic curve:
|
||||
/// - knot[0] = knot[1];
|
||||
/// - knot[-1] = knot[-2];
|
||||
///
|
||||
/// In spite of these slight differences in the spec, curves generated in Maya
|
||||
/// should be preserved when roundtripping.
|
||||
///
|
||||
/// \em order and \em range, when representing a batched NurbsCurve should be
|
||||
/// authored one value per curve. \em knots should be the concatentation of
|
||||
/// all batched curves.
|
||||
///
|
||||
class UsdGeomNurbsCurves : public UsdGeomCurves
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomNurbsCurves on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomNurbsCurves::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomNurbsCurves(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomCurves(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomNurbsCurves on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomNurbsCurves(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomNurbsCurves(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomCurves(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomNurbsCurves();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomNurbsCurves holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomNurbsCurves(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomNurbsCurves
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomNurbsCurves
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// ORDER
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Order of the curve. Order must be positive and is
|
||||
/// equal to the degree of the polynomial basis to be evaluated, plus 1.
|
||||
/// Its value for the 'i'th curve must be less than or equal to
|
||||
/// curveVertexCount[i]
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] order = []` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetOrderAttr() const;
|
||||
|
||||
/// See GetOrderAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// KNOTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Knot vector providing curve parameterization.
|
||||
/// The length of the slice of the array for the ith curve
|
||||
/// must be ( curveVertexCount[i] + order[i] ), and its
|
||||
/// entries must take on monotonically increasing values.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double[] knots` |
|
||||
/// | C++ Type | VtArray<double> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetKnotsAttr() const;
|
||||
|
||||
/// See GetKnotsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateKnotsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// RANGES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Provides the minimum and maximum parametric values (as defined
|
||||
/// by knots) over which the curve is actually defined. The minimum must
|
||||
/// be less than the maximum, and greater than or equal to the value of the
|
||||
/// knots['i'th curve slice][order[i]-1]. The maxium must be less
|
||||
/// than or equal to the last element's value in knots['i'th curve slice].
|
||||
/// Range maps to (vmin, vmax) in the RenderMan spec.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double2[] ranges` |
|
||||
/// | C++ Type | VtArray<GfVec2d> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double2Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetRangesAttr() const;
|
||||
|
||||
/// See GetRangesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateRangesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,634 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_NURBSPATCH_H
|
||||
#define USDGEOM_GENERATED_NURBSPATCH_H
|
||||
|
||||
/// \file usdGeom/nurbsPatch.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/pointBased.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// NURBSPATCH //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomNurbsPatch
|
||||
///
|
||||
/// Encodes a rational or polynomial non-uniform B-spline
|
||||
/// surface, with optional trim curves.
|
||||
///
|
||||
/// The encoding mostly follows that of RiNuPatch and RiTrimCurve:
|
||||
/// https://renderman.pixar.com/resources/current/RenderMan/geometricPrimitives.html#rinupatch , with some minor renaming and coalescing for clarity.
|
||||
///
|
||||
/// The layout of control vertices in the \em points attribute inherited
|
||||
/// from UsdGeomPointBased is row-major with U considered rows, and V columns.
|
||||
///
|
||||
/// \anchor UsdGeom_NurbsPatch_Form
|
||||
/// <b>NurbsPatch Form</b>
|
||||
///
|
||||
/// The authored points, orders, knots, weights, and ranges are all that is
|
||||
/// required to render the nurbs patch. However, the only way to model closed
|
||||
/// surfaces with nurbs is to ensure that the first and last control points
|
||||
/// along the given axis are coincident. Similarly, to ensure the surface is
|
||||
/// not only closed but also C2 continuous, the last \em order - 1 control
|
||||
/// points must be (correspondingly) coincident with the first \em order - 1
|
||||
/// control points, and also the spacing of the last corresponding knots
|
||||
/// must be the same as the first corresponding knots.
|
||||
///
|
||||
/// <b>Form</b> is provided as an aid to interchange between modeling and
|
||||
/// animation applications so that they can robustly identify the intent with
|
||||
/// which the surface was modelled, and take measures (if they are able) to
|
||||
/// preserve the continuity/concidence constraints as the surface may be rigged
|
||||
/// or deformed.
|
||||
/// \li An \em open-form NurbsPatch has no continuity constraints.
|
||||
/// \li A \em closed-form NurbsPatch expects the first and last control points
|
||||
/// to overlap
|
||||
/// \li A \em periodic-form NurbsPatch expects the first and last
|
||||
/// \em order - 1 control points to overlap.
|
||||
///
|
||||
/// <b>Nurbs vs Subdivision Surfaces</b>
|
||||
///
|
||||
/// Nurbs are an important modeling primitive in CAD/CAM tools and early
|
||||
/// computer graphics DCC's. Because they have a natural UV parameterization
|
||||
/// they easily support "trim curves", which allow smooth shapes to be
|
||||
/// carved out of the surface.
|
||||
///
|
||||
/// However, the topology of the patch is always rectangular, and joining two
|
||||
/// nurbs patches together (especially when they have differing numbers of
|
||||
/// spans) is difficult to do smoothly. Also, nurbs are not supported by
|
||||
/// the Ptex texturing technology (http://ptex.us).
|
||||
///
|
||||
/// Neither of these limitations are shared by subdivision surfaces; therefore,
|
||||
/// although they do not subscribe to trim-curve-based shaping, subdivs are
|
||||
/// often considered a more flexible modeling primitive.
|
||||
///
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomNurbsPatch : public UsdGeomPointBased
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomNurbsPatch on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomNurbsPatch::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomNurbsPatch(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomPointBased(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomNurbsPatch on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomNurbsPatch(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomNurbsPatch(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomPointBased(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomNurbsPatch();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomNurbsPatch holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomNurbsPatch(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomNurbsPatch
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomNurbsPatch
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// UVERTEXCOUNT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Number of vertices in the U direction. Should be at least as
|
||||
/// large as uOrder.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int uVertexCount` |
|
||||
/// | C++ Type | int |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetUVertexCountAttr() const;
|
||||
|
||||
/// See GetUVertexCountAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateUVertexCountAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VVERTEXCOUNT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Number of vertices in the V direction. Should be at least as
|
||||
/// large as vOrder.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int vVertexCount` |
|
||||
/// | C++ Type | int |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVVertexCountAttr() const;
|
||||
|
||||
/// See GetVVertexCountAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVVertexCountAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// UORDER
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Order in the U direction. Order must be positive and is
|
||||
/// equal to the degree of the polynomial basis to be evaluated, plus 1.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int uOrder` |
|
||||
/// | C++ Type | int |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetUOrderAttr() const;
|
||||
|
||||
/// See GetUOrderAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateUOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VORDER
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Order in the V direction. Order must be positive and is
|
||||
/// equal to the degree of the polynomial basis to be evaluated, plus 1.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int vOrder` |
|
||||
/// | C++ Type | int |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVOrderAttr() const;
|
||||
|
||||
/// See GetVOrderAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// UKNOTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Knot vector for U direction providing U parameterization.
|
||||
/// The length of this array must be ( uVertexCount + uOrder ), and its
|
||||
/// entries must take on monotonically increasing values.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double[] uKnots` |
|
||||
/// | C++ Type | VtArray<double> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetUKnotsAttr() const;
|
||||
|
||||
/// See GetUKnotsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateUKnotsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VKNOTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Knot vector for V direction providing U parameterization.
|
||||
/// The length of this array must be ( vVertexCount + vOrder ), and its
|
||||
/// entries must take on monotonically increasing values.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double[] vKnots` |
|
||||
/// | C++ Type | VtArray<double> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVKnotsAttr() const;
|
||||
|
||||
/// See GetVKnotsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVKnotsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// UFORM
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Interpret the control grid and knot vectors as representing
|
||||
/// an open, geometrically closed, or geometrically closed and C2 continuous
|
||||
/// surface along the U dimension.
|
||||
/// \sa \ref UsdGeom_NurbsPatch_Form "NurbsPatch Form"
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token uForm = "open"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | open, closed, periodic |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetUFormAttr() const;
|
||||
|
||||
/// See GetUFormAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateUFormAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VFORM
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Interpret the control grid and knot vectors as representing
|
||||
/// an open, geometrically closed, or geometrically closed and C2 continuous
|
||||
/// surface along the V dimension.
|
||||
/// \sa \ref UsdGeom_NurbsPatch_Form "NurbsPatch Form"
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token vForm = "open"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | open, closed, periodic |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVFormAttr() const;
|
||||
|
||||
/// See GetVFormAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVFormAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// URANGE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Provides the minimum and maximum parametric values (as defined
|
||||
/// by uKnots) over which the surface is actually defined. The minimum
|
||||
/// must be less than the maximum, and greater than or equal to the
|
||||
/// value of uKnots[uOrder-1]. The maxium must be less than or equal
|
||||
/// to the last element's value in uKnots.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double2 uRange` |
|
||||
/// | C++ Type | GfVec2d |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double2 |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetURangeAttr() const;
|
||||
|
||||
/// See GetURangeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateURangeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VRANGE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Provides the minimum and maximum parametric values (as defined
|
||||
/// by vKnots) over which the surface is actually defined. The minimum
|
||||
/// must be less than the maximum, and greater than or equal to the
|
||||
/// value of vKnots[vOrder-1]. The maxium must be less than or equal
|
||||
/// to the last element's value in vKnots.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double2 vRange` |
|
||||
/// | C++ Type | GfVec2d |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double2 |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVRangeAttr() const;
|
||||
|
||||
/// See GetVRangeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVRangeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// POINTWEIGHTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Optionally provides "w" components for each control point,
|
||||
/// thus must be the same length as the points attribute. If authored,
|
||||
/// the patch will be rational. If unauthored, the patch will be
|
||||
/// polynomial, i.e. weight for all points is 1.0.
|
||||
/// \note Some DCC's pre-weight the \em points, but in this schema,
|
||||
/// \em points are not pre-weighted.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double[] pointWeights` |
|
||||
/// | C++ Type | VtArray<double> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetPointWeightsAttr() const;
|
||||
|
||||
/// See GetPointWeightsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreatePointWeightsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TRIMCURVECOUNTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Each element specifies how many curves are present in each
|
||||
/// "loop" of the trimCurve, and the length of the array determines how
|
||||
/// many loops the trimCurve contains. The sum of all elements is the
|
||||
/// total nuber of curves in the trim, to which we will refer as
|
||||
/// \em nCurves in describing the other trim attributes.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] trimCurve:counts` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTrimCurveCountsAttr() const;
|
||||
|
||||
/// See GetTrimCurveCountsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTrimCurveCountsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TRIMCURVEORDERS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Flat list of orders for each of the \em nCurves curves.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] trimCurve:orders` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTrimCurveOrdersAttr() const;
|
||||
|
||||
/// See GetTrimCurveOrdersAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTrimCurveOrdersAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TRIMCURVEVERTEXCOUNTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Flat list of number of vertices for each of the
|
||||
/// \em nCurves curves.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] trimCurve:vertexCounts` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTrimCurveVertexCountsAttr() const;
|
||||
|
||||
/// See GetTrimCurveVertexCountsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTrimCurveVertexCountsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TRIMCURVEKNOTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Flat list of parametric values for each of the
|
||||
/// \em nCurves curves. There will be as many knots as the sum over
|
||||
/// all elements of \em vertexCounts plus the sum over all elements of
|
||||
/// \em orders.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double[] trimCurve:knots` |
|
||||
/// | C++ Type | VtArray<double> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->DoubleArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTrimCurveKnotsAttr() const;
|
||||
|
||||
/// See GetTrimCurveKnotsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTrimCurveKnotsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TRIMCURVERANGES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Flat list of minimum and maximum parametric values
|
||||
/// (as defined by \em knots) for each of the \em nCurves curves.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double2[] trimCurve:ranges` |
|
||||
/// | C++ Type | VtArray<GfVec2d> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double2Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTrimCurveRangesAttr() const;
|
||||
|
||||
/// See GetTrimCurveRangesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTrimCurveRangesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// TRIMCURVEPOINTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Flat list of homogeneous 2D points (u, v, w) that comprise
|
||||
/// the \em nCurves curves. The number of points should be equal to the
|
||||
/// um over all elements of \em vertexCounts.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double3[] trimCurve:points` |
|
||||
/// | C++ Type | VtArray<GfVec3d> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double3Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetTrimCurvePointsAttr() const;
|
||||
|
||||
/// See GetTrimCurvePointsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateTrimCurvePointsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,394 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_POINTBASED_H
|
||||
#define USDGEOM_GENERATED_POINTBASED_H
|
||||
|
||||
/// \file usdGeom/pointBased.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/gprim.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// POINTBASED //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomPointBased
|
||||
///
|
||||
/// Base class for all UsdGeomGprims that possess points,
|
||||
/// providing common attributes such as normals and velocities.
|
||||
///
|
||||
class UsdGeomPointBased : public UsdGeomGprim
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// Construct a UsdGeomPointBased on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomPointBased::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomPointBased(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomGprim(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomPointBased on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomPointBased(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomPointBased(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomGprim(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomPointBased();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomPointBased holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomPointBased(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomPointBased
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// POINTS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The primary geometry attribute for all PointBased
|
||||
/// primitives, describes points in (local) space.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `point3f[] points` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Point3fArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetPointsAttr() const;
|
||||
|
||||
/// See GetPointsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreatePointsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// VELOCITIES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// If provided, 'velocities' should be used by renderers to
|
||||
///
|
||||
/// compute positions between samples for the 'points' attribute, rather
|
||||
/// than interpolating between neighboring 'points' samples. This is the
|
||||
/// only reasonable means of computing motion blur for topologically
|
||||
/// varying PointBased primitives. It follows that the length of each
|
||||
/// 'velocities' sample must match the length of the corresponding
|
||||
/// 'points' sample. Velocity is measured in position units per second,
|
||||
/// as per most simulation software. To convert to position units per
|
||||
/// UsdTimeCode, divide by UsdStage::GetTimeCodesPerSecond().
|
||||
///
|
||||
/// See also \ref UsdGeom_VelocityInterpolation .
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `vector3f[] velocities` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3fArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetVelocitiesAttr() const;
|
||||
|
||||
/// See GetVelocitiesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateVelocitiesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// ACCELERATIONS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// If provided, 'accelerations' should be used with
|
||||
/// velocities to compute positions between samples for the 'points'
|
||||
/// attribute rather than interpolating between neighboring 'points'
|
||||
/// samples. Acceleration is measured in position units per second-squared.
|
||||
/// To convert to position units per squared UsdTimeCode, divide by the
|
||||
/// square of UsdStage::GetTimeCodesPerSecond().
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `vector3f[] accelerations` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3fArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetAccelerationsAttr() const;
|
||||
|
||||
/// See GetAccelerationsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateAccelerationsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// NORMALS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Provide an object-space orientation for individual points,
|
||||
/// which, depending on subclass, may define a surface, curve, or free
|
||||
/// points. Note that 'normals' should not be authored on any Mesh that
|
||||
/// is subdivided, since the subdivision algorithm will define its own
|
||||
/// normals. 'normals' is not a generic primvar, but the number of elements
|
||||
/// in this attribute will be determined by its 'interpolation'. See
|
||||
/// \ref SetNormalsInterpolation() . If 'normals' and 'primvars:normals'
|
||||
/// are both specified, the latter has precedence.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `normal3f[] normals` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Normal3fArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetNormalsAttr() const;
|
||||
|
||||
/// See GetNormalsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateNormalsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Get the \ref Usd_InterpolationVals "interpolation" for the \em normals
|
||||
/// attribute.
|
||||
///
|
||||
/// Although 'normals' is not classified as a generic UsdGeomPrimvar (and
|
||||
/// will not be included in the results of UsdGeomImageable::GetPrimvars() )
|
||||
/// it does require an interpolation specification. The fallback
|
||||
/// interpolation, if left unspecified, is UsdGeomTokens->vertex ,
|
||||
/// which will generally produce smooth shading on a polygonal mesh.
|
||||
/// To achieve partial or fully faceted shading of a polygonal mesh
|
||||
/// with normals, one should use UsdGeomTokens->faceVarying or
|
||||
/// UsdGeomTokens->uniform interpolation.
|
||||
USDGEOM_API
|
||||
TfToken GetNormalsInterpolation() const;
|
||||
|
||||
/// Set the \ref Usd_InterpolationVals "interpolation" for the \em normals
|
||||
/// attribute.
|
||||
///
|
||||
/// \return true upon success, false if \p interpolation is not a legal
|
||||
/// value as defined by UsdGeomPrimvar::IsValidInterpolation(), or if there
|
||||
/// was a problem setting the value. No attempt is made to validate
|
||||
/// that the normals attr's value contains the right number of elements
|
||||
/// to match its interpolation to its prim's topology.
|
||||
///
|
||||
/// \sa GetNormalsInterpolation()
|
||||
USDGEOM_API
|
||||
bool SetNormalsInterpolation(TfToken const &interpolation);
|
||||
|
||||
/// Compute the extent for the point cloud defined by points.
|
||||
///
|
||||
/// \return true on success, false if extents was unable to be calculated.
|
||||
///
|
||||
/// On success, extent will contain the axis-aligned bounding box of the
|
||||
/// point cloud defined by points.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(const VtVec3fArray& points, VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(const VtVec3fArray& points,
|
||||
const GfMatrix4d& transform, VtVec3fArray* extent);
|
||||
|
||||
public:
|
||||
/// Compute points given the positions, velocities and accelerations
|
||||
/// at \p time.
|
||||
///
|
||||
/// This will return \c false and leave \p points untouched if:
|
||||
/// - \p points is NULL
|
||||
/// - one of \p time and \p baseTime is numeric and the other is
|
||||
/// UsdTimeCode::Default() (they must either both be numeric or both be
|
||||
/// default)
|
||||
/// - there is no authored points attribute
|
||||
///
|
||||
/// If there is no error, we will return \c true and \p points will contain
|
||||
/// the computed points.
|
||||
///
|
||||
/// \param points - the out parameter for the new points. Its size
|
||||
/// will depend on the authored data.
|
||||
/// \param time - UsdTimeCode at which we want to evaluate the transforms
|
||||
/// \param baseTime - required for correct interpolation between samples
|
||||
/// when \em velocities or \em accelerations are
|
||||
/// present. If there are samples for \em positions and
|
||||
/// \em velocities at t1 and t2, normal value resolution
|
||||
/// would attempt to interpolate between the two samples,
|
||||
/// and if they could not be interpolated because they
|
||||
/// differ in size (common in cases where velocity is
|
||||
/// authored), will choose the sample at t1. When
|
||||
/// sampling for the purposes of motion-blur, for example,
|
||||
/// it is common, when rendering the frame at t2, to
|
||||
/// sample at [ t2-shutter/2, t2+shutter/2 ] for a
|
||||
/// shutter interval of \em shutter. The first sample
|
||||
/// falls between t1 and t2, but we must sample at t2
|
||||
/// and apply velocity-based interpolation based on those
|
||||
/// samples to get a correct result. In such scenarios,
|
||||
/// one should provide a \p baseTime of t2 when querying
|
||||
/// \em both samples. If your application does not care
|
||||
/// about off-sample interpolation, it can supply the
|
||||
/// same value for \p baseTime that it does for \p time.
|
||||
/// When \p baseTime is less than or equal to \p time,
|
||||
/// we will choose the lower bracketing timeSample.
|
||||
USDGEOM_API
|
||||
bool
|
||||
ComputePointsAtTime(
|
||||
VtArray<GfVec3f>* points,
|
||||
const UsdTimeCode time,
|
||||
const UsdTimeCode baseTime) const;
|
||||
|
||||
/// Compute points as in ComputePointsAtTime, but using multiple sample times. An
|
||||
/// array of vector arrays is returned where each vector array contains the
|
||||
/// points for the corresponding time in \p times .
|
||||
///
|
||||
/// \param times - A vector containing the UsdTimeCodes at which we want to
|
||||
/// sample.
|
||||
USDGEOM_API
|
||||
bool
|
||||
ComputePointsAtTimes(
|
||||
std::vector<VtArray<GfVec3f>>* pointsArray,
|
||||
const std::vector<UsdTimeCode>& times,
|
||||
const UsdTimeCode baseTime) const;
|
||||
|
||||
/// \overload
|
||||
/// Perform the point computation. This does the same computation as
|
||||
/// the non-static ComputePointsAtTime method, but takes all
|
||||
/// data as parameters rather than accessing authored data.
|
||||
///
|
||||
/// \param points - the out parameter for the computed points. Its size
|
||||
/// will depend on the given data.
|
||||
/// \param stage - the UsdStage
|
||||
/// \param time - time at which we want to evaluate the transforms
|
||||
/// \param positions - array containing all current points.
|
||||
/// \param velocities - array containing all velocities. This array
|
||||
/// must be either the same size as \p positions or
|
||||
/// empty. If it is empty, points are computed as if
|
||||
/// all velocities were zero in all dimensions.
|
||||
/// \param velocitiesSampleTime - time at which the samples from
|
||||
/// \p velocities were taken.
|
||||
/// \param accelerations - array containing all accelerations.
|
||||
/// This array must be either the same size as
|
||||
/// \p positions or empty. If it is empty, points
|
||||
/// are computed as if all accelerations were zero in
|
||||
/// all dimensions.
|
||||
/// \param velocityScale - factor used to artificially increase the effect
|
||||
/// of velocity on positions.
|
||||
USDGEOM_API
|
||||
static bool
|
||||
ComputePointsAtTime(
|
||||
VtArray<GfVec3f>* points,
|
||||
UsdStageWeakPtr& stage,
|
||||
UsdTimeCode time,
|
||||
const VtVec3fArray& positions,
|
||||
const VtVec3fArray& velocities,
|
||||
UsdTimeCode velocitiesSampleTime,
|
||||
const VtVec3fArray& accelerations,
|
||||
float velocityScale);
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,284 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_POINTS_H
|
||||
#define USDGEOM_GENERATED_POINTS_H
|
||||
|
||||
/// \file usdGeom/points.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/pointBased.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// POINTS //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomPoints
|
||||
///
|
||||
/// Points are analogous to the <A HREF="https://renderman.pixar.com/resources/current/RenderMan/appnote.18.html">RiPoints spec</A>.
|
||||
///
|
||||
/// Points can be an efficient means of storing and rendering particle
|
||||
/// effects comprised of thousands or millions of small particles. Points
|
||||
/// generally receive a single shading sample each, which should take
|
||||
/// \em normals into account, if present.
|
||||
///
|
||||
/// While not technically UsdGeomPrimvars, the widths and normals also
|
||||
/// have interpolation metadata. It's common for authored widths and normals
|
||||
/// to have constant or varying interpolation.
|
||||
///
|
||||
class UsdGeomPoints : public UsdGeomPointBased
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomPoints on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomPoints::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomPoints(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomPointBased(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomPoints on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomPoints(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomPoints(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomPointBased(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomPoints();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomPoints holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomPoints(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomPoints
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomPoints
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// WIDTHS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Widths are defined as the \em diameter of the points, in
|
||||
/// object space. 'widths' is not a generic Primvar, but
|
||||
/// the number of elements in this attribute will be determined by
|
||||
/// its 'interpolation'. See \ref SetWidthsInterpolation() . If
|
||||
/// 'widths' and 'primvars:widths' are both specified, the latter
|
||||
/// has precedence.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float[] widths` |
|
||||
/// | C++ Type | VtArray<float> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetWidthsAttr() const;
|
||||
|
||||
/// See GetWidthsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateWidthsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// IDS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Ids are optional; if authored, the ids array should be the same
|
||||
/// length as the points array, specifying (at each timesample if
|
||||
/// point identities are changing) the id of each point. The
|
||||
/// type is signed intentionally, so that clients can encode some
|
||||
/// binary state on Id'd points without adding a separate
|
||||
/// primvar.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int64[] ids` |
|
||||
/// | C++ Type | VtArray<int64_t> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int64Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetIdsAttr() const;
|
||||
|
||||
/// See GetIdsAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateIdsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Get the \ref Usd_InterpolationVals "interpolation" for the \em widths
|
||||
/// attribute.
|
||||
///
|
||||
/// Although 'widths' is not classified as a generic UsdGeomPrimvar (and
|
||||
/// will not be included in the results of UsdGeomImageable::GetPrimvars() )
|
||||
/// it does require an interpolation specification. The fallback
|
||||
/// interpolation, if left unspecified, is UsdGeomTokens->vertex ,
|
||||
/// which means a width value is specified for each point.
|
||||
USDGEOM_API
|
||||
TfToken GetWidthsInterpolation() const;
|
||||
|
||||
/// Set the \ref Usd_InterpolationVals "interpolation" for the \em widths
|
||||
/// attribute.
|
||||
///
|
||||
/// \return true upon success, false if \p interpolation is not a legal
|
||||
/// value as defined by UsdPrimvar::IsValidInterpolation(), or if there
|
||||
/// was a problem setting the value. No attempt is made to validate
|
||||
/// that the widths attr's value contains the right number of elements
|
||||
/// to match its interpolation to its prim's topology.
|
||||
///
|
||||
/// \sa GetWidthsInterpolation()
|
||||
USDGEOM_API
|
||||
bool SetWidthsInterpolation(TfToken const &interpolation);
|
||||
|
||||
/// Compute the extent for the point cloud defined by points and widths.
|
||||
///
|
||||
/// \return true upon success, false if widths and points are different
|
||||
/// sized arrays.
|
||||
///
|
||||
/// On success, extent will contain the axis-aligned bounding box of the
|
||||
/// point cloud defined by points with the given widths.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(const VtVec3fArray& points,
|
||||
const VtFloatArray& widths, VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(const VtVec3fArray& points,
|
||||
const VtFloatArray& widths, const GfMatrix4d& transform,
|
||||
VtVec3fArray* extent);
|
||||
|
||||
/// Returns the number of points as defined by the size of the
|
||||
/// _points_ array at _timeCode_.
|
||||
///
|
||||
/// \snippetdoc snippets.dox GetCount
|
||||
/// \sa GetPointsAttr()
|
||||
USDGEOM_API
|
||||
size_t GetPointCount(UsdTimeCode timeCode = UsdTimeCode::Default()) const;
|
||||
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,858 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_PRIMVAR_H
|
||||
#define PXR_USD_USD_GEOM_PRIMVAR_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/attribute.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
/// \class UsdGeomPrimvar
|
||||
///
|
||||
/// Schema wrapper for UsdAttribute for authoring and introspecting attributes
|
||||
/// that are primvars.
|
||||
///
|
||||
/// UsdGeomPrimvar provides API for authoring and retrieving the
|
||||
/// additional data required to encode an attribute as a "Primvar",
|
||||
/// which is a convenient contraction of RenderMan's "Primitive Variable"
|
||||
/// concept, which is represented in Alembic as
|
||||
/// "arbitrary geometry parameters" (arbGeomParams).
|
||||
///
|
||||
/// This includes the attribute's \ref GetInterpolation() "interpolation"
|
||||
/// across the primitive (which RenderMan refers to as its
|
||||
/// \ref Usd_InterpolationVals "class specifier"
|
||||
/// and Alembic as its <A HREF="https://github.com/alembic/alembic/blob/master/lib/Alembic/AbcGeom/GeometryScope.h#L47"> "geometry scope"</A>);
|
||||
/// it also includes the attribute's \ref GetElementSize() "elementSize",
|
||||
/// which states how many values in the value array must be aggregated for
|
||||
/// each element on the primitive. An attribute's \ref
|
||||
/// UsdAttribute::GetTypeName() "TypeName" also factors into the encoding of
|
||||
/// Primvar.
|
||||
///
|
||||
/// \section Usd_What_Is_Primvar What is the Purpose of a Primvar?
|
||||
///
|
||||
/// There are three key aspects of Primvar identity:
|
||||
/// \li Primvars define a value that can vary across the primitive on which
|
||||
/// they are defined, via prescribed interpolation rules
|
||||
/// \li Taken collectively on a prim, its Primvars describe the "per-primitive
|
||||
/// overrides" to the material to which the prim is bound. Different
|
||||
/// renderers may communicate the variables to the shaders using different
|
||||
/// mechanisms over which Usd has no control; Primvars simply provide the
|
||||
/// classification that any renderer should use to locate potential
|
||||
/// overrides. Do please note that primvars override parameters on
|
||||
/// UsdShadeShader objects, \em not
|
||||
/// \ref UsdShadeNodeGraph_Interfaces "Interface Attributes" on UsdShadeMaterial
|
||||
/// prims.
|
||||
/// \li *Primvars inherit down scene namespace.* Regular USD attributes only
|
||||
/// apply to the prim on which they are specified, but primvars implicitly
|
||||
/// also apply to any child prims, unless those child prims have their
|
||||
/// own opinions about those primvars. This capability necessarily
|
||||
/// entails added cost to check for inherited values, but the benefit
|
||||
/// is that it allows concise encoding of certain opinions that broadly
|
||||
/// affect large amounts of geometry. See
|
||||
/// UsdGeomImageable::FindInheritedPrimvars().
|
||||
///
|
||||
/// \section Usd_Creating_and_Accessing_Primvars Creating and Accessing Primvars
|
||||
///
|
||||
/// The UsdGeomPrimvarsAPI schema provides a complete interface for creating
|
||||
/// and querying prims for primvars.
|
||||
///
|
||||
/// The <b>only</b> way to create a new Primvar in scene description is by
|
||||
/// calling UsdGeomPrimvarsAPI::CreatePrimvar(). One cannot "enhance" or
|
||||
/// "promote" an already existing attribute into a Primvar, because doing so
|
||||
/// may require a namespace edit to rename the attribute, which cannot, in
|
||||
/// general, be done within a single UsdEditContext. Instead, create a new
|
||||
/// UsdGeomPrimvar of the desired name using
|
||||
/// UsdGeomPrimvarsAPI::CreatePrimvar(), and then copy the existing attribute
|
||||
/// onto the new UsdGeomPrimvar.
|
||||
///
|
||||
/// Primvar names can contain arbitrary sub-namespaces. The behavior of
|
||||
/// UsdGeomImageable::GetPrimvar(TfToken const &name) is to prepend "primvars:"
|
||||
/// onto 'name' if it is not already a prefix, and return the result, which
|
||||
/// means we do not have any ambiguity between the primvars
|
||||
/// "primvars:nsA:foo" and "primvars:nsB:foo". <b>There are reserved keywords
|
||||
/// that may not be used as the base names of primvars,</b> and attempting to
|
||||
/// create Primvars of these names will result in a coding error. The
|
||||
/// reserved keywords are tokens the Primvar uses internally to encode various
|
||||
/// features, such as the "indices" keyword used by
|
||||
/// \ref UsdGeomPrimvar_Indexed_primvars "Indexed Primvars".
|
||||
///
|
||||
/// \anchor UsdGeomPrimvar_Using_Primvar
|
||||
/// If a client wishes to access an already-extant attribute as a Primvar,
|
||||
/// (which may or may not actually be valid Primvar), they can use the
|
||||
/// speculative constructor; typically, a primvar is only "interesting" if it
|
||||
/// additionally provides a value. This might look like:
|
||||
/// \code
|
||||
/// UsdGeomPrimvar primvar = UsdGeomPrimvar(usdAttr);
|
||||
/// if (primvar.HasValue()) {
|
||||
/// VtValue values;
|
||||
/// primvar.Get(&values, timeCode);
|
||||
/// TfToken interpolation = primvar.GetInterpolation();
|
||||
/// int elementSize = primvar.GetElementSize();
|
||||
/// ...
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// or, because Get() returns `true` if and only if it found a value:
|
||||
/// \code
|
||||
/// UsdGeomPrimvar primvar = UsdGeomPrimvar(usdAttr);
|
||||
/// VtValue values;
|
||||
/// if (primvar.Get(&values, timeCode)) {
|
||||
/// TfToken interpolation = primvar.GetInterpolation();
|
||||
/// int elementSize = primvar.GetElementSize();
|
||||
/// ...
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// \subsection Usd_Handling_Indexed_Primvars Proper Client Handling of "Indexed" Primvars
|
||||
///
|
||||
/// As discussed in greater detail in
|
||||
/// \ref UsdGeomPrimvar_Indexed_primvars "Indexed Primvars", primvars can
|
||||
/// optionally contain a (possibly time-varying) indexing attribute that
|
||||
/// establishes a sharing topology for elements of the primvar. Consumers
|
||||
/// can always chose to ignore the possibility of indexed data by exclusively
|
||||
/// using the ComputeFlattened() API. If a client wishes to preserve indexing
|
||||
/// in their processing of a primvar, we suggest a pattern like the following,
|
||||
/// which accounts for the fact that a stronger layer can
|
||||
/// \ref UsdAttribute::Block() "block" a primvar's indexing from a weaker
|
||||
/// layer, via UsdGeomPrimvar::BlockIndices():
|
||||
/// \code
|
||||
/// VtValue values;
|
||||
/// VtIntArray indices;
|
||||
///
|
||||
/// if (primvar.Get(&values, timeCode)){
|
||||
/// if (primvar.GetIndices(&indices, timeCode)){
|
||||
/// // primvar is indexed: validate/process values and indices together
|
||||
/// }
|
||||
/// else {
|
||||
/// // primvar is not indexed: validate/process values as flat array
|
||||
/// }
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// \subsection Usd_Primvar_As_Attribute UsdGeomPrimvar and UsdAttribute API
|
||||
///
|
||||
/// UsdGeomPrimvar presents a small slice of the UsdAttribute API - enough to
|
||||
/// extract the data that comprises the "Declaration info", and get/set of
|
||||
/// the attribute value. A UsdGeomPrimvar also auto-converts to UsdAttribute,
|
||||
/// so you can pass a UsdGeomPrimvar to any function that accepts a UsdAttribute
|
||||
/// or const-ref thereto.
|
||||
///
|
||||
/// \section Usd_Primvar_Types Primvar Allowed Scene Description Types and Plurality
|
||||
/// There are no limitations imposed on the allowable scene description types
|
||||
/// for Primvars; it is the responsibility of each consuming client to perform
|
||||
/// renderer-specific conversions, if need be (the USD distribution will include
|
||||
/// reference RenderMan conversion utilities).
|
||||
///
|
||||
/// A note about type plurality of Primvars: It is legitimate for a Primvar
|
||||
/// to be of scalar or array type, and again, consuming clients must be
|
||||
/// prepared to accommodate both. However, while it is not possible, in all
|
||||
/// cases, for USD to \em prevent one from \em changing the type of an attribute
|
||||
/// in different layers or variants of an asset, it is never a good idea to
|
||||
/// do so. This is relevant because, except in a few special cases, it is
|
||||
/// not possible to encode an \em interpolation of any value greater than
|
||||
/// \em constant without providing multiple (i.e. array) data values. Therefore,
|
||||
/// if there is any possibility that downstream clients might need to change
|
||||
/// a Primvar's interpolation, the Primvar-creator should encode it as an
|
||||
/// array rather than a scalar.
|
||||
///
|
||||
/// Why allow scalar values at all, then? First, sometimes it brings clarity
|
||||
/// to (use of) a shader's API to acknowledge that some parameters are meant
|
||||
/// to be single-valued over a shaded primitive. Second, many DCC's provide
|
||||
/// far richer affordances for editing scalars than they do array values, and
|
||||
/// we feel it is safer to let the content creator make the decision/tradeoff
|
||||
/// of which kind of flexibility is more relevant, rather than leaving it to
|
||||
/// an importer/exporter pair to interpret.
|
||||
///
|
||||
/// Also, like all attributes, Primvars can be time-sampled, and values can
|
||||
/// be authored and consumed just as any other attribute. There is currently
|
||||
/// no validation that the length of value arrays matches to the size
|
||||
/// required by a gprim's topology, interpolation, and elementSize.
|
||||
///
|
||||
/// For consumer convenience, we provide GetDeclarationInfo(), which returns
|
||||
/// all the type information (other than topology) needed to compute the
|
||||
/// required array size, which is also all the information required to
|
||||
/// prepare the Primvar's value for consumption by a renderer.
|
||||
///
|
||||
/// \section Usd_UsdGeomPrimvar_Lifetime Lifetime Management and Primvar Validity
|
||||
///
|
||||
/// UsdGeomPrimvar has an explicit bool operator that validates that
|
||||
/// the attribute IsDefined() and thus valid for querying and authoring
|
||||
/// values and metadata. This is a fairly expensive query that we do
|
||||
/// <b>not</b> cache, so if client code retains UsdGeomPrimvar objects, it should
|
||||
/// manage its object validity closely, for performance. An ideal pattern
|
||||
/// is to listen for UsdNotice::StageContentsChanged notifications, and
|
||||
/// revalidate/refetch its retained UsdGeomPrimvar s only then, and otherwise use
|
||||
/// them without validity checking.
|
||||
///
|
||||
/// \section Usd_InterpolationVals Interpolation of Geometric Primitive Variables
|
||||
/// In the following explanation of the meaning of the various kinds/levels
|
||||
/// of Primvar interpolation, each bolded bullet gives the name of the token
|
||||
/// in \ref UsdGeomTokens that provides the value. So to set a Primvar's
|
||||
/// interpolation to "varying", one would:
|
||||
/// \code
|
||||
/// primvar.SetInterpolation(UsdGeomTokens->varying);
|
||||
/// \endcode
|
||||
///
|
||||
/// Reprinted and adapted from <a HREF="http://renderman.pixar.com/resources/current/rps/appnote.22.html#classSpecifiers">
|
||||
/// the RPS documentation</a>, which contains further details, \em interpolation
|
||||
/// describes how the Primvar will be interpolated over the uv parameter
|
||||
/// space of a surface primitive (or curve or pointcloud). The possible
|
||||
/// values are:
|
||||
/// \li <b>constant</b> One value remains constant over the entire surface
|
||||
/// primitive.
|
||||
/// \li <b>uniform</b> One value remains constant for each uv patch segment of
|
||||
/// the surface primitive (which is a \em face for meshes).
|
||||
/// \li <b>varying</b> Four values are interpolated over each uv patch segment
|
||||
/// of the surface. Bilinear interpolation is used for interpolation
|
||||
/// between the four values.
|
||||
/// \li <b>vertex</b> Values are interpolated between each vertex in the
|
||||
/// surface primitive. The basis function of the surface is used for
|
||||
/// interpolation between vertices.
|
||||
/// \li <b>faceVarying</b> For polygons and subdivision surfaces, four values
|
||||
/// are interpolated over each face of the mesh. Bilinear interpolation
|
||||
/// is used for interpolation between the four values.
|
||||
///
|
||||
/// \section Usd_Extending_UsdObject_Classes UsdGeomPrimvar As Example of Attribute Schema
|
||||
///
|
||||
/// Just as UsdSchemaBase and its subclasses provide the pattern for how to
|
||||
/// layer schema onto the generic UsdPrim object, UsdGeomPrimvar provides an
|
||||
/// example of how to layer schema onto a generic UsdAttribute object. In both
|
||||
/// cases, the schema object wraps and contains the UsdObject.
|
||||
///
|
||||
/// \section Usd_UsdGeomPrimvar_Inheritance Primvar Namespace Inheritance
|
||||
///
|
||||
/// Constant interpolation primvar values can be inherited down namespace.
|
||||
/// That is, a primvar value set on a prim will also apply to any child
|
||||
/// prims, unless those children have their own opinions about those named
|
||||
/// primvars. For complete details on how primvars inherit, see
|
||||
/// \ref usdGeom_PrimvarInheritance .
|
||||
///
|
||||
/// \sa UsdGeomImageable::FindInheritablePrimvars().
|
||||
///
|
||||
class UsdGeomPrimvar
|
||||
{
|
||||
public:
|
||||
|
||||
// Default constructor returns an invalid Primvar. Exists for
|
||||
// container classes
|
||||
UsdGeomPrimvar()
|
||||
{
|
||||
/* NOTHING */
|
||||
}
|
||||
|
||||
/// Speculative constructor that will produce a valid UsdGeomPrimvar when
|
||||
/// \p attr already represents an attribute that is Primvar, and
|
||||
/// produces an \em invalid Primvar otherwise (i.e.
|
||||
/// \ref UsdGeomPrimvar_bool "operator bool()" will return false).
|
||||
///
|
||||
/// Calling \c UsdGeomPrimvar::IsPrimvar(attr) will return the same truth
|
||||
/// value as this constructor, but if you plan to subsequently use the
|
||||
/// Primvar anyways, just use this constructor, as demonstrated in the
|
||||
/// \ref UsdGeomPrimvar_Using_Primvar "class documentation".
|
||||
USDGEOM_API
|
||||
explicit UsdGeomPrimvar(const UsdAttribute &attr);
|
||||
|
||||
/// Return the Primvar's interpolation, which is
|
||||
/// \ref Usd_InterpolationVals "UsdGeomTokens->constant" if unauthored
|
||||
///
|
||||
/// Interpolation determines how the Primvar interpolates over
|
||||
/// a geometric primitive. See \ref Usd_InterpolationVals
|
||||
USDGEOM_API
|
||||
TfToken GetInterpolation() const;
|
||||
|
||||
/// Set the Primvar's interpolation.
|
||||
///
|
||||
/// Errors and returns false if \p interpolation is out of range as
|
||||
/// defined by IsValidInterpolation(). No attempt is made to validate
|
||||
/// that the Primvar's value contains the right number of elements
|
||||
/// to match its interpolation to its topology.
|
||||
///
|
||||
/// \sa GetInterpolation(), \ref Usd_InterpolationVals
|
||||
USDGEOM_API
|
||||
bool SetInterpolation(const TfToken &interpolation);
|
||||
|
||||
/// Has interpolation been explicitly authored on this Primvar?
|
||||
///
|
||||
/// \sa GetInterpolationSize()
|
||||
USDGEOM_API
|
||||
bool HasAuthoredInterpolation() const;
|
||||
|
||||
/// Return the "element size" for this Primvar, which is 1 if
|
||||
/// unauthored. If this Primvar's type is \em not an array type,
|
||||
/// (e.g. "Vec3f[]"), then elementSize is irrelevant.
|
||||
///
|
||||
/// ElementSize does \em not generally encode the length of an array-type
|
||||
/// primvar, and rarely needs to be authored. ElementSize can be thought
|
||||
/// of as a way to create an "aggregate interpolatable type", by
|
||||
/// dictating how many consecutive elements in the value array should be
|
||||
/// taken as an atomic element to be interpolated over a gprim.
|
||||
///
|
||||
/// For example, spherical harmonics are often represented as a
|
||||
/// collection of nine floating-point coefficients, and the coefficients
|
||||
/// need to be sampled across a gprim's surface: a perfect case for
|
||||
/// primvars. However, USD has no <tt>float9</tt> datatype. But we can
|
||||
/// communicate the aggregation of nine floats successfully to renderers
|
||||
/// by declaring a simple float-array valued primvar, and setting its
|
||||
/// \em elementSize to 9. To author a \em uniform spherical harmonic
|
||||
/// primvar on a Mesh of 42 faces, the primvar's array value would contain
|
||||
/// 9*42 = 378 float elements.
|
||||
USDGEOM_API
|
||||
int GetElementSize() const;
|
||||
|
||||
/// Set the elementSize for this Primvar.
|
||||
///
|
||||
/// Errors and returns false if \p eltSize less than 1.
|
||||
///
|
||||
/// \sa GetElementSize()
|
||||
USDGEOM_API
|
||||
bool SetElementSize(int eltSize);
|
||||
|
||||
/// Has elementSize been explicitly authored on this Primvar?
|
||||
///
|
||||
/// \sa GetElementSize()
|
||||
USDGEOM_API
|
||||
bool HasAuthoredElementSize() const;
|
||||
|
||||
|
||||
/// Test whether a given UsdAttribute represents valid Primvar, which
|
||||
/// implies that creating a UsdGeomPrimvar from the attribute will succeed.
|
||||
///
|
||||
/// Success implies that \c attr.IsDefined() is true.
|
||||
USDGEOM_API
|
||||
static bool IsPrimvar(const UsdAttribute &attr);
|
||||
|
||||
|
||||
/// Test whether a given \p name represents a valid name of a primvar,
|
||||
/// which implies that creating a UsdGeomPrimvar with the given name will
|
||||
/// succeed.
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool IsValidPrimvarName(const TfToken& name);
|
||||
|
||||
/// Returns the \p name, devoid of the "primvars:" token if present,
|
||||
/// otherwise returns the \p name unchanged
|
||||
USDGEOM_API
|
||||
static TfToken StripPrimvarsName(const TfToken& name);
|
||||
|
||||
/// Validate that the provided \p interpolation is a valid setting for
|
||||
/// interpolation as defined by \ref Usd_InterpolationVals.
|
||||
USDGEOM_API
|
||||
static bool IsValidInterpolation(const TfToken &interpolation);
|
||||
|
||||
/// Convenience function for fetching all information required to
|
||||
/// properly declare this Primvar. The \p name returned is the
|
||||
/// "client name", stripped of the "primvars" namespace, i.e. equivalent to
|
||||
/// GetPrimvarName()
|
||||
///
|
||||
/// May also be more efficient than querying key individually.
|
||||
USDGEOM_API
|
||||
void GetDeclarationInfo(TfToken *name, SdfValueTypeName *typeName,
|
||||
TfToken *interpolation, int *elementSize) const;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/// \name UsdAttribute API
|
||||
// ---------------------------------------------------------------
|
||||
/// @{
|
||||
|
||||
/// Allow UsdGeomPrimvar to auto-convert to UsdAttribute, so you can
|
||||
/// pass a UsdGeomPrimvar to any function that accepts a UsdAttribute or
|
||||
/// const-ref thereto.
|
||||
operator UsdAttribute const& () const { return _attr; }
|
||||
|
||||
/// Explicit UsdAttribute extractor
|
||||
UsdAttribute const &GetAttr() const { return _attr; }
|
||||
|
||||
/// Return true if the underlying UsdAttribute::IsDefined(), and in
|
||||
/// addition the attribute is identified as a Primvar. Does not imply
|
||||
/// that the primvar provides a value
|
||||
bool IsDefined() const { return IsPrimvar(_attr); }
|
||||
|
||||
/// Return true if the underlying attribute has a value, either from
|
||||
/// authored scene description or a fallback.
|
||||
bool HasValue() const { return _attr.HasValue(); }
|
||||
|
||||
/// Return true if the underlying attribute has an unblocked, authored
|
||||
/// value.
|
||||
bool HasAuthoredValue() const { return _attr.HasAuthoredValue(); }
|
||||
|
||||
/// \anchor UsdGeomPrimvar_bool
|
||||
/// Return true if this Primvar is valid for querying and authoring
|
||||
/// values and metadata, which is identically equivalent to IsDefined().
|
||||
explicit operator bool() const {
|
||||
return IsDefined() ? &UsdGeomPrimvar::_attr : 0;
|
||||
}
|
||||
|
||||
/// \sa UsdAttribute::GetName()
|
||||
TfToken const &GetName() const { return _attr.GetName(); }
|
||||
|
||||
/// Returns the primvar's name, devoid of the "primvars:" namespace.
|
||||
/// This is the name by which clients should refer to the primvar, if
|
||||
/// not by its full attribute name - i.e. they should **not**, in general,
|
||||
/// use GetBaseName(). In the error condition in which this Primvar
|
||||
/// object is not backed by a properly namespaced UsdAttribute, return
|
||||
/// an empty TfToken.
|
||||
USDGEOM_API
|
||||
TfToken GetPrimvarName() const;
|
||||
|
||||
/// Does this primvar contain any namespaces other than the "primvars:"
|
||||
/// namespace?
|
||||
///
|
||||
/// Some clients may only wish to consume primvars that have no extra
|
||||
/// namespaces in their names, for ease of translating to other systems
|
||||
/// that do not allow namespaces.
|
||||
USDGEOM_API
|
||||
bool NameContainsNamespaces() const;
|
||||
|
||||
/// \sa UsdAttribute::GetBaseName()
|
||||
TfToken GetBaseName() const { return _attr.GetBaseName(); }
|
||||
|
||||
/// \sa UsdAttribute::GetNamespace()
|
||||
TfToken GetNamespace() const { return _attr.GetNamespace(); }
|
||||
|
||||
/// \sa UsdAttribute::SplitName()
|
||||
std::vector<std::string> SplitName() const { return _attr.SplitName(); };
|
||||
|
||||
/// \sa UsdAttribute::GetTypeName()
|
||||
SdfValueTypeName GetTypeName() const { return _attr.GetTypeName(); }
|
||||
|
||||
/// Get the attribute value of the Primvar at \p time .
|
||||
///
|
||||
/// \sa Usd_Handling_Indexed_Primvars for proper handling of
|
||||
/// \ref Usd_Handling_Indexed_Primvars "indexed primvars"
|
||||
template <typename T>
|
||||
bool Get(T* value, UsdTimeCode time = UsdTimeCode::Default()) const {
|
||||
return _attr.Get(value, time);
|
||||
}
|
||||
|
||||
/// Set the attribute value of the Primvar at \p time
|
||||
template <typename T>
|
||||
bool Set(const T& value, UsdTimeCode time = UsdTimeCode::Default()) const {
|
||||
return _attr.Set(value, time);
|
||||
}
|
||||
|
||||
/// Populates a vector with authored sample times for this primvar.
|
||||
/// Returns false on error.
|
||||
///
|
||||
/// This considers any timeSamples authored on the associated "indices"
|
||||
/// attribute if the primvar is indexed.
|
||||
///
|
||||
/// \sa UsdAttribute::GetTimeSamples
|
||||
USDGEOM_API
|
||||
bool GetTimeSamples(std::vector<double>* times) const;
|
||||
|
||||
/// Populates a vector with authored sample times in \p interval.
|
||||
///
|
||||
/// This considers any timeSamples authored on the associated "indices"
|
||||
/// attribute if the primvar is indexed.
|
||||
///
|
||||
/// \sa UsdAttribute::GetTimeSamplesInInterval
|
||||
USDGEOM_API
|
||||
bool GetTimeSamplesInInterval(const GfInterval& interval,
|
||||
std::vector<double>* times) const;
|
||||
|
||||
/// Return true if it is possible, but not certain, that this primvar's
|
||||
/// value changes over time, false otherwise.
|
||||
///
|
||||
/// This considers time-varyingness of the associated "indices" attribute
|
||||
/// if the primvar is indexed.
|
||||
///
|
||||
/// \sa UsdAttribute::ValueMightBeTimeVarying
|
||||
USDGEOM_API
|
||||
bool ValueMightBeTimeVarying() const;
|
||||
|
||||
/// @}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/// @{
|
||||
/// \anchor UsdGeomPrimvar_Indexed_primvars
|
||||
/// \name Indexed primvars API
|
||||
///
|
||||
/// For non-constant values of interpolation, it is often the case that the
|
||||
/// same value is repeated many times in the array value of a primvar. An
|
||||
/// indexed primvar can be used in such cases to optimize for data storage
|
||||
/// if the primvar's interpolation is uniform, varying, or vertex.
|
||||
/// For **faceVarying primvars,** however, indexing serves a higher
|
||||
/// purpose (and should be used *only* for this purpose, since renderers
|
||||
/// and OpenSubdiv will assume it) of establishing a surface topology
|
||||
/// for the primvar. That is, faveVarying primvars use indexing to
|
||||
/// unambiguously define discontinuities in their functions at edges
|
||||
/// and vertices. Please see the <a href="http://graphics.pixar.com/opensubdiv/docs/subdivision_surfaces.html#face-varying-interpolation-rules">
|
||||
/// OpenSubdiv documentation on FaceVarying Primvars</a> for more
|
||||
/// information.
|
||||
///
|
||||
/// To create an indexed primvar, the value of the attribute associated with
|
||||
/// the primvar is set to an array consisting of all the unique values that
|
||||
/// appear in the primvar array. A separate namespaced "indices" attribute
|
||||
/// is set to an integer array containing indices into the array with all
|
||||
/// the unique elements. The final value of the primvar is computed using
|
||||
/// the indices array and the attribute value array.
|
||||
///
|
||||
/// See also \ref Usd_Handling_Indexed_Primvars
|
||||
|
||||
/// Sets the indices value of the indexed primvar at \p time.
|
||||
///
|
||||
/// The values in the indices array must be valid indices into the authored
|
||||
/// array returned by Get(). The element numerality of the primvar's
|
||||
/// 'interpolation' metadata applies to the "indices" array, not the attribute
|
||||
/// value array (returned by Get()).
|
||||
USDGEOM_API
|
||||
bool SetIndices(const VtIntArray &indices,
|
||||
UsdTimeCode time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// Returns the value of the indices array associated with the indexed
|
||||
/// primvar at \p time.
|
||||
///
|
||||
/// \sa SetIndices(), \ref Usd_Handling_Indexed_Primvars
|
||||
USDGEOM_API
|
||||
bool GetIndices(VtIntArray *indices,
|
||||
UsdTimeCode time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// Block the indices that were previously set. This effectively makes an
|
||||
/// indexed primvar no longer indexed. This is useful when overriding an
|
||||
/// existing primvar.
|
||||
USDGEOM_API
|
||||
void BlockIndices() const;
|
||||
|
||||
/// Returns true if the primvar is indexed, i.e., if it has an associated
|
||||
/// "indices" attribute.
|
||||
///
|
||||
/// If you are going to query the indices anyways, prefer to simply
|
||||
/// consult the return-value of GetIndices(), which will be more efficient.
|
||||
USDGEOM_API
|
||||
bool IsIndexed() const;
|
||||
|
||||
/// Returns a valid indices attribute if the primvar is indexed. Returns
|
||||
/// an invalid attribute otherwise.
|
||||
USDGEOM_API
|
||||
UsdAttribute GetIndicesAttr() const;
|
||||
|
||||
/// Returns the existing indices attribute if the primvar is indexed
|
||||
/// or creates a new one.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateIndicesAttr() const;
|
||||
|
||||
/// Set the index that represents unauthored values in the indices array.
|
||||
///
|
||||
/// Some apps (like Maya) allow you to author primvars sparsely over a
|
||||
/// surface. Since most apps can't handle sparse primvars, Maya needs to
|
||||
/// provide a value even for the elements it didn't author. This metadatum
|
||||
/// provides a way to recover the information in apps that do support
|
||||
/// sparse authoring / representation of primvars.
|
||||
///
|
||||
/// The fallback value of unauthoredValuesIndex is -1, which indicates that
|
||||
/// there are no unauthored values.
|
||||
///
|
||||
/// \sa GetUnauthoredValuesIndex()
|
||||
USDGEOM_API
|
||||
bool SetUnauthoredValuesIndex(int unauthoredValuesIndex) const;
|
||||
|
||||
/// Returns the index that represents unauthored values in the indices array.
|
||||
///
|
||||
/// \sa SetUnauthoredValuesIndex()
|
||||
USDGEOM_API
|
||||
int GetUnauthoredValuesIndex() const;
|
||||
|
||||
/// Computes the flattened value of the primvar at \p time.
|
||||
///
|
||||
/// If the primvar is not indexed or if the value type of this primvar is
|
||||
/// a scalar, this returns the authored value, which is the same as
|
||||
/// \ref Get(). Hence, it's safe to call ComputeFlattened() on non-indexed
|
||||
/// primvars.
|
||||
template <typename ScalarType>
|
||||
bool ComputeFlattened(VtArray<ScalarType> * value,
|
||||
UsdTimeCode time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// \overload
|
||||
/// Computes the flattened value of the primvar at \p time as a VtValue.
|
||||
///
|
||||
/// If the primvar is not indexed or if the value type of this primvar is
|
||||
/// a scalar, this returns the authored value, which is the same as
|
||||
/// \ref Get(). Hence, it's safe to call ComputeFlattened() on non-indexed
|
||||
/// primvars.
|
||||
USDGEOM_API
|
||||
bool ComputeFlattened(VtValue *value,
|
||||
UsdTimeCode time=UsdTimeCode::Default()) const;
|
||||
|
||||
/// Computes the flattened value of \p attrValue given \p indices.
|
||||
///
|
||||
/// This method is a static convenience function that performs the main
|
||||
/// work of ComputeFlattened above without needing an instance of a
|
||||
/// UsdGeomPrimvar.
|
||||
///
|
||||
/// Returns \c false if the value contained in \p attrVal is not a supported
|
||||
/// type for flattening. Otherwise returns \c true. The output
|
||||
/// \p errString variable may be populated with an error string if an error
|
||||
/// is encountered during flattening.
|
||||
USDGEOM_API
|
||||
static bool ComputeFlattened(VtValue *value, const VtValue &attrVal,
|
||||
const VtIntArray &indices,
|
||||
std::string *errString);
|
||||
|
||||
|
||||
/// @}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/// @{
|
||||
/// \anchor UsdGeomPrimvar_Id_primvars
|
||||
/// \name Id attribute API
|
||||
///
|
||||
/// Often there is the need to identify a prim within a scene (e.g. a mesh
|
||||
/// on which a procedural should operate, or a shader to inherit). A
|
||||
/// string or string[] -typed primvar can be turned into an "Id Path" primvar by
|
||||
/// calling SetIdTarget() with the path of any object on the current stage. When
|
||||
/// the primvar is subsequently queried via Get(), the returned value will
|
||||
/// be the stringified value of the targeted object's path in whatever
|
||||
/// namespace is defined by the querying stage's root layer. In other
|
||||
/// words, authoring an Id primvar into a published model will return the
|
||||
/// path-to-target in the model, but when the model is referenced into a
|
||||
/// larger scene, it will return the complete scene path.
|
||||
///
|
||||
/// This works by adding a paired UsdRelationship in a ":idFrom" namespace
|
||||
/// "below" the string primvar. Get() evaluates
|
||||
/// UsdRelationship::GetForwardedTargets() to determine the id-string.
|
||||
/// Thus, this mechanism will always produce a unique identifier for every
|
||||
/// object in a scene, regardless of how many times an asset is referenced
|
||||
/// into a scene. Providing a mesh with a unique identifier primvar can be
|
||||
/// especially useful for renderers that allow plugins/shaders access to
|
||||
/// processed scene data based on user-provided string identifiers.
|
||||
///
|
||||
/// If an Id primvar has both an \em authored string value and a SetIdTarget()'d
|
||||
/// target, the target path takes precedence.
|
||||
///
|
||||
/// Currently Id primvars can have only a single target, so the only useful
|
||||
/// interpolation is constant.
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/// Returns true if the primvar is an Id primvar.
|
||||
///
|
||||
/// \sa \ref UsdGeomPrimvar_Id_primvars
|
||||
USDGEOM_API
|
||||
bool IsIdTarget() const;
|
||||
|
||||
/// This primvar must be of String or StringArray type for this method to
|
||||
/// succeed. If not, a coding error is raised.
|
||||
///
|
||||
/// \sa \ref UsdGeomPrimvar_Id_primvars
|
||||
USDGEOM_API
|
||||
bool SetIdTarget(const SdfPath& path) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// Equality comparison. Return true if \a lhs and \a rhs represent the
|
||||
/// same UsdGeomPrimvar, false otherwise.
|
||||
friend bool operator==(const UsdGeomPrimvar &lhs, const UsdGeomPrimvar &rhs) {
|
||||
return lhs.GetAttr() == rhs.GetAttr();
|
||||
}
|
||||
|
||||
/// Inequality comparison. Return false if \a lhs and \a rhs represent the
|
||||
/// same UsdPrimvar, true otherwise.
|
||||
friend bool operator!=(const UsdGeomPrimvar &lhs, const UsdGeomPrimvar &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/// Less-than operator. Returns true if \a lhs < \a rhs.
|
||||
///
|
||||
/// This simply compares the paths of the underlyingattributes.
|
||||
friend bool operator<(const UsdGeomPrimvar &lhs, const UsdGeomPrimvar &rhs) {
|
||||
return lhs.GetAttr().GetPath() < rhs.GetAttr().GetPath();
|
||||
}
|
||||
|
||||
// hash_value overload for std/boost hash.
|
||||
USDGEOM_API
|
||||
friend size_t hash_value(const UsdGeomPrimvar &obj) {
|
||||
return hash_value(obj.GetAttr());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
friend class UsdGeomImageable;
|
||||
friend class UsdGeomPrimvarsAPI;
|
||||
|
||||
/// Validate that the given \p name contains the primvars namespace.
|
||||
/// Does not validate name as a legal property identifier
|
||||
static bool _IsNamespaced(const TfToken& name);
|
||||
|
||||
/// Return \p name prepended with the proper primvars namespace, if
|
||||
/// it is not already prefixed.
|
||||
///
|
||||
/// Does not validate name as a legal property identifier, but will
|
||||
/// verify that \p name contains no reserved keywords, and will return
|
||||
/// an empty TfToken if it does. If \p quiet is true, the verification
|
||||
/// will be silent
|
||||
static TfToken _MakeNamespaced(const TfToken& name, bool quiet=false);
|
||||
|
||||
static TfToken const &_GetNamespacePrefix();
|
||||
|
||||
/// Factory for UsdGeomImageable's use, so that we can encapsulate the
|
||||
/// logic of what discriminates Primvar in this class, while
|
||||
/// preserving the pattern that attributes can only be created
|
||||
/// via their container objects.
|
||||
///
|
||||
/// The name of the created attribute may or may not be the specified
|
||||
/// \p attrName, due to the possible need to apply property namespacing
|
||||
/// for Primvar.
|
||||
///
|
||||
/// The behavior with respect to the provided \p typeName
|
||||
/// is the same as for UsdAttributes::Create().
|
||||
///
|
||||
/// \return an invalid UsdGeomPrimvar if we failed to create a valid
|
||||
/// attribute, a valid UsdGeomPrimvar otherwise. It is not an
|
||||
/// error to create over an existing, compatible attribute.
|
||||
///
|
||||
/// It is a failed verification for \p prim to be invalid/expired
|
||||
///
|
||||
/// \sa UsdPrim::CreateAttribute()
|
||||
UsdGeomPrimvar(const UsdPrim& prim, const TfToken& attrName,
|
||||
const SdfValueTypeName &typeName);
|
||||
|
||||
UsdAttribute _attr;
|
||||
|
||||
// upon construction, we'll take note of the attrType. If we're a type
|
||||
// that could possibly have an Id associated with it, we'll store that name
|
||||
// so we don't have to pay the cost of constructing that token per-Get().
|
||||
void _SetIdTargetRelName();
|
||||
|
||||
// Gets or creates the indices attribute corresponding to the primvar.
|
||||
UsdAttribute _GetIndicesAttr(bool create) const;
|
||||
|
||||
// Helper method for computing the flattened value of an indexed primvar.
|
||||
template<typename ScalarType>
|
||||
static bool _ComputeFlattenedHelper(const VtArray<ScalarType> &authored,
|
||||
const VtIntArray &indices,
|
||||
VtArray<ScalarType> *value,
|
||||
std::string *errString);
|
||||
|
||||
// Helper function to evaluate the flattened array value of a primvar given
|
||||
// the attribute value and the indices array.
|
||||
template <typename ArrayType>
|
||||
static bool _ComputeFlattenedArray(const VtValue &attrVal,
|
||||
const VtIntArray &indices,
|
||||
VtValue *value,
|
||||
std::string *errString);
|
||||
|
||||
// Should only be called if _idTargetRelName is set
|
||||
UsdRelationship _GetIdTargetRel(bool create) const;
|
||||
TfToken _idTargetRelName;
|
||||
};
|
||||
|
||||
// We instantiate the following so we can check and provide the correct value
|
||||
// for Id attributes.
|
||||
template <>
|
||||
USDGEOM_API bool UsdGeomPrimvar::Get(std::string* value, UsdTimeCode time) const;
|
||||
|
||||
template <>
|
||||
USDGEOM_API bool UsdGeomPrimvar::Get(VtStringArray* value, UsdTimeCode time) const;
|
||||
|
||||
template <>
|
||||
USDGEOM_API bool UsdGeomPrimvar::Get(VtValue* value, UsdTimeCode time) const;
|
||||
|
||||
template <typename ScalarType>
|
||||
bool
|
||||
UsdGeomPrimvar::ComputeFlattened(VtArray<ScalarType> *value, UsdTimeCode time) const
|
||||
{
|
||||
VtArray<ScalarType> authored;
|
||||
if (!Get(&authored, time))
|
||||
return false;
|
||||
|
||||
if (!IsIndexed()) {
|
||||
*value = authored;
|
||||
return true;
|
||||
}
|
||||
|
||||
VtIntArray indices;
|
||||
if (!GetIndices(&indices, time)) {
|
||||
TF_WARN("No indices authored for indexed primvar <%s>.",
|
||||
_attr.GetPath().GetText());
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the authored array is empty, there's nothing to do.
|
||||
if (authored.empty())
|
||||
return false;
|
||||
|
||||
std::string errString;
|
||||
bool res = _ComputeFlattenedHelper(authored, indices, value, &errString);
|
||||
if (!errString.empty()) {
|
||||
TF_WARN("For primvar %s: %s",
|
||||
UsdDescribe(_attr).c_str(), errString.c_str());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename ScalarType>
|
||||
bool
|
||||
UsdGeomPrimvar::_ComputeFlattenedHelper(const VtArray<ScalarType> &authored,
|
||||
const VtIntArray &indices,
|
||||
VtArray<ScalarType> *value,
|
||||
std::string *errString)
|
||||
{
|
||||
value->resize(indices.size());
|
||||
bool success = true;
|
||||
|
||||
std::vector<size_t> invalidIndexPositions;
|
||||
for (size_t i=0; i < indices.size(); i++) {
|
||||
int index = indices[i];
|
||||
if (index >= 0 && (size_t)index < authored.size()) {
|
||||
(*value)[i] = authored[index];
|
||||
} else {
|
||||
invalidIndexPositions.push_back(i);
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!invalidIndexPositions.empty()) {
|
||||
std::vector<std::string> invalidPositionsStrVec;
|
||||
// Print a maximum of 5 invalid index positions.
|
||||
size_t numElementsToPrint = std::min(invalidIndexPositions.size(),
|
||||
size_t(5));
|
||||
invalidPositionsStrVec.reserve(numElementsToPrint);
|
||||
for (size_t i = 0; i < numElementsToPrint ; ++i) {
|
||||
invalidPositionsStrVec.push_back(
|
||||
TfStringify(invalidIndexPositions[i]));
|
||||
}
|
||||
|
||||
if (errString) {
|
||||
*errString = TfStringPrintf(
|
||||
"Found %ld invalid indices at positions [%s%s] that are out of "
|
||||
"range [0,%ld).", invalidIndexPositions.size(),
|
||||
TfStringJoin(invalidPositionsStrVec, ", ").c_str(),
|
||||
invalidIndexPositions.size() > 5 ? ", ..." : "",
|
||||
authored.size());
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // USD_PRIMVAR_H
|
||||
@@ -0,0 +1,457 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_PRIMVARSAPI_H
|
||||
#define USDGEOM_GENERATED_PRIMVARSAPI_H
|
||||
|
||||
/// \file usdGeom/primvarsAPI.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/apiSchemaBase.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
|
||||
#include "pxr/usd/usdGeom/primvar.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// PRIMVARSAPI //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomPrimvarsAPI
|
||||
///
|
||||
/// UsdGeomPrimvarsAPI encodes geometric "primitive variables",
|
||||
/// as UsdGeomPrimvar, which interpolate across a primitive's topology,
|
||||
/// can override shader inputs, and inherit down namespace.
|
||||
///
|
||||
/// \section usdGeom_PrimvarFetchingAPI Which Method to Use to Retrieve Primvars
|
||||
///
|
||||
/// While creating primvars is unambiguous (CreatePrimvar()), there are quite
|
||||
/// a few methods available for retrieving primvars, making it potentially
|
||||
/// confusing knowing which one to use. Here are some guidelines:
|
||||
///
|
||||
/// \li If you are populating a GUI with the primvars already available for
|
||||
/// authoring values on a prim, use GetPrimvars().
|
||||
/// \li If you want all of the "useful" (e.g. to a renderer) primvars
|
||||
/// available at a prim, including those inherited from ancestor prims, use
|
||||
/// FindPrimvarsWithInheritance(). Note that doing so individually for many
|
||||
/// prims will be inefficient.
|
||||
/// \li To find a particular primvar defined directly on a prim, which may
|
||||
/// or may not provide a value, use GetPrimvar().
|
||||
/// \li To find a particular primvar defined on a prim or inherited from
|
||||
/// ancestors, which may or may not provide a value, use
|
||||
/// FindPrimvarWithInheritance().
|
||||
/// \li To *efficiently* query for primvars using the overloads of
|
||||
/// FindPrimvarWithInheritance() and FindPrimvarsWithInheritance(), one
|
||||
/// must first cache the results of FindIncrementallyInheritablePrimvars() for
|
||||
/// each non-leaf prim on the stage.
|
||||
///
|
||||
class UsdGeomPrimvarsAPI : public UsdAPISchemaBase
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI;
|
||||
|
||||
/// Construct a UsdGeomPrimvarsAPI on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomPrimvarsAPI::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomPrimvarsAPI(const UsdPrim& prim=UsdPrim())
|
||||
: UsdAPISchemaBase(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomPrimvarsAPI on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomPrimvarsAPI(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomPrimvarsAPI(const UsdSchemaBase& schemaObj)
|
||||
: UsdAPISchemaBase(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomPrimvarsAPI();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomPrimvarsAPI holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomPrimvarsAPI(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomPrimvarsAPI
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Author scene description to create an attribute on this prim that
|
||||
/// will be recognized as Primvar (i.e. will present as a valid
|
||||
/// UsdGeomPrimvar).
|
||||
///
|
||||
/// The name of the created attribute may or may not be the specified
|
||||
/// \p name, due to the possible need to apply property namespacing
|
||||
/// for primvars. See \ref Usd_Creating_and_Accessing_Primvars
|
||||
/// for more information. Creation may fail and return an invalid
|
||||
/// Primvar if \p name contains a reserved keyword, such as the
|
||||
/// "indices" suffix we use for indexed primvars.
|
||||
///
|
||||
/// The behavior with respect to the provided \p typeName
|
||||
/// is the same as for UsdAttributes::Create(), and
|
||||
/// \p interpolation and \p elementSize are as described in
|
||||
/// UsdGeomPrimvar::GetInterpolation() and UsdGeomPrimvar::GetElementSize().
|
||||
///
|
||||
/// If \p interpolation and/or \p elementSize are left unspecified, we
|
||||
/// will author no opinions for them, which means any (strongest) opinion
|
||||
/// already authored in any contributing layer for these fields will
|
||||
/// become the Primvar's values, or the fallbacks if no opinions
|
||||
/// have been authored.
|
||||
///
|
||||
/// \return an invalid UsdGeomPrimvar if we failed to create a valid
|
||||
/// attribute, a valid UsdGeomPrimvar otherwise. It is not an
|
||||
/// error to create over an existing, compatible attribute.
|
||||
///
|
||||
/// \sa UsdPrim::CreateAttribute(), UsdGeomPrimvar::IsPrimvar()
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar CreatePrimvar(const TfToken& name,
|
||||
const SdfValueTypeName &typeName,
|
||||
const TfToken& interpolation = TfToken(),
|
||||
int elementSize = -1) const;
|
||||
|
||||
/// Author scene description to create an attribute and authoring a \p value
|
||||
/// on this prim that will be recognized as a Primvar (i.e. will present as
|
||||
/// a valid UsdGeomPrimvar). Note that unlike CreatePrimvar using this API
|
||||
/// explicitly authors a block for the indices attr associated with the
|
||||
/// primvar, thereby blocking any indices set in any weaker layers.
|
||||
///
|
||||
/// \return an invalid UsdGeomPrimvar on error, a valid UsdGeomPrimvar
|
||||
/// otherwise. It is fine to call this method multiple times, and in
|
||||
/// different UsdEditTargets, even if there is an existing primvar of the
|
||||
/// same name, indexed or not.
|
||||
///
|
||||
/// \sa CreatePrimvar(), CreateIndexedPrimvar(), UsdPrim::CreateAttribute(),
|
||||
/// UsdGeomPrimvar::IsPrimvar()
|
||||
template <typename T>
|
||||
UsdGeomPrimvar CreateNonIndexedPrimvar(
|
||||
const TfToken& name,
|
||||
const SdfValueTypeName &typeName,
|
||||
const T &value,
|
||||
const TfToken &interpolation = TfToken(),
|
||||
int elementSize = -1,
|
||||
UsdTimeCode time = UsdTimeCode::Default()) const
|
||||
{
|
||||
UsdGeomPrimvar primvar =
|
||||
CreatePrimvar(name, typeName, interpolation, elementSize);
|
||||
|
||||
primvar.GetAttr().Set(value, time);
|
||||
primvar.BlockIndices();
|
||||
return primvar;
|
||||
}
|
||||
|
||||
/// Author scene description to create an attribute and authoring a \p value
|
||||
/// on this prim that will be recognized as an indexed Primvar with \p
|
||||
/// indices appropriately set (i.e. will present as a valid UsdGeomPrimvar).
|
||||
///
|
||||
/// \return an invalid UsdGeomPrimvar on error, a valid UsdGeomPrimvar
|
||||
/// otherwise. It is fine to call this method multiple times, and in
|
||||
/// different UsdEditTargets, even if there is an existing primvar of the
|
||||
/// same name, indexed or not.
|
||||
///
|
||||
/// \sa CreatePrimvar(), CreateNonIndexedPrimvar(),
|
||||
/// UsdPrim::CreateAttribute(), UsdGeomPrimvar::IsPrimvar()
|
||||
template <typename T>
|
||||
UsdGeomPrimvar CreateIndexedPrimvar(
|
||||
const TfToken& name,
|
||||
const SdfValueTypeName &typeName,
|
||||
const T &value,
|
||||
const VtIntArray &indices,
|
||||
const TfToken &interpolation = TfToken(),
|
||||
int elementSize = -1,
|
||||
UsdTimeCode time = UsdTimeCode::Default()) const
|
||||
{
|
||||
UsdGeomPrimvar primvar =
|
||||
CreatePrimvar(name, typeName, interpolation, elementSize);
|
||||
|
||||
primvar.GetAttr().Set(value, time);
|
||||
primvar.SetIndices(indices, time);
|
||||
return primvar;
|
||||
}
|
||||
|
||||
/// Author scene description to delete an attribute on this prim that
|
||||
/// was recognized as Primvar (i.e. will present as a valid UsdGeomPrimvar),
|
||||
/// <em>in the current UsdEditTarget</em>.
|
||||
///
|
||||
/// Because this method can only remove opinions about the primvar
|
||||
/// from the current EditTarget, you may generally find it more useful to
|
||||
/// use BlockPrimvar() which will ensure that all values from the EditTarget
|
||||
/// and weaker layers for the primvar and its indices will be ignored.
|
||||
///
|
||||
/// Removal may fail and return false if \p name contains a reserved
|
||||
/// keyword, such as the "indices" suffix we use for indexed primvars.
|
||||
///
|
||||
/// Note this will also remove the indices attribute associated with an
|
||||
/// indiced primvar.
|
||||
///
|
||||
/// \return true if UsdGeomPrimvar and indices attribute was successfully
|
||||
/// removed, false otherwise.
|
||||
///
|
||||
/// \sa UsdPrim::RemoveProperty())
|
||||
USDGEOM_API
|
||||
bool RemovePrimvar(const TfToken& name);
|
||||
|
||||
/// Remove all time samples on the primvar and its associated indices attr,
|
||||
/// and author a *block* \c default value. This will cause authored opinions
|
||||
/// in weaker layers to be ignored.
|
||||
///
|
||||
/// \sa UsdAttribute::Block(), UsdGeomPrimvar::BlockIndices
|
||||
USDGEOM_API
|
||||
void BlockPrimvar(const TfToken& name);
|
||||
|
||||
/// Return the Primvar object named by \p name, which will
|
||||
/// be valid if a Primvar attribute definition already exists.
|
||||
///
|
||||
/// Name lookup will account for Primvar namespacing, which means
|
||||
/// that this method will succeed in some cases where
|
||||
/// \code
|
||||
/// UsdGeomPrimvar(prim->GetAttribute(name))
|
||||
/// \endcode
|
||||
/// will not, unless \p name is properly namespace prefixed.
|
||||
///
|
||||
/// \note Just because a Primvar is valid and defined, and *even if* its
|
||||
/// underlying UsdAttribute (GetAttr()) answers HasValue() affirmatively,
|
||||
/// one must still check the return value of Get(), due to the potential
|
||||
/// of time-varying value blocks (see \ref Usd_AttributeBlocking).
|
||||
///
|
||||
/// \sa HasPrimvar(), \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar GetPrimvar(const TfToken &name) const;
|
||||
|
||||
/// Return valid UsdGeomPrimvar objects for all defined Primvars on
|
||||
/// this prim, similarly to UsdPrim::GetAttributes().
|
||||
///
|
||||
/// The returned primvars may not possess any values, and therefore not
|
||||
/// be useful to some clients. For the primvars useful for inheritance
|
||||
/// computations, see GetPrimvarsWithAuthoredValues(), and for primvars
|
||||
/// useful for direct consumption, see GetPrimvarsWithValues().
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> GetPrimvars() const;
|
||||
|
||||
/// Like GetPrimvars(), but include only primvars that have some
|
||||
/// authored scene description (though not necessarily a value).
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> GetAuthoredPrimvars() const;
|
||||
|
||||
/// Like GetPrimvars(), but include only primvars that have some
|
||||
/// value, whether it comes from authored scene description or a schema
|
||||
/// fallback.
|
||||
///
|
||||
/// For most purposes, this method is more useful than GetPrimvars().
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> GetPrimvarsWithValues() const;
|
||||
|
||||
/// Like GetPrimvars(), but include only primvars that have an **authored**
|
||||
/// value.
|
||||
///
|
||||
/// This is the query used when computing inheritable primvars, and is
|
||||
/// generally more useful than GetAuthoredPrimvars().
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> GetPrimvarsWithAuthoredValues() const;
|
||||
|
||||
/// Compute the primvars that can be inherited from this prim by its
|
||||
/// child prims, including the primvars that **this** prim inherits from
|
||||
/// ancestor prims. Inherited primvars will be bound to attributes on
|
||||
/// the corresponding ancestor prims.
|
||||
///
|
||||
/// Only primvars with **authored**, **non-blocked**,
|
||||
/// **constant interpolation** values are inheritable;
|
||||
/// fallback values are not inherited. The order of the returned
|
||||
/// primvars is undefined.
|
||||
///
|
||||
/// It is not generally useful to call this method on UsdGeomGprim leaf
|
||||
/// prims, and furthermore likely to be expensive since *most* primvars
|
||||
/// are defined on Gprims.
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> FindInheritablePrimvars() const;
|
||||
|
||||
/// Compute the primvars that can be inherited from this prim by its
|
||||
/// child prims, starting from the set of primvars inherited from
|
||||
/// this prim's ancestors. If this method returns an empty vector, then
|
||||
/// this prim's children should inherit the same set of primvars available
|
||||
/// to this prim, i.e. the input `inheritedFromAncestors` .
|
||||
///
|
||||
/// As opposed to FindInheritablePrimvars(), which always recurses up
|
||||
/// through all of the prim's ancestors, this method allows more
|
||||
/// efficient computation of inheritable primvars by starting with the
|
||||
/// list of primvars inherited from this prim's ancestors, and returning
|
||||
/// a newly allocated vector only when this prim makes a change to the
|
||||
/// set of inherited primvars. This enables O(n) inherited primvar
|
||||
/// computation for all prims on a Stage, with potential to share
|
||||
/// computed results that are identical (i.e. when this method returns an
|
||||
/// empty vector, its parent's result can (and must!) be reused for all
|
||||
/// of the prim's children.
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> FindIncrementallyInheritablePrimvars(
|
||||
const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const;
|
||||
|
||||
/// Like GetPrimvar(), but if the named primvar does not exist or has no
|
||||
/// authored value on this prim, search for the named, value-producing
|
||||
/// primvar on ancestor prims.
|
||||
///
|
||||
/// The returned primvar will be bound to the attribute on the
|
||||
/// corresponding ancestor prim on which it was found (if any). If neither
|
||||
/// this prim nor any ancestor contains a value-producing primvar, then
|
||||
/// the returned primvar will be the same as that returned by GetPrimvar().
|
||||
///
|
||||
/// This is probably the method you want to call when needing to consume
|
||||
/// a primvar of a particular name.
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar FindPrimvarWithInheritance(const TfToken &name) const;
|
||||
|
||||
/// \overload
|
||||
///
|
||||
/// This version of FindPrimvarWithInheritance() takes the pre-computed
|
||||
/// set of primvars inherited from this prim's ancestors, as computed
|
||||
/// by FindInheritablePrimvars() or FindIncrementallyInheritablePrimvars()
|
||||
/// on the prim's parent.
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
UsdGeomPrimvar FindPrimvarWithInheritance(const TfToken &name,
|
||||
const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const;
|
||||
|
||||
/// Find all of the value-producing primvars either defined on this prim,
|
||||
/// or inherited from ancestor prims.
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> FindPrimvarsWithInheritance() const;
|
||||
|
||||
/// \overload
|
||||
///
|
||||
/// This version of FindPrimvarsWithInheritance() takes the pre-computed
|
||||
/// set of primvars inherited from this prim's ancestors, as computed
|
||||
/// by FindInheritablePrimvars() or FindIncrementallyInheritablePrimvars()
|
||||
/// on the prim's parent.
|
||||
///
|
||||
/// \sa \ref usdGeom_PrimvarFetchingAPI
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomPrimvar> FindPrimvarsWithInheritance(
|
||||
const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const;
|
||||
|
||||
/// Is there a defined Primvar \p name on this prim?
|
||||
///
|
||||
/// Name lookup will account for Primvar namespacing.
|
||||
///
|
||||
/// Like GetPrimvar(), a return value of `true` for HasPrimvar() does not
|
||||
/// guarantee the primvar will produce a value.
|
||||
USDGEOM_API
|
||||
bool HasPrimvar(const TfToken &name) const;
|
||||
|
||||
/// Is there a Primvar named \p name with an authored value on this
|
||||
/// prim or any of its ancestors?
|
||||
///
|
||||
/// This is probably the method you want to call when wanting to know
|
||||
/// whether or not the prim "has" a primvar of a particular name.
|
||||
///
|
||||
/// \sa FindPrimvarWithInheritance()
|
||||
USDGEOM_API
|
||||
bool HasPossiblyInheritedPrimvar(const TfToken &name) const;
|
||||
|
||||
/// Test whether a given \p name contains the "primvars:" prefix
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool CanContainPropertyName(const TfToken& name);
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,168 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_SCOPE_H
|
||||
#define USDGEOM_GENERATED_SCOPE_H
|
||||
|
||||
/// \file usdGeom/scope.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/imageable.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// SCOPE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomScope
|
||||
///
|
||||
/// Scope is the simplest grouping primitive, and does not carry the
|
||||
/// baggage of transformability. Note that transforms should inherit down
|
||||
/// through a Scope successfully - it is just a guaranteed no-op from a
|
||||
/// transformability perspective.
|
||||
///
|
||||
class UsdGeomScope : public UsdGeomImageable
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomScope on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomScope::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomScope(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomImageable(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomScope on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomScope(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomScope(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomImageable(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomScope();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomScope holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomScope(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomScope
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomScope
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,236 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_SPHERE_H
|
||||
#define USDGEOM_GENERATED_SPHERE_H
|
||||
|
||||
/// \file usdGeom/sphere.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/gprim.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// SPHERE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomSphere
|
||||
///
|
||||
/// Defines a primitive sphere centered at the origin.
|
||||
///
|
||||
/// The fallback values for Cube, Sphere, Cone, and Cylinder are set so that
|
||||
/// they all pack into the same volume/bounds.
|
||||
///
|
||||
class UsdGeomSphere : public UsdGeomGprim
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomSphere on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomSphere::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomSphere(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomGprim(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomSphere on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomSphere(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomSphere(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomGprim(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomSphere();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomSphere holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomSphere(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomSphere
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomSphere
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// RADIUS
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Indicates the sphere's radius. If you
|
||||
/// author \em radius you must also author \em extent.
|
||||
///
|
||||
/// \sa GetExtentAttr()
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `double radius = 1` |
|
||||
/// | C++ Type | double |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Double |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetRadiusAttr() const;
|
||||
|
||||
/// See GetRadiusAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateRadiusAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// EXTENT
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Extent is re-defined on Sphere only to provide a fallback
|
||||
/// value. \sa UsdGeomGprim::GetExtentAttr().
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `float3[] extent = [(-1, -1, -1), (1, 1, 1)]` |
|
||||
/// | C++ Type | VtArray<GfVec3f> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetExtentAttr() const;
|
||||
|
||||
/// See GetExtentAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateExtentAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Compute the extent for the sphere defined by the radius.
|
||||
///
|
||||
/// \return true upon success, false if unable to calculate extent.
|
||||
///
|
||||
/// On success, extent will contain an approximate axis-aligned bounding
|
||||
/// box of the sphere defined by the radius.
|
||||
///
|
||||
/// This function is to provide easy authoring of extent for usd authoring
|
||||
/// tools, hence it is static and acts outside a specific prim (as in
|
||||
/// attribute based methods).
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double radius, VtVec3fArray* extent);
|
||||
|
||||
/// \overload
|
||||
/// Computes the extent as if the matrix \p transform was first applied.
|
||||
USDGEOM_API
|
||||
static bool ComputeExtent(double radius, const GfMatrix4d& transform,
|
||||
VtVec3fArray* extent);
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,434 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_SUBSET_H
|
||||
#define USDGEOM_GENERATED_SUBSET_H
|
||||
|
||||
/// \file usdGeom/subset.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/typed.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/usd/usdGeom/imageable.h"
|
||||
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// GEOMSUBSET //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomSubset
|
||||
///
|
||||
/// Encodes a subset of a piece of geometry (i.e. a UsdGeomImageable)
|
||||
/// as a set of indices. Currently only supports encoding of face-subsets, but
|
||||
/// could be extended in the future to support subsets representing edges,
|
||||
/// segments, points etc.
|
||||
///
|
||||
/// To apply to a geometric prim, a GeomSubset prim must be defined as a
|
||||
/// child of it in namespace. This restriction makes it easy and efficient
|
||||
/// to discover subsets of a prim. We might want to relax this restriction if
|
||||
/// it's common to have multiple <b>families</b> of subsets on a gprim and if
|
||||
/// it's useful to be able to organize subsets belonging to a </b>family</b>
|
||||
/// under a common scope. See 'familyName' attribute for more info on defining
|
||||
/// a family of subsets.
|
||||
///
|
||||
/// Note that a GeomSubset isn't an imageable (i.e. doesn't derive from
|
||||
/// UsdGeomImageable). So, you can't author <b>visibility</b> for it or
|
||||
/// override its <b>purpose</b>.
|
||||
///
|
||||
/// Materials are bound to GeomSubsets just as they are for regular
|
||||
/// geometry using API available in UsdShade (UsdShadeMaterial::Bind).
|
||||
///
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomSubset : public UsdTyped
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomSubset on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomSubset::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomSubset(const UsdPrim& prim=UsdPrim())
|
||||
: UsdTyped(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomSubset on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomSubset(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomSubset(const UsdSchemaBase& schemaObj)
|
||||
: UsdTyped(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomSubset();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomSubset holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomSubset(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomSubset
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomSubset
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// ELEMENTTYPE
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The type of element that the indices target. Currently only
|
||||
/// allows "face" and defaults to it.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token elementType = "face"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | face |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetElementTypeAttr() const;
|
||||
|
||||
/// See GetElementTypeAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateElementTypeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// INDICES
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The set of indices included in this subset. The indices need not
|
||||
/// be sorted, but the same index should not appear more than once.
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `int[] indices = []` |
|
||||
/// | C++ Type | VtArray<int> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetIndicesAttr() const;
|
||||
|
||||
/// See GetIndicesAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// FAMILYNAME
|
||||
// --------------------------------------------------------------------- //
|
||||
/// The name of the family of subsets that this subset belongs to.
|
||||
/// This is optional and is primarily useful when there are multiple
|
||||
/// families of subsets under a geometric prim. In some cases, this could
|
||||
/// also be used for achieving proper roundtripping of subset data between
|
||||
/// DCC apps.
|
||||
/// When multiple subsets belonging to a prim have the same familyName, they
|
||||
/// are said to belong to the family. A <i>familyType</i> value can be
|
||||
/// encoded on the owner of a family of subsets as a token using the static
|
||||
/// method UsdGeomSubset::SetFamilyType(). "familyType" can have one of the
|
||||
/// following values:
|
||||
/// <ul><li><b>UsdGeomTokens->partition</b>: implies that every element of
|
||||
/// the whole geometry appears exactly once in only one of the subsets
|
||||
/// belonging to the family.</li>
|
||||
/// <li><b>UsdGeomTokens->nonOverlapping</b>: an element that appears in one
|
||||
/// subset may not appear in any other subset belonging to the family.</li>
|
||||
/// <li><b>UsdGeomTokens->unrestricted</b>: implies that there are no
|
||||
/// restrictions w.r.t. the membership of elements in the subsets. They
|
||||
/// could be overlapping and the union of all subsets in the family may
|
||||
/// not represent the whole.</li>
|
||||
/// </ul>
|
||||
/// \note The validity of subset data is not enforced by the authoring
|
||||
/// APIs, however they can be checked using UsdGeomSubset::ValidateFamily().
|
||||
///
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token familyName = ""` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetFamilyNameAttr() const;
|
||||
|
||||
/// See GetFamilyNameAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateFamilyNameAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Creates a new GeomSubset below the given \p geom with the given
|
||||
/// name, \p subsetName, element type, \p elementType and \p indices.
|
||||
///
|
||||
/// If a subset named \p subsetName already exists below \p geom, then
|
||||
/// this updates its attributes with the values of the provided arguments
|
||||
/// (indices value at time 'default' will be updated) and returns it.
|
||||
///
|
||||
/// The family type is set / updated on \p geom only if a non-empty value
|
||||
/// is passed in for \p familyType and \p familyName.
|
||||
USDGEOM_API
|
||||
static UsdGeomSubset CreateGeomSubset(
|
||||
const UsdGeomImageable &geom,
|
||||
const TfToken &subsetName,
|
||||
const TfToken &elementType,
|
||||
const VtIntArray &indices,
|
||||
const TfToken &familyName=TfToken(),
|
||||
const TfToken &familyType=TfToken());
|
||||
|
||||
/// Creates a new GeomSubset below the given imageable, \p geom with the
|
||||
/// given name, \p subsetName, element type, \p elementType and \p indices.
|
||||
///
|
||||
/// If a subset named \p subsetName already exists below \p geom, then
|
||||
/// this creates a new subset by appending a suitable index as suffix to
|
||||
/// \p subsetName (eg, subsetName_1) to avoid name collisions.
|
||||
///
|
||||
/// The family type is set / updated on \p geom only if a non-empty value
|
||||
/// is passed in for \p familyType and \p familyName.
|
||||
USDGEOM_API
|
||||
static UsdGeomSubset CreateUniqueGeomSubset(
|
||||
const UsdGeomImageable &geom,
|
||||
const TfToken &subsetName,
|
||||
const TfToken &elementType,
|
||||
const VtIntArray &indices,
|
||||
const TfToken &familyName=TfToken(),
|
||||
const TfToken &familyType=TfToken());
|
||||
|
||||
/// Returns all the GeomSubsets defined on the given imageable, \p geom.
|
||||
USDGEOM_API
|
||||
static std::vector<UsdGeomSubset> GetAllGeomSubsets(
|
||||
const UsdGeomImageable &geom);
|
||||
|
||||
/// Returns all the GeomSubsets of the given \p elementType belonging to
|
||||
/// the specified family, \p familyName on the given imageable, \p geom.
|
||||
/// If \p elementType is empty, then subsets containing all element types
|
||||
/// are returned.
|
||||
/// If \p familyName is left empty, then all subsets of the specified
|
||||
/// \p elementType will be returned.
|
||||
USDGEOM_API
|
||||
static std::vector<UsdGeomSubset> GetGeomSubsets(
|
||||
const UsdGeomImageable &geom,
|
||||
const TfToken &elementType=TfToken(),
|
||||
const TfToken &familyName=TfToken());
|
||||
|
||||
/// Returns the names of all the families of GeomSubsets defined on the given
|
||||
/// imageable, \p geom.
|
||||
USDGEOM_API
|
||||
static TfToken::Set GetAllGeomSubsetFamilyNames(
|
||||
const UsdGeomImageable &geom);
|
||||
|
||||
/// This method is used to encode the type of family that the GeomSubsets
|
||||
/// on the given geometric prim \p geom, with the given family name,
|
||||
/// \p familyName belong to.
|
||||
///
|
||||
/// See \ref UsdGeomSubset::GetFamilyNameAttr for the possible values for
|
||||
/// \p familyType.
|
||||
///
|
||||
/// When a family of GeomSubsets is tagged as a UsdGeomTokens->partition or
|
||||
/// UsdGeomTokens->nonOverlapping, the validity of the data (i.e.
|
||||
/// mutual exclusivity and/or wholeness) is not enforced by the authoring
|
||||
/// APIs. Use ValidateFamily() to validate the data in a family of
|
||||
/// GeomSubsets.
|
||||
///
|
||||
/// \return Returns false upon failure to create or set the appropriate
|
||||
/// attribute on \p geom.
|
||||
USDGEOM_API
|
||||
static bool SetFamilyType(
|
||||
const UsdGeomImageable &geom,
|
||||
const TfToken &familyName,
|
||||
const TfToken &familyType);
|
||||
|
||||
/// Returns the type of family that the GeomSubsets on the given geometric
|
||||
/// prim \p geom, with the given family name, \p familyName belong to.
|
||||
///
|
||||
/// This only returns the token that's encoded on \p geom and does not perform
|
||||
/// any actual validation on the family of GeomSubsets. Please use
|
||||
/// ValidateFamily() for such validation.
|
||||
///
|
||||
/// When familyType is not set on \p geom, the fallback value
|
||||
/// UsdTokens->unrestricted is returned.
|
||||
USDGEOM_API
|
||||
static TfToken GetFamilyType(
|
||||
const UsdGeomImageable &geom,
|
||||
const TfToken &familyName);
|
||||
|
||||
/// Utility for getting the list of indices that are not assigned to any of
|
||||
/// the GeomSubsets in \p subsets at the timeCode, \p time, given the
|
||||
/// element count (total number of indices in the array being subdivided),
|
||||
/// \p elementCount.
|
||||
USDGEOM_API
|
||||
static VtIntArray GetUnassignedIndices(
|
||||
const std::vector<UsdGeomSubset> &subsets,
|
||||
const size_t elementCount,
|
||||
const UsdTimeCode &time=UsdTimeCode::EarliestTime());
|
||||
|
||||
/// Validates the data in the given set of GeomSubsets, \p subsets, given
|
||||
/// the total number of elements in the array being subdivided,
|
||||
/// \p elementCount and the \p familyType that the subsets belong to.
|
||||
///
|
||||
/// For proper validation of indices in \p subsets, all of the GeomSubsets
|
||||
/// must have the same 'elementType'.
|
||||
///
|
||||
/// If one or more subsets contain invalid data, then false is returned and
|
||||
/// \p reason is populated with a string explaining the reason why it is
|
||||
/// invalid.
|
||||
///
|
||||
/// The python version of this method returns a tuple containing
|
||||
/// a (bool, string), where the bool has the validity of the subsets and
|
||||
/// the string contains the reason (if they're invalid).
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool ValidateSubsets(
|
||||
const std::vector<UsdGeomSubset> &subsets,
|
||||
const size_t elementCount,
|
||||
const TfToken &familyType,
|
||||
std::string * const reason);
|
||||
|
||||
/// Validates whether the family of subsets identified by the given
|
||||
/// \p familyName and \p elementType on the given imageable, \p geom contain
|
||||
/// valid data. If the family is designated as a partition or as
|
||||
/// non-overlapping using SetFamilyType(), then the validity of the data
|
||||
/// is checked. If the familyType is "unrestricted", then this performs only
|
||||
/// bounds checking of the values in the "indices" arrays.
|
||||
///
|
||||
/// If \p reason is not NULL, then it is populated with a string explaining
|
||||
/// why the family is invalid, if it is invalid.
|
||||
///
|
||||
/// The python version of this method returns a tuple containing
|
||||
/// a (bool, string), where the bool has the validity of the family and
|
||||
/// the string contains the reason (if it's invalid).
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool ValidateFamily(
|
||||
const UsdGeomImageable &geom,
|
||||
const TfToken &elementType,
|
||||
const TfToken &familyName,
|
||||
std::string * const reason);
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,709 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_TOKENS_H
|
||||
#define USDGEOM_TOKENS_H
|
||||
|
||||
/// \file usdGeom/tokens.h
|
||||
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
//
|
||||
// This is an automatically generated file (by usdGenSchema.py).
|
||||
// Do not hand-edit!
|
||||
//
|
||||
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/base/tf/staticData.h"
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
/// \class UsdGeomTokensType
|
||||
///
|
||||
/// \link UsdGeomTokens \endlink provides static, efficient
|
||||
/// \link TfToken TfTokens\endlink for use in all public USD API.
|
||||
///
|
||||
/// These tokens are auto-generated from the module's schema, representing
|
||||
/// property names, for when you need to fetch an attribute or relationship
|
||||
/// directly by name, e.g. UsdPrim::GetAttribute(), in the most efficient
|
||||
/// manner, and allow the compiler to verify that you spelled the name
|
||||
/// correctly.
|
||||
///
|
||||
/// UsdGeomTokens also contains all of the \em allowedTokens values
|
||||
/// declared for schema builtin attributes of 'token' scene description type.
|
||||
/// Use UsdGeomTokens like so:
|
||||
///
|
||||
/// \code
|
||||
/// gprim.GetMyTokenValuedAttr().Set(UsdGeomTokens->accelerations);
|
||||
/// \endcode
|
||||
struct UsdGeomTokensType {
|
||||
USDGEOM_API UsdGeomTokensType();
|
||||
/// \brief "accelerations"
|
||||
///
|
||||
/// UsdGeomPointInstancer, UsdGeomPointBased
|
||||
const TfToken accelerations;
|
||||
/// \brief "all"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetFaceVaryingLinearInterpolationAttr()
|
||||
const TfToken all;
|
||||
/// \brief "angularVelocities"
|
||||
///
|
||||
/// UsdGeomPointInstancer
|
||||
const TfToken angularVelocities;
|
||||
/// \brief "axis"
|
||||
///
|
||||
/// UsdGeomCone, UsdGeomCapsule, UsdGeomCylinder
|
||||
const TfToken axis;
|
||||
/// \brief "basis"
|
||||
///
|
||||
/// UsdGeomBasisCurves
|
||||
const TfToken basis;
|
||||
/// \brief "bezier"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetBasisAttr(), Default value for UsdGeomBasisCurves::GetBasisAttr()
|
||||
const TfToken bezier;
|
||||
/// \brief "bilinear"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetSubdivisionSchemeAttr()
|
||||
const TfToken bilinear;
|
||||
/// \brief "boundaries"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetFaceVaryingLinearInterpolationAttr()
|
||||
const TfToken boundaries;
|
||||
/// \brief "bounds"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelDrawModeAttr()
|
||||
const TfToken bounds;
|
||||
/// \brief "box"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelCardGeometryAttr()
|
||||
const TfToken box;
|
||||
/// \brief "bspline"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetBasisAttr()
|
||||
const TfToken bspline;
|
||||
/// \brief "cards"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelDrawModeAttr()
|
||||
const TfToken cards;
|
||||
/// \brief "catmullClark"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetSubdivisionSchemeAttr(), Default value for UsdGeomMesh::GetSubdivisionSchemeAttr(), Possible value for UsdGeomMesh::GetTriangleSubdivisionRuleAttr(), Default value for UsdGeomMesh::GetTriangleSubdivisionRuleAttr()
|
||||
const TfToken catmullClark;
|
||||
/// \brief "catmullRom"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetBasisAttr()
|
||||
const TfToken catmullRom;
|
||||
/// \brief "clippingPlanes"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken clippingPlanes;
|
||||
/// \brief "clippingRange"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken clippingRange;
|
||||
/// \brief "closed"
|
||||
///
|
||||
/// Possible value for UsdGeomNurbsPatch::GetUFormAttr(), Possible value for UsdGeomNurbsPatch::GetVFormAttr()
|
||||
const TfToken closed;
|
||||
/// \brief "constant"
|
||||
///
|
||||
/// Possible value for UsdGeomPrimvar::SetInterpolation. Default value for UsdGeomPrimvar::GetInterpolation. One value remains constant over the entire surface primitive.
|
||||
const TfToken constant;
|
||||
/// \brief "cornerIndices"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken cornerIndices;
|
||||
/// \brief "cornerSharpnesses"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken cornerSharpnesses;
|
||||
/// \brief "cornersOnly"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetFaceVaryingLinearInterpolationAttr()
|
||||
const TfToken cornersOnly;
|
||||
/// \brief "cornersPlus1"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetFaceVaryingLinearInterpolationAttr(), Default value for UsdGeomMesh::GetFaceVaryingLinearInterpolationAttr()
|
||||
const TfToken cornersPlus1;
|
||||
/// \brief "cornersPlus2"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetFaceVaryingLinearInterpolationAttr()
|
||||
const TfToken cornersPlus2;
|
||||
/// \brief "creaseIndices"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken creaseIndices;
|
||||
/// \brief "creaseLengths"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken creaseLengths;
|
||||
/// \brief "creaseSharpnesses"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken creaseSharpnesses;
|
||||
/// \brief "cross"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelCardGeometryAttr(), Default value for UsdGeomModelAPI::GetModelCardGeometryAttr()
|
||||
const TfToken cross;
|
||||
/// \brief "cubic"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetTypeAttr(), Default value for UsdGeomBasisCurves::GetTypeAttr()
|
||||
const TfToken cubic;
|
||||
/// \brief "curveVertexCounts"
|
||||
///
|
||||
/// UsdGeomCurves
|
||||
const TfToken curveVertexCounts;
|
||||
/// \brief "default"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelDrawModeAttr(), Possible value for UsdGeomImageable::GetPurposeAttr(), Default value for UsdGeomImageable::GetPurposeAttr()
|
||||
const TfToken default_;
|
||||
/// \brief "doubleSided"
|
||||
///
|
||||
/// UsdGeomGprim
|
||||
const TfToken doubleSided;
|
||||
/// \brief "edgeAndCorner"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetInterpolateBoundaryAttr(), Default value for UsdGeomMesh::GetInterpolateBoundaryAttr()
|
||||
const TfToken edgeAndCorner;
|
||||
/// \brief "edgeOnly"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetInterpolateBoundaryAttr()
|
||||
const TfToken edgeOnly;
|
||||
/// \brief "elementSize"
|
||||
///
|
||||
/// UsdGeomPrimvar - The number of values in the value array that must be aggregated for each element on the primitive.
|
||||
const TfToken elementSize;
|
||||
/// \brief "elementType"
|
||||
///
|
||||
/// UsdGeomSubset
|
||||
const TfToken elementType;
|
||||
/// \brief "exposure"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken exposure;
|
||||
/// \brief "extent"
|
||||
///
|
||||
/// UsdGeomCone, UsdGeomCapsule, UsdGeomCylinder, UsdGeomSphere, UsdGeomCube, UsdGeomBoundable
|
||||
const TfToken extent;
|
||||
/// \brief "extentsHint"
|
||||
///
|
||||
/// Name of the attribute used to author extents hints at the root of leaf models. Extents hints are stored by purpose as a vector of GfVec3f values. They are ordered based on the order of purpose tokens returned by UsdGeomImageable::GetOrderedPurposeTokens.
|
||||
const TfToken extentsHint;
|
||||
/// \brief "face"
|
||||
///
|
||||
/// Possible value for UsdGeomSubset::GetElementTypeAttr(), Default value for UsdGeomSubset::GetElementTypeAttr()
|
||||
const TfToken face;
|
||||
/// \brief "faceVarying"
|
||||
///
|
||||
/// Possible value for UsdGeomPrimvar::SetInterpolation. For polygons and subdivision surfaces, four values are interpolated over each face of the mesh. Bilinear interpolation is used for interpolation between the four values.
|
||||
const TfToken faceVarying;
|
||||
/// \brief "faceVaryingLinearInterpolation"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken faceVaryingLinearInterpolation;
|
||||
/// \brief "faceVertexCounts"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken faceVertexCounts;
|
||||
/// \brief "faceVertexIndices"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken faceVertexIndices;
|
||||
/// \brief "familyName"
|
||||
///
|
||||
/// UsdGeomSubset
|
||||
const TfToken familyName;
|
||||
/// \brief "focalLength"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken focalLength;
|
||||
/// \brief "focusDistance"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken focusDistance;
|
||||
/// \brief "fromTexture"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelCardGeometryAttr()
|
||||
const TfToken fromTexture;
|
||||
/// \brief "fStop"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken fStop;
|
||||
/// \brief "guide"
|
||||
///
|
||||
/// Possible value for UsdGeomImageable::GetPurposeAttr()
|
||||
const TfToken guide;
|
||||
/// \brief "guideVisibility"
|
||||
///
|
||||
/// UsdGeomVisibilityAPI
|
||||
const TfToken guideVisibility;
|
||||
/// \brief "height"
|
||||
///
|
||||
/// UsdGeomCone, UsdGeomCapsule, UsdGeomCylinder
|
||||
const TfToken height;
|
||||
/// \brief "hermite"
|
||||
///
|
||||
/// A deprecated basis token for UsdGeomBasisCurves. Consumers of USD should transition to using the UsdGeomHermiteCurves schema.
|
||||
const TfToken hermite;
|
||||
/// \brief "holeIndices"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken holeIndices;
|
||||
/// \brief "horizontalAperture"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken horizontalAperture;
|
||||
/// \brief "horizontalApertureOffset"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken horizontalApertureOffset;
|
||||
/// \brief "ids"
|
||||
///
|
||||
/// UsdGeomPointInstancer, UsdGeomPoints
|
||||
const TfToken ids;
|
||||
/// \brief "inactiveIds"
|
||||
///
|
||||
/// int64listop prim metadata that specifies the PointInstancer ids that should be masked (unrenderable) over all time.
|
||||
const TfToken inactiveIds;
|
||||
/// \brief "indices"
|
||||
///
|
||||
/// UsdGeomSubset
|
||||
const TfToken indices;
|
||||
/// \brief "inherited"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelDrawModeAttr(), Default value for UsdGeomModelAPI::GetModelDrawModeAttr(), Possible value for UsdGeomVisibilityAPI::GetGuideVisibilityAttr(), Possible value for UsdGeomVisibilityAPI::GetProxyVisibilityAttr(), Default value for UsdGeomVisibilityAPI::GetProxyVisibilityAttr(), Possible value for UsdGeomVisibilityAPI::GetRenderVisibilityAttr(), Default value for UsdGeomVisibilityAPI::GetRenderVisibilityAttr(), Possible value for UsdGeomImageable::GetVisibilityAttr(), Default value for UsdGeomImageable::GetVisibilityAttr()
|
||||
const TfToken inherited;
|
||||
/// \brief "interpolateBoundary"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken interpolateBoundary;
|
||||
/// \brief "interpolation"
|
||||
///
|
||||
/// UsdGeomPrimvar - How a Primvar interpolates across a primitive; equivalent to RenderMan's \ref Usd_InterpolationVals "class specifier"
|
||||
const TfToken interpolation;
|
||||
/// \brief "invisible"
|
||||
///
|
||||
/// Possible value for UsdGeomVisibilityAPI::GetGuideVisibilityAttr(), Default value for UsdGeomVisibilityAPI::GetGuideVisibilityAttr(), Possible value for UsdGeomVisibilityAPI::GetProxyVisibilityAttr(), Possible value for UsdGeomVisibilityAPI::GetRenderVisibilityAttr(), Possible value for UsdGeomImageable::GetVisibilityAttr()
|
||||
const TfToken invisible;
|
||||
/// \brief "invisibleIds"
|
||||
///
|
||||
/// UsdGeomPointInstancer
|
||||
const TfToken invisibleIds;
|
||||
/// \brief "knots"
|
||||
///
|
||||
/// UsdGeomNurbsCurves
|
||||
const TfToken knots;
|
||||
/// \brief "left"
|
||||
///
|
||||
/// Possible value for UsdGeomCamera::GetStereoRoleAttr()
|
||||
const TfToken left;
|
||||
/// \brief "leftHanded"
|
||||
///
|
||||
/// Possible value for UsdGeomGprim::GetOrientationAttr()
|
||||
const TfToken leftHanded;
|
||||
/// \brief "linear"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetTypeAttr()
|
||||
const TfToken linear;
|
||||
/// \brief "loop"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetSubdivisionSchemeAttr()
|
||||
const TfToken loop;
|
||||
/// \brief "metersPerUnit"
|
||||
///
|
||||
/// Stage-level metadata that encodes a scene's linear unit of measure as meters per encoded unit.
|
||||
const TfToken metersPerUnit;
|
||||
/// \brief "model:applyDrawMode"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelApplyDrawMode;
|
||||
/// \brief "model:cardGeometry"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelCardGeometry;
|
||||
/// \brief "model:cardTextureXNeg"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelCardTextureXNeg;
|
||||
/// \brief "model:cardTextureXPos"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelCardTextureXPos;
|
||||
/// \brief "model:cardTextureYNeg"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelCardTextureYNeg;
|
||||
/// \brief "model:cardTextureYPos"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelCardTextureYPos;
|
||||
/// \brief "model:cardTextureZNeg"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelCardTextureZNeg;
|
||||
/// \brief "model:cardTextureZPos"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelCardTextureZPos;
|
||||
/// \brief "model:drawMode"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelDrawMode;
|
||||
/// \brief "model:drawModeColor"
|
||||
///
|
||||
/// UsdGeomModelAPI
|
||||
const TfToken modelDrawModeColor;
|
||||
/// \brief "mono"
|
||||
///
|
||||
/// Possible value for UsdGeomCamera::GetStereoRoleAttr(), Default value for UsdGeomCamera::GetStereoRoleAttr()
|
||||
const TfToken mono;
|
||||
/// \brief "motion:velocityScale"
|
||||
///
|
||||
/// UsdGeomMotionAPI
|
||||
const TfToken motionVelocityScale;
|
||||
/// \brief "none"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetFaceVaryingLinearInterpolationAttr(), Possible value for UsdGeomMesh::GetInterpolateBoundaryAttr(), Possible value for UsdGeomMesh::GetSubdivisionSchemeAttr()
|
||||
const TfToken none;
|
||||
/// \brief "nonOverlapping"
|
||||
///
|
||||
/// A type of family of GeomSubsets. It implies that the elements in the various subsets belonging to the family are mutually exclusive, i.e., an element that appears in one subset may not belong to any other subset in the family.
|
||||
const TfToken nonOverlapping;
|
||||
/// \brief "nonperiodic"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetWrapAttr(), Default value for UsdGeomBasisCurves::GetWrapAttr()
|
||||
const TfToken nonperiodic;
|
||||
/// \brief "normals"
|
||||
///
|
||||
/// UsdGeomPointBased
|
||||
const TfToken normals;
|
||||
/// \brief "open"
|
||||
///
|
||||
/// Possible value for UsdGeomNurbsPatch::GetUFormAttr(), Default value for UsdGeomNurbsPatch::GetUFormAttr(), Possible value for UsdGeomNurbsPatch::GetVFormAttr(), Default value for UsdGeomNurbsPatch::GetVFormAttr()
|
||||
const TfToken open;
|
||||
/// \brief "order"
|
||||
///
|
||||
/// UsdGeomNurbsCurves
|
||||
const TfToken order;
|
||||
/// \brief "orientation"
|
||||
///
|
||||
/// UsdGeomGprim
|
||||
const TfToken orientation;
|
||||
/// \brief "orientations"
|
||||
///
|
||||
/// UsdGeomPointInstancer
|
||||
const TfToken orientations;
|
||||
/// \brief "origin"
|
||||
///
|
||||
/// Possible value for UsdGeomModelAPI::GetModelDrawModeAttr()
|
||||
const TfToken origin;
|
||||
/// \brief "orthographic"
|
||||
///
|
||||
/// Possible value for UsdGeomCamera::GetProjectionAttr()
|
||||
const TfToken orthographic;
|
||||
/// \brief "partition"
|
||||
///
|
||||
/// A type of family of GeomSubsets. It implies that every element appears exacly once in only one of the subsets in the family.
|
||||
const TfToken partition;
|
||||
/// \brief "periodic"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetWrapAttr(), Possible value for UsdGeomNurbsPatch::GetUFormAttr(), Possible value for UsdGeomNurbsPatch::GetVFormAttr()
|
||||
const TfToken periodic;
|
||||
/// \brief "perspective"
|
||||
///
|
||||
/// Possible value for UsdGeomCamera::GetProjectionAttr(), Default value for UsdGeomCamera::GetProjectionAttr()
|
||||
const TfToken perspective;
|
||||
/// \brief "pinned"
|
||||
///
|
||||
/// Possible value for UsdGeomBasisCurves::GetWrapAttr()
|
||||
const TfToken pinned;
|
||||
/// \brief "pivot"
|
||||
///
|
||||
/// Op suffix for the standard scale-rotate pivot on a UsdGeomXformCommonAPI-compatible prim.
|
||||
const TfToken pivot;
|
||||
/// \brief "points"
|
||||
///
|
||||
/// UsdGeomPointBased
|
||||
const TfToken points;
|
||||
/// \brief "pointWeights"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken pointWeights;
|
||||
/// \brief "positions"
|
||||
///
|
||||
/// UsdGeomPointInstancer
|
||||
const TfToken positions;
|
||||
/// \brief "power"
|
||||
///
|
||||
/// A deprecated basis token for UsdGeomBasisCurves.
|
||||
const TfToken power;
|
||||
/// \brief "primvars:displayColor"
|
||||
///
|
||||
/// UsdGeomGprim
|
||||
const TfToken primvarsDisplayColor;
|
||||
/// \brief "primvars:displayOpacity"
|
||||
///
|
||||
/// UsdGeomGprim
|
||||
const TfToken primvarsDisplayOpacity;
|
||||
/// \brief "projection"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken projection;
|
||||
/// \brief "protoIndices"
|
||||
///
|
||||
/// UsdGeomPointInstancer
|
||||
const TfToken protoIndices;
|
||||
/// \brief "prototypes"
|
||||
///
|
||||
/// UsdGeomPointInstancer
|
||||
const TfToken prototypes;
|
||||
/// \brief "proxy"
|
||||
///
|
||||
/// Possible value for UsdGeomImageable::GetPurposeAttr()
|
||||
const TfToken proxy;
|
||||
/// \brief "proxyPrim"
|
||||
///
|
||||
/// UsdGeomImageable
|
||||
const TfToken proxyPrim;
|
||||
/// \brief "proxyVisibility"
|
||||
///
|
||||
/// UsdGeomVisibilityAPI
|
||||
const TfToken proxyVisibility;
|
||||
/// \brief "purpose"
|
||||
///
|
||||
/// UsdGeomImageable
|
||||
const TfToken purpose;
|
||||
/// \brief "radius"
|
||||
///
|
||||
/// UsdGeomCone, UsdGeomCapsule, UsdGeomCylinder, UsdGeomSphere
|
||||
const TfToken radius;
|
||||
/// \brief "ranges"
|
||||
///
|
||||
/// UsdGeomNurbsCurves
|
||||
const TfToken ranges;
|
||||
/// \brief "render"
|
||||
///
|
||||
/// Possible value for UsdGeomImageable::GetPurposeAttr()
|
||||
const TfToken render;
|
||||
/// \brief "renderVisibility"
|
||||
///
|
||||
/// UsdGeomVisibilityAPI
|
||||
const TfToken renderVisibility;
|
||||
/// \brief "right"
|
||||
///
|
||||
/// Possible value for UsdGeomCamera::GetStereoRoleAttr()
|
||||
const TfToken right;
|
||||
/// \brief "rightHanded"
|
||||
///
|
||||
/// Possible value for UsdGeomGprim::GetOrientationAttr(), Default value for UsdGeomGprim::GetOrientationAttr()
|
||||
const TfToken rightHanded;
|
||||
/// \brief "scales"
|
||||
///
|
||||
/// UsdGeomPointInstancer
|
||||
const TfToken scales;
|
||||
/// \brief "shutter:close"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken shutterClose;
|
||||
/// \brief "shutter:open"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken shutterOpen;
|
||||
/// \brief "size"
|
||||
///
|
||||
/// UsdGeomCube
|
||||
const TfToken size;
|
||||
/// \brief "smooth"
|
||||
///
|
||||
/// Possible value for UsdGeomMesh::GetTriangleSubdivisionRuleAttr()
|
||||
const TfToken smooth;
|
||||
/// \brief "stereoRole"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken stereoRole;
|
||||
/// \brief "subdivisionScheme"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken subdivisionScheme;
|
||||
/// \brief "tangents"
|
||||
///
|
||||
/// UsdGeomHermiteCurves
|
||||
const TfToken tangents;
|
||||
/// \brief "triangleSubdivisionRule"
|
||||
///
|
||||
/// UsdGeomMesh
|
||||
const TfToken triangleSubdivisionRule;
|
||||
/// \brief "trimCurve:counts"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken trimCurveCounts;
|
||||
/// \brief "trimCurve:knots"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken trimCurveKnots;
|
||||
/// \brief "trimCurve:orders"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken trimCurveOrders;
|
||||
/// \brief "trimCurve:points"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken trimCurvePoints;
|
||||
/// \brief "trimCurve:ranges"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken trimCurveRanges;
|
||||
/// \brief "trimCurve:vertexCounts"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken trimCurveVertexCounts;
|
||||
/// \brief "type"
|
||||
///
|
||||
/// UsdGeomBasisCurves
|
||||
const TfToken type;
|
||||
/// \brief "uForm"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken uForm;
|
||||
/// \brief "uKnots"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken uKnots;
|
||||
/// \brief "unauthoredValuesIndex"
|
||||
///
|
||||
/// UsdGeomPrimvar - The index that represents unauthored values in the indices array of an indexed primvar.
|
||||
const TfToken unauthoredValuesIndex;
|
||||
/// \brief "uniform"
|
||||
///
|
||||
/// Possible value for UsdGeomPrimvar::SetInterpolation. One value remains constant for each uv patch segment of the surface primitive (which is a \em face for meshes).
|
||||
const TfToken uniform;
|
||||
/// \brief "unrestricted"
|
||||
///
|
||||
/// A type of family of GeomSubsets. It implies that there are no restrictions w.r.t. the membership of elements in the subsets. There could be overlapping members in subsets belonging to the family and the union of all subsets in the family may not contain all the elements.
|
||||
const TfToken unrestricted;
|
||||
/// \brief "uOrder"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken uOrder;
|
||||
/// \brief "upAxis"
|
||||
///
|
||||
/// Stage-level metadata that encodes a scene's orientation as a token whose value can be "Y" or "Z".
|
||||
const TfToken upAxis;
|
||||
/// \brief "uRange"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken uRange;
|
||||
/// \brief "uVertexCount"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken uVertexCount;
|
||||
/// \brief "varying"
|
||||
///
|
||||
/// Possible value for UsdGeomPrimvar::SetInterpolation. Four values are interpolated over each uv patch segment of the surface. Bilinear interpolation is used for interpolation between the four values.
|
||||
const TfToken varying;
|
||||
/// \brief "velocities"
|
||||
///
|
||||
/// UsdGeomPointInstancer, UsdGeomPointBased
|
||||
const TfToken velocities;
|
||||
/// \brief "vertex"
|
||||
///
|
||||
/// Possible value for UsdGeomPrimvar::SetInterpolation. Values are interpolated between each vertex in the surface primitive. The basis function of the surface is used for interpolation between vertices.
|
||||
const TfToken vertex;
|
||||
/// \brief "verticalAperture"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken verticalAperture;
|
||||
/// \brief "verticalApertureOffset"
|
||||
///
|
||||
/// UsdGeomCamera
|
||||
const TfToken verticalApertureOffset;
|
||||
/// \brief "vForm"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken vForm;
|
||||
/// \brief "visibility"
|
||||
///
|
||||
/// UsdGeomImageable
|
||||
const TfToken visibility;
|
||||
/// \brief "visible"
|
||||
///
|
||||
/// Possible value for UsdGeomVisibilityAPI::GetGuideVisibilityAttr(), Possible value for UsdGeomVisibilityAPI::GetProxyVisibilityAttr(), Possible value for UsdGeomVisibilityAPI::GetRenderVisibilityAttr()
|
||||
const TfToken visible;
|
||||
/// \brief "vKnots"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken vKnots;
|
||||
/// \brief "vOrder"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken vOrder;
|
||||
/// \brief "vRange"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken vRange;
|
||||
/// \brief "vVertexCount"
|
||||
///
|
||||
/// UsdGeomNurbsPatch
|
||||
const TfToken vVertexCount;
|
||||
/// \brief "widths"
|
||||
///
|
||||
/// UsdGeomPoints, UsdGeomCurves
|
||||
const TfToken widths;
|
||||
/// \brief "wrap"
|
||||
///
|
||||
/// UsdGeomBasisCurves
|
||||
const TfToken wrap;
|
||||
/// \brief "X"
|
||||
///
|
||||
/// Possible value for UsdGeomCone::GetAxisAttr(), Possible value for UsdGeomCapsule::GetAxisAttr(), Possible value for UsdGeomCylinder::GetAxisAttr()
|
||||
const TfToken x;
|
||||
/// \brief "xformOpOrder"
|
||||
///
|
||||
/// UsdGeomXformable
|
||||
const TfToken xformOpOrder;
|
||||
/// \brief "Y"
|
||||
///
|
||||
/// Possible value for UsdGeomCone::GetAxisAttr(), Possible value for UsdGeomCapsule::GetAxisAttr(), Possible value for UsdGeomCylinder::GetAxisAttr()
|
||||
const TfToken y;
|
||||
/// \brief "Z"
|
||||
///
|
||||
/// Possible value for UsdGeomCone::GetAxisAttr(), Default value for UsdGeomCone::GetAxisAttr(), Possible value for UsdGeomCapsule::GetAxisAttr(), Default value for UsdGeomCapsule::GetAxisAttr(), Possible value for UsdGeomCylinder::GetAxisAttr(), Default value for UsdGeomCylinder::GetAxisAttr()
|
||||
const TfToken z;
|
||||
/// A vector of all of the tokens listed above.
|
||||
const std::vector<TfToken> allTokens;
|
||||
};
|
||||
|
||||
/// \var UsdGeomTokens
|
||||
///
|
||||
/// A global variable with static, efficient \link TfToken TfTokens\endlink
|
||||
/// for use in all public USD API. \sa UsdGeomTokensType
|
||||
extern USDGEOM_API TfStaticData<UsdGeomTokensType> UsdGeomTokens;
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,346 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_VISIBILITYAPI_H
|
||||
#define USDGEOM_GENERATED_VISIBILITYAPI_H
|
||||
|
||||
/// \file usdGeom/visibilityAPI.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/apiSchemaBase.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// VISIBILITYAPI //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomVisibilityAPI
|
||||
///
|
||||
///
|
||||
/// UsdGeomVisibilityAPI introduces properties that can be used to author
|
||||
/// visibility opinions.
|
||||
///
|
||||
/// \note
|
||||
/// Currently, this schema only introduces the attributes that are used to
|
||||
/// control purpose visibility. Later, this schema will define _all_
|
||||
/// visibility-related properties and UsdGeomImageable will no longer define
|
||||
/// those properties.
|
||||
///
|
||||
/// The purpose visibility attributes added by this schema,
|
||||
/// _guideVisibility_, _proxyVisibility_, and _renderVisibility_ can each be
|
||||
/// used to control visibility for geometry of the corresponding purpose
|
||||
/// values, with the overall _visibility_ attribute acting as an
|
||||
/// override. I.e., if _visibility_ evaluates to "invisible", purpose
|
||||
/// visibility is invisible; otherwise, purpose visibility is determined by
|
||||
/// the corresponding purpose visibility attribute.
|
||||
///
|
||||
/// Note that the behavior of _guideVisibility_ is subtly different from the
|
||||
/// _proxyVisibility_ and _renderVisibility_ attributes, in that "guide"
|
||||
/// purpose visibility always evaluates to either "invisible" or "visible",
|
||||
/// whereas the other attributes may yield computed values of "inherited" if
|
||||
/// there is no authored opinion on the attribute or inherited from an
|
||||
/// ancestor. This is motivated by the fact that, in Pixar"s user workflows,
|
||||
/// we have never found a need to have all guides visible in a scene by
|
||||
/// default, whereas we do find that flexibility useful for "proxy" and
|
||||
/// "render" geometry.
|
||||
///
|
||||
/// This schema can only be applied to UsdGeomImageable prims. The
|
||||
/// UseGeomImageable schema provides API for computing the purpose visibility
|
||||
/// values that result from the attributes introduced by this schema.
|
||||
///
|
||||
///
|
||||
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
|
||||
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
|
||||
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
|
||||
/// as the value.
|
||||
///
|
||||
class UsdGeomVisibilityAPI : public UsdAPISchemaBase
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::SingleApplyAPI;
|
||||
|
||||
/// Construct a UsdGeomVisibilityAPI on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomVisibilityAPI::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomVisibilityAPI(const UsdPrim& prim=UsdPrim())
|
||||
: UsdAPISchemaBase(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomVisibilityAPI on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomVisibilityAPI(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomVisibilityAPI(const UsdSchemaBase& schemaObj)
|
||||
: UsdAPISchemaBase(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomVisibilityAPI();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomVisibilityAPI holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomVisibilityAPI(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomVisibilityAPI
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
/// Returns true if this <b>single-apply</b> API schema can be applied to
|
||||
/// the given \p prim. If this schema can not be a applied to the prim,
|
||||
/// this returns false and, if provided, populates \p whyNot with the
|
||||
/// reason it can not be applied.
|
||||
///
|
||||
/// Note that if CanApply returns false, that does not necessarily imply
|
||||
/// that calling Apply will fail. Callers are expected to call CanApply
|
||||
/// before calling Apply if they want to ensure that it is valid to
|
||||
/// apply a schema.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool
|
||||
CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
|
||||
|
||||
/// Applies this <b>single-apply</b> API schema to the given \p prim.
|
||||
/// This information is stored by adding "VisibilityAPI" to the
|
||||
/// token-valued, listOp metadata \em apiSchemas on the prim.
|
||||
///
|
||||
/// \return A valid UsdGeomVisibilityAPI object is returned upon success.
|
||||
/// An invalid (or empty) UsdGeomVisibilityAPI object is returned upon
|
||||
/// failure. See \ref UsdPrim::ApplyAPI() for conditions
|
||||
/// resulting in failure.
|
||||
///
|
||||
/// \sa UsdPrim::GetAppliedSchemas()
|
||||
/// \sa UsdPrim::HasAPI()
|
||||
/// \sa UsdPrim::CanApplyAPI()
|
||||
/// \sa UsdPrim::ApplyAPI()
|
||||
/// \sa UsdPrim::RemoveAPI()
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomVisibilityAPI
|
||||
Apply(const UsdPrim &prim);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// GUIDEVISIBILITY
|
||||
// --------------------------------------------------------------------- //
|
||||
///
|
||||
/// This attribute controls visibility for geometry with purpose "guide".
|
||||
///
|
||||
/// Unlike overall _visibility_, _guideVisibility_ is uniform, and
|
||||
/// therefore cannot be animated.
|
||||
///
|
||||
/// Also unlike overall _visibility_, _guideVisibility_ is tri-state, in
|
||||
/// that a descendant with an opinion of "visible" overrides an ancestor
|
||||
/// opinion of "invisible".
|
||||
///
|
||||
/// The _guideVisibility_ attribute works in concert with the overall
|
||||
/// _visibility_ attribute: The visibility of a prim with purpose "guide"
|
||||
/// is determined by the inherited values it receives for the _visibility_
|
||||
/// and _guideVisibility_ attributes. If _visibility_ evaluates to
|
||||
/// "invisible", the prim is invisible. If _visibility_ evaluates to
|
||||
/// "inherited" and _guideVisibility_ evaluates to "visible", then the
|
||||
/// prim is visible. __Otherwise, it is invisible.__
|
||||
///
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token guideVisibility = "invisible"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | inherited, invisible, visible |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetGuideVisibilityAttr() const;
|
||||
|
||||
/// See GetGuideVisibilityAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateGuideVisibilityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// PROXYVISIBILITY
|
||||
// --------------------------------------------------------------------- //
|
||||
///
|
||||
/// This attribute controls visibility for geometry with purpose "proxy".
|
||||
///
|
||||
/// Unlike overall _visibility_, _proxyVisibility_ is uniform, and
|
||||
/// therefore cannot be animated.
|
||||
///
|
||||
/// Also unlike overall _visibility_, _proxyVisibility_ is tri-state, in
|
||||
/// that a descendant with an opinion of "visible" overrides an ancestor
|
||||
/// opinion of "invisible".
|
||||
///
|
||||
/// The _proxyVisibility_ attribute works in concert with the overall
|
||||
/// _visibility_ attribute: The visibility of a prim with purpose "proxy"
|
||||
/// is determined by the inherited values it receives for the _visibility_
|
||||
/// and _proxyVisibility_ attributes. If _visibility_ evaluates to
|
||||
/// "invisible", the prim is invisible. If _visibility_ evaluates to
|
||||
/// "inherited" then: If _proxyVisibility_ evaluates to "visible", then
|
||||
/// the prim is visible; if _proxyVisibility_ evaluates to "invisible",
|
||||
/// then the prim is invisible; if _proxyVisibility_ evaluates to
|
||||
/// "inherited", then the prim may either be visible or invisible,
|
||||
/// depending on a fallback value determined by the calling context.
|
||||
///
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token proxyVisibility = "inherited"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | inherited, invisible, visible |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetProxyVisibilityAttr() const;
|
||||
|
||||
/// See GetProxyVisibilityAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateProxyVisibilityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// RENDERVISIBILITY
|
||||
// --------------------------------------------------------------------- //
|
||||
///
|
||||
/// This attribute controls visibility for geometry with purpose
|
||||
/// "render".
|
||||
///
|
||||
/// Unlike overall _visibility_, _renderVisibility_ is uniform, and
|
||||
/// therefore cannot be animated.
|
||||
///
|
||||
/// Also unlike overall _visibility_, _renderVisibility_ is tri-state, in
|
||||
/// that a descendant with an opinion of "visible" overrides an ancestor
|
||||
/// opinion of "invisible".
|
||||
///
|
||||
/// The _renderVisibility_ attribute works in concert with the overall
|
||||
/// _visibility_ attribute: The visibility of a prim with purpose "render"
|
||||
/// is determined by the inherited values it receives for the _visibility_
|
||||
/// and _renderVisibility_ attributes. If _visibility_ evaluates to
|
||||
/// "invisible", the prim is invisible. If _visibility_ evaluates to
|
||||
/// "inherited" then: If _renderVisibility_ evaluates to "visible", then
|
||||
/// the prim is visible; if _renderVisibility_ evaluates to "invisible",
|
||||
/// then the prim is invisible; if _renderVisibility_ evaluates to
|
||||
/// "inherited", then the prim may either be visible or invisible,
|
||||
/// depending on a fallback value determined by the calling context.
|
||||
///
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token renderVisibility = "inherited"` |
|
||||
/// | C++ Type | TfToken |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
/// | \ref UsdGeomTokens "Allowed Values" | inherited, invisible, visible |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetRenderVisibilityAttr() const;
|
||||
|
||||
/// See GetRenderVisibilityAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateRenderVisibilityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_XFORM_H
|
||||
#define USDGEOM_GENERATED_XFORM_H
|
||||
|
||||
/// \file usdGeom/xform.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/xformable.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// XFORM //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomXform
|
||||
///
|
||||
/// Concrete prim schema for a transform, which implements Xformable
|
||||
///
|
||||
class UsdGeomXform : public UsdGeomXformable
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::ConcreteTyped;
|
||||
|
||||
/// Construct a UsdGeomXform on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomXform::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomXform(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomXformable(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomXform on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomXform(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomXform(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomXformable(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomXform();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomXform holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomXform(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomXform
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
|
||||
/// is defined (according to UsdPrim::IsDefined()) on this stage.
|
||||
///
|
||||
/// If a prim adhering to this schema at \p path is already defined on this
|
||||
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
|
||||
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
|
||||
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
|
||||
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
|
||||
/// current EditTarget for any nonexistent, or existing but not \a Defined
|
||||
/// ancestors.
|
||||
///
|
||||
/// The given \a 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 \a path cannot map to the current UsdEditTarget's
|
||||
/// namespace) issue an error and return an invalid \a 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.
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomXform
|
||||
Define(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,185 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_XFORM_CACHE_H
|
||||
#define PXR_USD_USD_GEOM_XFORM_CACHE_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/attributeQuery.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
|
||||
#include "pxr/usd/usdGeom/xformable.h"
|
||||
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
#include "pxr/base/tf/hashmap.h"
|
||||
#include "pxr/base/tf/token.h"
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
/// \class UsdGeomXformCache
|
||||
///
|
||||
/// A caching mechanism for transform matrices. For best performance, this
|
||||
/// object should be reused for multiple CTM queries.
|
||||
///
|
||||
/// Instances of this type can be copied, though using Swap() may result in
|
||||
/// better performance.
|
||||
///
|
||||
/// It is valid to cache prims from multiple stages in a single XformCache.
|
||||
///
|
||||
/// WARNING: this class does not automatically invalidate cached values based
|
||||
/// on changes to the stage from which values were cached. Additionally, a
|
||||
/// separate instance of this class should be used per-thread, calling the Get*
|
||||
/// methods from multiple threads is not safe, as they mutate internal state.
|
||||
///
|
||||
class UsdGeomXformCache
|
||||
{
|
||||
public:
|
||||
/// Construct a new XformCache for the specified \p time.
|
||||
USDGEOM_API
|
||||
explicit UsdGeomXformCache(const UsdTimeCode time);
|
||||
|
||||
/// Construct a new XformCache for UsdTimeCode::Default().
|
||||
USDGEOM_API
|
||||
UsdGeomXformCache();
|
||||
|
||||
/// Compute the transformation matrix for the given \p prim, including the
|
||||
/// transform authored on the Prim itself, if present.
|
||||
///
|
||||
/// \note This method may mutate internal cache state and is not thread
|
||||
/// safe.
|
||||
USDGEOM_API
|
||||
GfMatrix4d GetLocalToWorldTransform(const UsdPrim& prim);
|
||||
|
||||
/// Compute the transformation matrix for the given \p prim, but do NOT
|
||||
/// include the transform authored on the prim itself.
|
||||
///
|
||||
/// \note This method may mutate internal cache state and is not thread
|
||||
/// safe.
|
||||
USDGEOM_API
|
||||
GfMatrix4d GetParentToWorldTransform(const UsdPrim& prim);
|
||||
|
||||
/// Returns the local transformation of the prim. Uses the cached
|
||||
/// XformQuery to compute the result quickly. The \p resetsXformStack
|
||||
/// pointer must be valid. It will be set to true if \p prim resets
|
||||
/// the transform stack.
|
||||
/// The result of this call is cached.
|
||||
USDGEOM_API
|
||||
GfMatrix4d GetLocalTransformation(const UsdPrim &prim,
|
||||
bool *resetsXformStack);
|
||||
|
||||
/// Returns the result of concatenating all transforms beneath \p ancestor
|
||||
/// that affect \p prim. This includes the local transform of \p prim
|
||||
/// itself, but not the local transform of \p ancestor. If \p ancestor is
|
||||
/// not an ancestor of \p prim, the resulting transform is the
|
||||
/// local-to-world transformation of \p prim.
|
||||
/// The \p resetXformTsack pointer must be valid. If any intermediate prims
|
||||
/// reset the transform stack, \p resetXformStack will be set to true.
|
||||
/// Intermediate transforms are cached, but the result of this call itself
|
||||
/// is not cached.
|
||||
USDGEOM_API
|
||||
GfMatrix4d ComputeRelativeTransform(const UsdPrim &prim,
|
||||
const UsdPrim &ancestor,
|
||||
bool *resetXformStack);
|
||||
|
||||
/// Whether the attribute named \p attrName, belonging to the
|
||||
/// given \p prim affects the local transform value at the prim.
|
||||
///
|
||||
/// \note This method may mutate internal cache state and is not thread
|
||||
/// safe.
|
||||
USDGEOM_API
|
||||
bool IsAttributeIncludedInLocalTransform(const UsdPrim &prim,
|
||||
const TfToken &attrName);
|
||||
|
||||
/// Whether the local transformation value at the prim may vary over time.
|
||||
///
|
||||
/// \note This method may mutate internal cache state and is not thread
|
||||
/// safe.
|
||||
USDGEOM_API
|
||||
bool TransformMightBeTimeVarying(const UsdPrim &prim);
|
||||
|
||||
/// Whether the xform stack is reset at the given prim.
|
||||
///
|
||||
/// \note This method may mutate internal cache state and is not thread
|
||||
/// safe.
|
||||
USDGEOM_API
|
||||
bool GetResetXformStack(const UsdPrim &prim);
|
||||
|
||||
/// Clears all pre-cached values.
|
||||
USDGEOM_API
|
||||
void Clear();
|
||||
|
||||
/// Use the new \p time when computing values and may clear any existing
|
||||
/// values cached for the previous time. Setting \p time to the current time
|
||||
/// is a no-op.
|
||||
USDGEOM_API
|
||||
void SetTime(UsdTimeCode time);
|
||||
|
||||
/// Get the current time from which this cache is reading values.
|
||||
UsdTimeCode GetTime() { return _time; }
|
||||
|
||||
/// Swap the contents of this XformCache with \p other.
|
||||
USDGEOM_API
|
||||
void Swap(UsdGeomXformCache& other);
|
||||
|
||||
private:
|
||||
|
||||
// Traverses backwards the hierarchy starting from prim
|
||||
// all the way to the root and computes the ctm
|
||||
GfMatrix4d const* _GetCtm(const UsdPrim& prim);
|
||||
|
||||
// Map of cached values.
|
||||
struct _Entry {
|
||||
_Entry() = default;
|
||||
_Entry(const UsdGeomXformable::XformQuery & query_,
|
||||
const GfMatrix4d& ctm_,
|
||||
bool ctmIsValid_)
|
||||
: query(query_)
|
||||
, ctm(ctm_)
|
||||
, ctmIsValid(ctmIsValid_)
|
||||
{ }
|
||||
|
||||
UsdGeomXformable::XformQuery query;
|
||||
GfMatrix4d ctm;
|
||||
bool ctmIsValid;
|
||||
};
|
||||
|
||||
// Helper function to get or create a new entry for a prim in the ctm cache.
|
||||
_Entry * _GetCacheEntryForPrim(const UsdPrim &prim);
|
||||
|
||||
typedef TfHashMap<UsdPrim, _Entry, boost::hash<UsdPrim> > _PrimHashMap;
|
||||
_PrimHashMap _ctmCache;
|
||||
|
||||
// The time at which this stack is querying and caching attribute values.
|
||||
UsdTimeCode _time;
|
||||
};
|
||||
|
||||
#define USDGEOM_XFORM_CACHE_API_VERSION 1
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_USD_GEOM_XFORM_CACHE_H
|
||||
@@ -0,0 +1,380 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_XFORMCOMMONAPI_H
|
||||
#define USDGEOM_GENERATED_XFORMCOMMONAPI_H
|
||||
|
||||
/// \file usdGeom/xformCommonAPI.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/apiSchemaBase.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/usd/usdGeom/xformable.h"
|
||||
#include "pxr/usd/usdGeom/xformOp.h"
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// XFORMCOMMONAPI //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomXformCommonAPI
|
||||
///
|
||||
/// This class provides API for authoring and retrieving a standard set
|
||||
/// of component transformations which include a scale, a rotation, a
|
||||
/// scale-rotate pivot and a translation. The goal of the API is to enhance
|
||||
/// component-wise interchange. It achieves this by limiting the set of allowed
|
||||
/// basic ops and by specifying the order in which they are applied. In addition
|
||||
/// to the basic set of ops, the 'resetXformStack' bit can also be set to
|
||||
/// indicate whether the underlying xformable resets the parent transformation
|
||||
/// (i.e. does not inherit it's parent's transformation).
|
||||
///
|
||||
/// \sa UsdGeomXformCommonAPI::GetResetXformStack()
|
||||
/// \sa UsdGeomXformCommonAPI::SetResetXformStack()
|
||||
///
|
||||
/// The operator-bool for the class will inform you whether an existing
|
||||
/// xformable is compatible with this API.
|
||||
///
|
||||
/// The scale-rotate pivot is represented by a pair of (translate,
|
||||
/// inverse-translate) xformOps around the scale and rotate operations.
|
||||
/// The rotation operation can be any of the six allowed Euler angle sets.
|
||||
/// \sa UsdGeomXformOp::Type.
|
||||
///
|
||||
/// The xformOpOrder of an xformable that has all of the supported basic ops
|
||||
/// is as follows:
|
||||
/// ["xformOp:translate", "xformOp:translate:pivot", "xformOp:rotateXYZ",
|
||||
/// "xformOp:scale", "!invert!xformOp:translate:pivot"].
|
||||
///
|
||||
/// It is worth noting that all of the ops are optional. For example, an
|
||||
/// xformable may have only a translate or a rotate. It would still be
|
||||
/// considered as compatible with this API. Individual SetTranslate(),
|
||||
/// SetRotate(), SetScale() and SetPivot() methods are provided by this API
|
||||
/// to allow such sparse authoring.
|
||||
///
|
||||
class UsdGeomXformCommonAPI : public UsdAPISchemaBase
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI;
|
||||
|
||||
/// Construct a UsdGeomXformCommonAPI on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomXformCommonAPI::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomXformCommonAPI(const UsdPrim& prim=UsdPrim())
|
||||
: UsdAPISchemaBase(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomXformCommonAPI on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomXformCommonAPI(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomXformCommonAPI(const UsdSchemaBase& schemaObj)
|
||||
: UsdAPISchemaBase(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomXformCommonAPI();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomXformCommonAPI holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomXformCommonAPI(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomXformCommonAPI
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// Enumerates the rotation order of the 3-angle Euler rotation.
|
||||
enum RotationOrder {
|
||||
RotationOrderXYZ,
|
||||
RotationOrderXZY,
|
||||
RotationOrderYXZ,
|
||||
RotationOrderYZX,
|
||||
RotationOrderZXY,
|
||||
RotationOrderZYX
|
||||
};
|
||||
|
||||
/// Enumerates the categories of ops that can be handled by XformCommonAPI.
|
||||
/// For use with CreateXformOps().
|
||||
enum OpFlags {
|
||||
OpNone = 0,
|
||||
OpTranslate = 1,
|
||||
OpPivot = 2,
|
||||
OpRotate = 4,
|
||||
OpScale = 8,
|
||||
};
|
||||
|
||||
/// Return type for CreateXformOps().
|
||||
/// Stores the op of each type that is present on the prim.
|
||||
/// The order of members in this struct corresponds to the expected op order
|
||||
/// for XformCommonAPI.
|
||||
struct Ops {
|
||||
UsdGeomXformOp translateOp;
|
||||
UsdGeomXformOp pivotOp;
|
||||
UsdGeomXformOp rotateOp;
|
||||
UsdGeomXformOp scaleOp;
|
||||
UsdGeomXformOp inversePivotOp;
|
||||
};
|
||||
|
||||
/// Set values for the various component xformOps at a given \p time.
|
||||
///
|
||||
/// Calling this method will call all of the supported ops to be created,
|
||||
/// even if they only contain default (identity) values.
|
||||
///
|
||||
/// To author individual operations selectively, use the Set[OpType]()
|
||||
/// API.
|
||||
///
|
||||
/// \note Once the rotation order has been established for a given xformable
|
||||
/// (either because of an already defined (and compatible) rotate op or
|
||||
/// from calling SetXformVectors() or SetRotate()), it cannot be changed.
|
||||
///
|
||||
USDGEOM_API
|
||||
bool SetXformVectors(const GfVec3d &translation,
|
||||
const GfVec3f &rotation,
|
||||
const GfVec3f &scale,
|
||||
const GfVec3f &pivot,
|
||||
RotationOrder rotOrder,
|
||||
const UsdTimeCode time) const;
|
||||
|
||||
/// Retrieve values of the various component xformOps at a given \p time.
|
||||
/// Identity values are filled in for the component xformOps that don't
|
||||
/// exist or don't have an authored value.
|
||||
///
|
||||
/// \note This method works even on prims with an incompatible xform schema,
|
||||
/// i.e. when the bool operator returns false.
|
||||
///
|
||||
/// When the underlying xformable has an incompatible xform schema, it
|
||||
/// performs a full-on matrix decomposition to XYZ rotation order.
|
||||
///
|
||||
USDGEOM_API
|
||||
bool GetXformVectors(GfVec3d *translation,
|
||||
GfVec3f *rotation,
|
||||
GfVec3f *scale,
|
||||
GfVec3f *pivot,
|
||||
RotationOrder *rotOrder,
|
||||
const UsdTimeCode time) const;
|
||||
|
||||
/// Retrieve values of the various component xformOps at a given \p time.
|
||||
/// Identity values are filled in for the component xformOps that don't
|
||||
/// exist or don't have an authored value.
|
||||
///
|
||||
/// This method allows some additional flexibility for xform schemas that
|
||||
/// do not strictly adhere to the xformCommonAPI. For incompatible schemas,
|
||||
/// this method will attempt to reduce the schema into one from which
|
||||
/// component vectors can be extracted by accumulating xformOp transforms
|
||||
/// of the common types.
|
||||
///
|
||||
/// \note When the underlying xformable has a compatible xform schema, the
|
||||
/// usual component value extraction method is used instead. When the xform
|
||||
/// schema is incompatible and it cannot be reduced by accumulating
|
||||
/// transforms, it performs a full-on matrix decomposition to XYZ rotation
|
||||
/// order.
|
||||
///
|
||||
USDGEOM_API
|
||||
bool GetXformVectorsByAccumulation(GfVec3d* translation,
|
||||
GfVec3f* rotation,
|
||||
GfVec3f* scale,
|
||||
GfVec3f* pivot,
|
||||
UsdGeomXformCommonAPI::RotationOrder* rotOrder,
|
||||
const UsdTimeCode time) const;
|
||||
|
||||
/// Returns whether the xformable resets the transform stack.
|
||||
/// i.e., does not inherit the parent transformation.
|
||||
USDGEOM_API
|
||||
bool GetResetXformStack() const;
|
||||
|
||||
/// \anchor UsdGeomXformCommonAPI_Set_Individual_Ops
|
||||
/// \name API for setting individual ops independently.
|
||||
///
|
||||
/// @{
|
||||
|
||||
/// Set translation at \p time to \p translation.
|
||||
USDGEOM_API
|
||||
bool SetTranslate(const GfVec3d &translation,
|
||||
const UsdTimeCode time=UsdTimeCode::Default()) const;
|
||||
|
||||
/// Set pivot position at \p time to \p pivot.
|
||||
USDGEOM_API
|
||||
bool SetPivot(const GfVec3f &pivot,
|
||||
const UsdTimeCode time=UsdTimeCode::Default()) const;
|
||||
|
||||
/// Set rotation at \p time to \p rotation.
|
||||
USDGEOM_API
|
||||
bool SetRotate(const GfVec3f &rotation,
|
||||
UsdGeomXformCommonAPI::RotationOrder rotOrder=RotationOrderXYZ,
|
||||
const UsdTimeCode time=UsdTimeCode::Default()) const;
|
||||
|
||||
/// Set scale at \p time to \p scale.
|
||||
USDGEOM_API
|
||||
bool SetScale(const GfVec3f &scale,
|
||||
const UsdTimeCode time=UsdTimeCode::Default()) const;
|
||||
|
||||
/// Set whether the xformable resets the transform stack.
|
||||
/// i.e., does not inherit the parent transformation.
|
||||
USDGEOM_API
|
||||
bool SetResetXformStack(bool resetXformStack) const;
|
||||
|
||||
/// Creates the specified XformCommonAPI-compatible xform ops, or returns
|
||||
/// the existing ops if they already exist. If successful, returns an Ops
|
||||
/// object with all the ops on this prim, identified by type. If the
|
||||
/// requested xform ops couldn't be created or the prim is not
|
||||
/// XformCommonAPI-compatible, returns an Ops object with all invalid ops.
|
||||
///
|
||||
/// The \p rotOrder is only used if OpRotate is specified. Otherwise,
|
||||
/// it is ignored. (If you don't need to create a rotate op, you might find
|
||||
/// it helpful to use the other overload that takes no rotation order.)
|
||||
USDGEOM_API
|
||||
Ops CreateXformOps(
|
||||
RotationOrder rotOrder,
|
||||
OpFlags op1=OpNone,
|
||||
OpFlags op2=OpNone,
|
||||
OpFlags op3=OpNone,
|
||||
OpFlags op4=OpNone) const;
|
||||
|
||||
/// \overload
|
||||
/// This overload does not take a rotation order. If you specify
|
||||
/// OpRotate, then this overload assumes RotationOrderXYZ or the
|
||||
/// previously-authored rotation order. (If you do need to create a rotate
|
||||
/// op, you might find it helpful to use the other overload that explicitly
|
||||
/// takes a rotation order.)
|
||||
USDGEOM_API
|
||||
Ops CreateXformOps(
|
||||
OpFlags op1=OpNone,
|
||||
OpFlags op2=OpNone,
|
||||
OpFlags op3=OpNone,
|
||||
OpFlags op4=OpNone) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Computing transforms
|
||||
/// @{
|
||||
|
||||
/// Return the 4x4 matrix that applies the rotation encoded by rotation
|
||||
/// vector \p rotation using the rotation order \p rotationOrder.
|
||||
///
|
||||
/// \deprecated Please use the result of ConvertRotationOrderToOpType()
|
||||
/// along with UsdGeomXformOp::GetOpTransform() instead.
|
||||
USDGEOM_API
|
||||
static GfMatrix4d GetRotationTransform(
|
||||
const GfVec3f &rotation,
|
||||
const UsdGeomXformCommonAPI::RotationOrder rotationOrder);
|
||||
|
||||
/// @}
|
||||
|
||||
/// Converts the given \p rotOrder to the corresponding value in the
|
||||
/// UsdGeomXformOp::Type enum. For example, RotationOrderYZX corresponds to
|
||||
/// TypeRotateYZX. Raises a coding error if \p rotOrder is not one of the
|
||||
/// named enumerators of RotationOrder.
|
||||
USDGEOM_API
|
||||
static UsdGeomXformOp::Type ConvertRotationOrderToOpType(
|
||||
RotationOrder rotOrder);
|
||||
|
||||
/// Converts the given \p opType to the corresponding value in the
|
||||
/// UsdGeomXformCommonAPI::RotationOrder enum. For example, TypeRotateYZX
|
||||
/// corresponds to RotationOrderYZX. Raises a coding error if \p opType is
|
||||
/// not convertible to RotationOrder (i.e., if it isn't a three-axis
|
||||
/// rotation) and returns the default RotationOrderXYZ instead.
|
||||
USDGEOM_API
|
||||
static RotationOrder ConvertOpTypeToRotationOrder(
|
||||
UsdGeomXformOp::Type opType);
|
||||
|
||||
/// Whether the given \p opType has a corresponding value in the
|
||||
/// UsdGeomXformCommonAPI::RotationOrder enum (i.e., whether it is a
|
||||
/// three-axis rotation).
|
||||
USDGEOM_API
|
||||
static bool CanConvertOpTypeToRotationOrder(
|
||||
UsdGeomXformOp::Type opType);
|
||||
|
||||
protected:
|
||||
/// Returns whether the underlying xformable is compatible with the API.
|
||||
USDGEOM_API
|
||||
bool _IsCompatible() const override;
|
||||
};
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,612 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_USD_GEOM_XFORM_OP_H
|
||||
#define PXR_USD_USD_GEOM_XFORM_OP_H
|
||||
|
||||
/// \file usdGeom/xformOp.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usd/attribute.h"
|
||||
#include "pxr/usd/usd/attributeQuery.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
#include "pxr/base/tf/staticTokens.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
|
||||
/// \hideinitializer
|
||||
#define USDGEOM_XFORM_OP_TYPES \
|
||||
(translate) \
|
||||
(scale) \
|
||||
(rotateX) \
|
||||
(rotateY) \
|
||||
(rotateZ) \
|
||||
(rotateXYZ) \
|
||||
(rotateXZY) \
|
||||
(rotateYXZ) \
|
||||
(rotateYZX) \
|
||||
(rotateZXY) \
|
||||
(rotateZYX) \
|
||||
(orient) \
|
||||
(transform) \
|
||||
((resetXformStack, "!resetXformStack!"))
|
||||
|
||||
/// \anchor UsdGeomXformOpTypes
|
||||
/// Provides TfToken's for use in conjunction with UsdGeomXformable::Add
|
||||
/// XformOp() and UsdGeomXformOp::GetOpType(), to establish op type.
|
||||
///
|
||||
/// The component operation names and their meanings are:
|
||||
/// \li <b>translate</b> - XYZ translation
|
||||
/// \li <b>scale</b> - XYZ scale
|
||||
/// \li <b>rotateX</b> - rotation about the X axis, <b>in degrees</b>
|
||||
/// \li <b>rotateY</b> - rotation about the Y axis, <b>in degrees</b>
|
||||
/// \li <b>rotateZ</b> - rotation about the Z axis, <b>in degrees</b>
|
||||
/// \li <b>rotateXYZ, rotateXZY, rotateYXZ, rotateYZX, rotateZXY, rotateZYX</b>
|
||||
/// - a set of three canonical Euler rotations, packed into a single
|
||||
/// Vec3, for conciseness and efficiency of reading. The \\em first
|
||||
/// axis named is the most local, so a single rotateXYZ is equivalent to
|
||||
/// the ordered ops "rotateZ rotateY rotateX". See also
|
||||
/// \ref usdGeom_rotationPackingOrder "note on rotation packing order."
|
||||
/// \li <b>orient</b> - arbitrary axis/angle rotation, expressed as a quaternion
|
||||
/// \li <b>transform</b> - 4x4 matrix transformation
|
||||
/// \li <b>resetXformStack</b> - when appearing as the first op, instructs
|
||||
/// client that the transform stack should be cleared of any inherited
|
||||
/// transformation prior to processing the rest of the prims ops. It is
|
||||
/// an error for resetXformStack to appear anywhere other than as the
|
||||
/// first element in \em xformOpOrder.
|
||||
TF_DECLARE_PUBLIC_TOKENS(UsdGeomXformOpTypes, USDGEOM_API, USDGEOM_XFORM_OP_TYPES);
|
||||
|
||||
/// \class UsdGeomXformOp
|
||||
///
|
||||
/// Schema wrapper for UsdAttribute for authoring and computing
|
||||
/// transformation operations, as consumed by UsdGeomXformable schema.
|
||||
///
|
||||
/// The semantics of an op are determined primarily by its name, which allows
|
||||
/// us to decode an op very efficiently. All ops are independent attributes,
|
||||
/// which must live in the "xformOp" property namespace. The op's primary name
|
||||
/// within the namespace must be one of \ref UsdGeomXformOpTypes, which
|
||||
/// determines the type of transformation operation, and its secondary name
|
||||
/// (or suffix) within the namespace (which is not required to exist), can be
|
||||
/// any name that distinguishes it from other ops of the same type. Suffixes
|
||||
/// are generally imposed by higer level xform API schemas.
|
||||
///
|
||||
/// \anchor usdGeom_rotationPackingOrder
|
||||
/// \note
|
||||
/// <b>On packing order of rotateABC triples</b><br>
|
||||
/// The order in which the axis rotations are recorded in a Vec3* for the
|
||||
/// six \em rotateABC Euler triples <b>is always the same:</b> vec[0] = X,
|
||||
/// vec[1] = Y, vec[2] = Z . The \em A, \em B, \em C in the op name dictate
|
||||
/// the order in which their corresponding elements are consumed by the
|
||||
/// rotation, not how they are laid out.
|
||||
///
|
||||
class UsdGeomXformOp
|
||||
{
|
||||
public:
|
||||
|
||||
/// Enumerates the set of all transformation operation types.
|
||||
enum Type {
|
||||
TypeInvalid, ///< Represents an invalid xformOp.
|
||||
TypeTranslate, ///< XYZ translation.
|
||||
TypeScale, ///< XYZ scale.
|
||||
TypeRotateX, ///< Rotation about the X-axis, <b>in degrees</b>.
|
||||
TypeRotateY, ///< Rotation about the Y-axis, <b>in degrees</b>.
|
||||
TypeRotateZ, ///< Rotation about the Z-axis, <b>in degrees</b>.
|
||||
TypeRotateXYZ, ///< Set of 3 canonical Euler rotations
|
||||
/// \ref usdGeom_rotationPackingOrder "in XYZ order"
|
||||
TypeRotateXZY, ///< Set of 3 canonical Euler rotations
|
||||
/// \ref usdGeom_rotationPackingOrder "in XZY order"
|
||||
TypeRotateYXZ, ///< Set of 3 canonical Euler rotations
|
||||
/// \ref usdGeom_rotationPackingOrder "in YXZ order"
|
||||
TypeRotateYZX, ///< Set of 3 canonical Euler rotations
|
||||
/// \ref usdGeom_rotationPackingOrder "in YZX order"
|
||||
TypeRotateZXY, ///< Set of 3 canonical Euler rotations
|
||||
/// \ref usdGeom_rotationPackingOrder "in ZXY order"
|
||||
TypeRotateZYX, ///< Set of 3 canonical Euler rotations
|
||||
/// \ref usdGeom_rotationPackingOrder "in ZYX order"
|
||||
TypeOrient, ///< Arbitrary axis/angle rotation, expressed as a quaternion.
|
||||
TypeTransform ///< A 4x4 matrix transformation.
|
||||
};
|
||||
|
||||
/// Precision with which the value of the tranformation operation is encoded.
|
||||
enum Precision {
|
||||
PrecisionDouble, ///< Double precision
|
||||
PrecisionFloat, ///< Floating-point precision
|
||||
PrecisionHalf ///< Half-float precision
|
||||
};
|
||||
|
||||
// Default constructor returns an invalid XformOp. Exists for
|
||||
// container classes
|
||||
UsdGeomXformOp()
|
||||
{
|
||||
/* NOTHING */
|
||||
}
|
||||
|
||||
/// Speculative constructor that will produce a valid UsdGeomXformOp when
|
||||
/// \p attr already represents an attribute that is XformOp, and
|
||||
/// produces an \em invalid XformOp otherwise (i.e.
|
||||
/// explicit-bool conversion operator will return false).
|
||||
///
|
||||
/// Calling \c UsdGeomXformOp::IsXformOp(attr) will return the same truth
|
||||
/// value as this constructor, but if you plan to subsequently use the
|
||||
/// XformOp anyways, just use this constructor.
|
||||
///
|
||||
/// \p isInverseOp is set to true to indicate an inverse transformation
|
||||
/// op.
|
||||
///
|
||||
/// This constructor exists mainly for internal use. Clients should use
|
||||
/// AddXformOp API (or one of Add*Op convenience API) to create and retain
|
||||
/// a copy of an UsdGeomXformOp object.
|
||||
///
|
||||
USDGEOM_API
|
||||
explicit UsdGeomXformOp(const UsdAttribute &attr, bool isInverseOp=false);
|
||||
|
||||
// -------------------------------------------------------
|
||||
/// \name Static Helper API
|
||||
// -------------------------------------------------------
|
||||
|
||||
/// Test whether a given UsdAttribute represents valid XformOp, which
|
||||
/// implies that creating a UsdGeomXformOp from the attribute will succeed.
|
||||
///
|
||||
/// Success implies that \c attr.IsDefined() is true.
|
||||
USDGEOM_API
|
||||
static bool IsXformOp(const UsdAttribute &attr);
|
||||
|
||||
/// Test whether a given attrbute name represents a valid XformOp, which
|
||||
/// implies that creating a UsdGeomXformOp from the corresponding
|
||||
/// UsdAttribute will succeed.
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool IsXformOp(const TfToken &attrName);
|
||||
|
||||
/// Returns the TfToken used to encode the given \p opType.
|
||||
/// Note that an empty TfToken is used to represent TypeInvalid
|
||||
USDGEOM_API
|
||||
static TfToken const &GetOpTypeToken(Type const opType);
|
||||
|
||||
/// Returns the Type enum associated with the given \p opTypeToken.
|
||||
USDGEOM_API
|
||||
static Type GetOpTypeEnum(TfToken const &opTypeToken);
|
||||
|
||||
/// Returns the precision corresponding to the given value typeName.
|
||||
USDGEOM_API
|
||||
static Precision GetPrecisionFromValueTypeName(const SdfValueTypeName& typeName);
|
||||
|
||||
/// Returns the value typeName token that corresponds to the given
|
||||
/// combination of \p opType and \p precision.
|
||||
USDGEOM_API
|
||||
static const SdfValueTypeName &GetValueTypeName(const Type opType,
|
||||
const Precision precision);
|
||||
|
||||
/// Returns the xformOp's name as it appears in xformOpOrder, given
|
||||
/// the opType, the (optional) suffix and whether it is an inverse
|
||||
/// operation.
|
||||
USDGEOM_API
|
||||
static TfToken GetOpName(const Type opType,
|
||||
const TfToken &opSuffix=TfToken(),
|
||||
bool inverse=false);
|
||||
|
||||
// -------------------------------------------------------
|
||||
/// \name Data Encoding Queries
|
||||
// -------------------------------------------------------
|
||||
|
||||
/// Return the operation type of this op, one of \ref UsdGeomXformOp::Type
|
||||
Type GetOpType() const {
|
||||
return _opType;
|
||||
}
|
||||
|
||||
/// Returns the precision level of the xform op.
|
||||
USDGEOM_API
|
||||
Precision GetPrecision() const;
|
||||
|
||||
/// Returns whether the xformOp represents an inverse operation.
|
||||
bool IsInverseOp() const {
|
||||
return _isInverseOp;
|
||||
}
|
||||
|
||||
/// Returns the opName as it appears in the xformOpOrder attribute.
|
||||
///
|
||||
/// This will begin with "!invert!:xformOp:" if it is an inverse xform
|
||||
/// operation. If it is not an inverse xformOp, it will begin with 'xformOp:'.
|
||||
///
|
||||
/// This will be empty for an invalid xformOp.
|
||||
///
|
||||
USDGEOM_API
|
||||
TfToken GetOpName() const;
|
||||
|
||||
/// Does this op have the given suffix in its name.
|
||||
USDGEOM_API
|
||||
bool HasSuffix(TfToken const &suffix) const;
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/// \name Computing with Ops
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/// We allow ops to be encoded with varying degrees of precision,
|
||||
/// depending on the clients needs and constraints. GetAs() will
|
||||
/// attempt to convert the stored data to the requested datatype.
|
||||
///
|
||||
/// Note this accessor incurs some overhead beyond Get()'ing the
|
||||
/// value as a VtValue and dealing with the results yourself.
|
||||
///
|
||||
/// \return true if a value was successfully read \em and converted
|
||||
/// to the requested datatype (see \ref VtValue::Cast()), false
|
||||
/// otherwise. A problem reading or failure to convert will cause
|
||||
/// an error to be emitted.
|
||||
///
|
||||
/// \note the requested type \p T must be constructable by assignment
|
||||
template <typename T>
|
||||
bool GetAs(T* value, UsdTimeCode time) const {
|
||||
VtValue v;
|
||||
if (!Get(&v, time)) {
|
||||
return false;
|
||||
}
|
||||
v.Cast<T>();
|
||||
if (v.IsEmpty()){
|
||||
TfType thisType = GetTypeName().GetType();
|
||||
TF_CODING_ERROR("Unable to convert xformOp %s's value from %s to "
|
||||
"requested type %s.", GetAttr().GetPath().GetText(),
|
||||
thisType.GetTypeName().c_str(),
|
||||
TfType::GetCanonicalTypeName(typeid(*value)).c_str());
|
||||
return false;
|
||||
}
|
||||
*value = v.UncheckedGet<T>();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Return the 4x4 matrix that applies the transformation encoded
|
||||
/// by op \p opType and data value \p opVal.
|
||||
///
|
||||
/// If \p isInverseOp is true, then the inverse of the tranformation
|
||||
/// represented by the op/value pair is returned.
|
||||
///
|
||||
/// An error will be issued if \p opType is not one of the values in the enum
|
||||
/// \ref UsdGeomXformOp::Type or if \p opVal cannot be converted
|
||||
/// to a suitable input to \p opType
|
||||
USDGEOM_API
|
||||
static GfMatrix4d GetOpTransform(Type const opType,
|
||||
VtValue const &opVal,
|
||||
bool isInverseOp=false);
|
||||
|
||||
|
||||
/// Return the 4x4 matrix that applies the transformation encoded
|
||||
/// in this op at \p time.
|
||||
///
|
||||
/// Returns the identity matrix and issues a coding error if the op is
|
||||
/// invalid.
|
||||
///
|
||||
/// If the op is valid, but has no authored value, the identity
|
||||
/// matrix is returned and no error is issued.
|
||||
///
|
||||
USDGEOM_API
|
||||
GfMatrix4d GetOpTransform(UsdTimeCode time) const;
|
||||
|
||||
/// Determine whether there is any possibility that this op's value
|
||||
/// may vary over time.
|
||||
///
|
||||
/// The determination is based on a snapshot of the authored state of the
|
||||
/// op, and may become invalid in the face of further authoring.
|
||||
bool MightBeTimeVarying() const {
|
||||
return boost::apply_visitor(_GetMightBeTimeVarying(), _attr);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
/// \name UsdAttribute API
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
/// Allow UsdGeomXformOp to auto-convert to UsdAttribute, so you can
|
||||
/// pass a UsdGeomXformOp to any function that accepts a UsdAttribute or
|
||||
/// const-ref thereto.
|
||||
operator UsdAttribute const& () const { return GetAttr(); }
|
||||
|
||||
/// Explicit UsdAttribute extractor
|
||||
UsdAttribute const &GetAttr() const {
|
||||
return boost::apply_visitor(_GetAttr(), _attr);
|
||||
}
|
||||
|
||||
/// Return true if the wrapped UsdAttribute::IsDefined(), and in
|
||||
/// addition the attribute is identified as a XformOp.
|
||||
bool IsDefined() const { return IsXformOp(GetAttr()); }
|
||||
|
||||
public:
|
||||
/// \anchor UsdGeomXformOp_explicit_bool
|
||||
/// Explicit bool conversion operator. An XformOp object converts to
|
||||
/// \c true iff it is valid for querying and authoring values and metadata,
|
||||
/// (which is identically equivalent to IsDefined()), and converts to
|
||||
/// \c false otherwise.
|
||||
explicit operator bool() const {
|
||||
return IsDefined();
|
||||
}
|
||||
|
||||
/// Equality comparison. Return true if \a lhs and \a rhs represent the
|
||||
/// same underlying UsdAttribute, false otherwise.
|
||||
friend bool operator==(const UsdGeomXformOp &lhs,
|
||||
const UsdGeomXformOp &rhs) {
|
||||
return lhs.GetAttr() == rhs.GetAttr();
|
||||
}
|
||||
|
||||
/// Inequality comparison. Return false if \a lhs and \a rhs represent the
|
||||
/// same underlying UsdAttribute, true otherwise.
|
||||
friend bool operator!=(const UsdGeomXformOp &lhs,
|
||||
const UsdGeomXformOp &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/// \sa UsdAttribute::GetName()
|
||||
TfToken const &GetName() const { return GetAttr().GetName(); }
|
||||
|
||||
/// \sa UsdAttribute::GetBaseName()
|
||||
TfToken GetBaseName() const { return GetAttr().GetBaseName(); }
|
||||
|
||||
/// \sa UsdAttribute::GetNamespace()
|
||||
TfToken GetNamespace() const { return GetAttr().GetNamespace(); }
|
||||
|
||||
/// \sa UsdAttribute::SplitName()
|
||||
std::vector<std::string> SplitName() const { return GetAttr().SplitName(); };
|
||||
|
||||
/// \sa UsdAttribute::GetTypeName()
|
||||
SdfValueTypeName GetTypeName() const { return GetAttr().GetTypeName(); }
|
||||
|
||||
/// Get the attribute value of the XformOp at \p time.
|
||||
///
|
||||
/// \note For inverted ops, this returns the raw, uninverted value.
|
||||
///
|
||||
template <typename T>
|
||||
bool Get(T* value, UsdTimeCode time = UsdTimeCode::Default()) const {
|
||||
return boost::apply_visitor(_Get<T>(value, time), _attr);
|
||||
}
|
||||
|
||||
/// Set the attribute value of the XformOp at \p time
|
||||
///
|
||||
/// \note This only works on non-inverse operations. If invoked on
|
||||
/// an inverse xform operation, a coding error is issued and no value is
|
||||
/// authored.
|
||||
///
|
||||
template <typename T>
|
||||
bool Set(T const & value, UsdTimeCode time = UsdTimeCode::Default()) const {
|
||||
// Issue a coding error and return without setting value,
|
||||
// if this is an inverse op.
|
||||
if (_isInverseOp) {
|
||||
TF_CODING_ERROR("Cannot set a value on the inverse xformOp '%s'. "
|
||||
"Please set value on the paired non-inverse xformOp instead.",
|
||||
GetOpName().GetText());
|
||||
return false;
|
||||
}
|
||||
|
||||
return GetAttr().Set(value, time);
|
||||
}
|
||||
|
||||
/// Populates the list of time samples at which the associated attribute
|
||||
/// is authored.
|
||||
bool GetTimeSamples(std::vector<double> *times) const {
|
||||
return boost::apply_visitor(_GetTimeSamples(times), _attr);
|
||||
}
|
||||
|
||||
/// Populates the list of time samples within the given \p interval,
|
||||
/// at which the associated attribute is authored.
|
||||
bool GetTimeSamplesInInterval(const GfInterval &interval,
|
||||
std::vector<double> *times) const {
|
||||
return boost::apply_visitor(
|
||||
_GetTimeSamplesInInterval(interval, times), _attr);
|
||||
}
|
||||
|
||||
/// Returns the number of time samples authored for this xformOp.
|
||||
size_t GetNumTimeSamples() const {
|
||||
return boost::apply_visitor(_GetNumTimeSamples(), _attr);
|
||||
}
|
||||
|
||||
private:
|
||||
struct _ValidAttributeTagType {};
|
||||
|
||||
public:
|
||||
// Allow clients that guarantee \p attr is valid avoid having
|
||||
// UsdGeomXformOp's ctor check again.
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp(const UsdAttribute &attr, bool isInverseOp,
|
||||
_ValidAttributeTagType);
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp(UsdAttributeQuery &&query, bool isInverseOp,
|
||||
_ValidAttributeTagType);
|
||||
private:
|
||||
friend class UsdGeomXformable;
|
||||
|
||||
// Shared initialization function.
|
||||
void _Init();
|
||||
|
||||
// Return the op-type for the string value \p str.
|
||||
static Type _GetOpTypeEnumFromCString(char const *str, size_t len);
|
||||
|
||||
// Returns the attribute belonging to \p prim that corresponds to the
|
||||
// given \p opName. It also populates the output parameter \p isInverseOp
|
||||
// appropriately.
|
||||
//
|
||||
// The attribute that's returned will be invalid if the
|
||||
// corresponding xformOp attribute doesn't exist on the prim.
|
||||
//
|
||||
static UsdAttribute _GetXformOpAttr(UsdPrim const& prim,
|
||||
const TfToken &opName, bool *isInverseOp);
|
||||
|
||||
// Private method for creating and using an attribute query interally for
|
||||
// this xformOp.
|
||||
void _CreateAttributeQuery() const {
|
||||
_attr = UsdAttributeQuery(GetAttr());
|
||||
}
|
||||
|
||||
// Factory for UsdGeomXformable's use, so that we can encapsulate the
|
||||
// logic of what discriminates XformOp in this class, while
|
||||
// preserving the pattern that attributes can only be created
|
||||
// via their container objects.
|
||||
//
|
||||
// \p opType must be one of UsdGeomXformOp::Type
|
||||
//
|
||||
// \p precision must be one of UsdGeomXformOp::Precision.
|
||||
//
|
||||
// \return an invalid UsdGeomXformOp if we failed to create a valid
|
||||
// attribute, a valid UsdGeomXformOp otherwise. It is not an
|
||||
// error to create over an existing, compatible attribute.
|
||||
//
|
||||
// It is a failed verification for \p prim to be invalid/expired
|
||||
//
|
||||
// \sa UsdPrim::CreateAttribute()
|
||||
UsdGeomXformOp(UsdPrim const& prim, Type const opType,
|
||||
Precision const precision, TfToken const &opSuffix=TfToken(),
|
||||
bool inverse=false);
|
||||
|
||||
// UsdAttributeQuery already contains a copy of the associated UsdAttribute.
|
||||
// To minimize the memory usage, we only store one or the other.
|
||||
//
|
||||
// The lifetime of a UsdAttributeQuery needs to be managed very carefully as
|
||||
// it gets invalidated whenever the associated attribute is authored.
|
||||
// Hence, access to the creation of an attribute query is restricted inside
|
||||
// a private member function named _CreateAttributeQuery().
|
||||
//
|
||||
mutable boost::variant<UsdAttribute, UsdAttributeQuery> _attr;
|
||||
|
||||
Type _opType;
|
||||
bool _isInverseOp;
|
||||
|
||||
// Visitor for getting xformOp value.
|
||||
template <class T>
|
||||
struct _Get : public boost::static_visitor<bool>
|
||||
{
|
||||
_Get(T *value_,
|
||||
UsdTimeCode time_ = UsdTimeCode::Default()) : value (value_), time(time_)
|
||||
{}
|
||||
|
||||
bool operator()(const UsdAttribute &attr) const
|
||||
{
|
||||
return attr.Get(value, time);
|
||||
}
|
||||
|
||||
bool operator()(const UsdAttributeQuery &attrQuery) const
|
||||
{
|
||||
return attrQuery.Get(value, time);
|
||||
}
|
||||
|
||||
T *value;
|
||||
UsdTimeCode time;
|
||||
};
|
||||
|
||||
// Visitor for getting a const-reference to the UsdAttribute.
|
||||
struct _GetAttr : public boost::static_visitor<const UsdAttribute &> {
|
||||
|
||||
_GetAttr() {}
|
||||
|
||||
const UsdAttribute &operator()(const UsdAttribute &attr) const
|
||||
{
|
||||
return attr;
|
||||
}
|
||||
|
||||
const UsdAttribute &operator()(const UsdAttributeQuery &attrQuery) const
|
||||
{
|
||||
return attrQuery.GetAttribute();
|
||||
}
|
||||
};
|
||||
|
||||
// Visitor for getting all the time samples.
|
||||
struct _GetTimeSamples : public boost::static_visitor<bool> {
|
||||
|
||||
_GetTimeSamples(std::vector<double> *times_) : times(times_) {}
|
||||
|
||||
bool operator()(const UsdAttribute &attr) const
|
||||
{
|
||||
return attr.GetTimeSamples(times);
|
||||
}
|
||||
|
||||
bool operator()(const UsdAttributeQuery &attrQuery) const
|
||||
{
|
||||
return attrQuery.GetTimeSamples(times);
|
||||
}
|
||||
|
||||
std::vector<double> *times;
|
||||
};
|
||||
|
||||
// Visitor for getting all the time samples within a given interval.
|
||||
struct _GetTimeSamplesInInterval : public boost::static_visitor<bool> {
|
||||
|
||||
_GetTimeSamplesInInterval(const GfInterval &interval_,
|
||||
std::vector<double> *times_)
|
||||
: interval(interval_), times(times_)
|
||||
{}
|
||||
|
||||
bool operator()(const UsdAttribute &attr) const
|
||||
{
|
||||
return attr.GetTimeSamplesInInterval(interval, times);
|
||||
}
|
||||
|
||||
bool operator()(const UsdAttributeQuery &attrQuery) const
|
||||
{
|
||||
return attrQuery.GetTimeSamplesInInterval(interval, times);
|
||||
}
|
||||
|
||||
const GfInterval &interval;
|
||||
std::vector<double> *times;
|
||||
};
|
||||
|
||||
// Visitor for getting the number of time samples.
|
||||
struct _GetNumTimeSamples : public boost::static_visitor<size_t> {
|
||||
|
||||
_GetNumTimeSamples() {}
|
||||
|
||||
size_t operator()(const UsdAttribute &attr) const
|
||||
{
|
||||
return attr.GetNumTimeSamples();
|
||||
}
|
||||
|
||||
size_t operator()(const UsdAttributeQuery &attrQuery) const
|
||||
{
|
||||
return attrQuery.GetNumTimeSamples();
|
||||
}
|
||||
};
|
||||
|
||||
// Visitor for determining whether the op might vary over time.
|
||||
struct _GetMightBeTimeVarying : public boost::static_visitor<bool> {
|
||||
|
||||
_GetMightBeTimeVarying() {}
|
||||
|
||||
bool operator()(const UsdAttribute &attr) const
|
||||
{
|
||||
return attr.ValueMightBeTimeVarying();
|
||||
}
|
||||
|
||||
bool operator()(const UsdAttributeQuery &attrQuery) const
|
||||
{
|
||||
return attrQuery.ValueMightBeTimeVarying();
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // USD_XFORMOP_H
|
||||
@@ -0,0 +1,847 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef USDGEOM_GENERATED_XFORMABLE_H
|
||||
#define USDGEOM_GENERATED_XFORMABLE_H
|
||||
|
||||
/// \file usdGeom/xformable.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/usdGeom/api.h"
|
||||
#include "pxr/usd/usdGeom/imageable.h"
|
||||
#include "pxr/usd/usd/prim.h"
|
||||
#include "pxr/usd/usd/stage.h"
|
||||
#include "pxr/usd/usdGeom/tokens.h"
|
||||
|
||||
#include "pxr/usd/usdGeom/xformOp.h"
|
||||
#include <vector>
|
||||
|
||||
#include "pxr/base/vt/value.h"
|
||||
|
||||
#include "pxr/base/gf/vec3d.h"
|
||||
#include "pxr/base/gf/vec3f.h"
|
||||
#include "pxr/base/gf/matrix4d.h"
|
||||
|
||||
#include "pxr/base/tf/token.h"
|
||||
#include "pxr/base/tf/type.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class SdfAssetPath;
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// XFORMABLE //
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
/// \class UsdGeomXformable
|
||||
///
|
||||
/// Base class for all transformable prims, which allows arbitrary
|
||||
/// sequences of component affine transformations to be encoded.
|
||||
///
|
||||
/// \note
|
||||
/// You may find it useful to review \ref UsdGeom_LinAlgBasics while reading
|
||||
/// this class description.
|
||||
///
|
||||
/// <b>Supported Component Transformation Operations</b>
|
||||
///
|
||||
/// UsdGeomXformable currently supports arbitrary sequences of the following
|
||||
/// operations, each of which can be encoded in an attribute of the proper
|
||||
/// shape in any supported precision:
|
||||
/// \li translate - 3D
|
||||
/// \li scale - 3D
|
||||
/// \li rotateX - 1D angle in degrees
|
||||
/// \li rotateY - 1D angle in degrees
|
||||
/// \li rotateZ - 1D angle in degrees
|
||||
/// \li rotateABC - 3D where ABC can be any combination of the six principle
|
||||
/// Euler Angle sets: XYZ, XZY, YXZ, YZX, ZXY, ZYX. See
|
||||
/// \ref usdGeom_rotationPackingOrder "note on rotation packing order"
|
||||
/// \li orient - 4D (quaternion)
|
||||
/// \li transform - 4x4D
|
||||
///
|
||||
/// <b>Creating a Component Transformation</b>
|
||||
///
|
||||
/// To add components to a UsdGeomXformable prim, simply call AddXformOp()
|
||||
/// with the desired op type, as enumerated in \ref UsdGeomXformOp::Type,
|
||||
/// and the desired precision, which is one of \ref UsdGeomXformOp::Precision.
|
||||
/// Optionally, you can also provide an "op suffix" for the operator that
|
||||
/// disambiguates it from other components of the same type on the same prim.
|
||||
/// Application-specific transform schemas can use the suffixes to fill a role
|
||||
/// similar to that played by AbcGeom::XformOp's "Hint" enums for their own
|
||||
/// round-tripping logic.
|
||||
///
|
||||
/// We also provide specific "Add" API for each type, for clarity and
|
||||
/// conciseness, e.g. AddTranslateOp(), AddRotateXYZOp() etc.
|
||||
///
|
||||
/// AddXformOp() will return a UsdGeomXformOp object, which is a schema on a
|
||||
/// newly created UsdAttribute that provides convenience API for authoring
|
||||
/// and computing the component transformations. The UsdGeomXformOp can then
|
||||
/// be used to author any number of timesamples and default for the op.
|
||||
///
|
||||
/// Each successive call to AddXformOp() adds an operator that will be applied
|
||||
/// "more locally" than the preceding operator, just as if we were pushing
|
||||
/// transforms onto a transformation stack - which is precisely what should
|
||||
/// happen when the operators are consumed by a reader.
|
||||
///
|
||||
/// \note
|
||||
/// If you can, please try to use the UsdGeomXformCommonAPI, which wraps
|
||||
/// the UsdGeomXformable with an interface in which Op creation is taken
|
||||
/// care of for you, and there is a much higher chance that the data you
|
||||
/// author will be importable without flattening into other DCC's, as it
|
||||
/// conforms to a fixed set of Scale-Rotate-Translate Ops.
|
||||
///
|
||||
/// \sa \ref usdGeom_xformableExamples "Using the Authoring API"
|
||||
///
|
||||
/// <b>Data Encoding and Op Ordering</b>
|
||||
///
|
||||
/// Because there is no "fixed schema" of operations, all of the attributes
|
||||
/// that encode transform operations are dynamic, and are scoped in
|
||||
/// the namespace "xformOp". The second component of an attribute's name provides
|
||||
/// the \em type of operation, as listed above. An "xformOp" attribute can
|
||||
/// have additional namespace components derived from the \em opSuffix argument
|
||||
/// to the AddXformOp() suite of methods, which provides a preferred way of
|
||||
/// naming the ops such that we can have multiple "translate" ops with unique
|
||||
/// attribute names. For example, in the attribute named
|
||||
/// "xformOp:translate:maya:pivot", "translate" is the type of operation and
|
||||
/// "maya:pivot" is the suffix.
|
||||
///
|
||||
/// The following ordered list of attribute declarations in usda
|
||||
/// define a basic Scale-Rotate-Translate with XYZ Euler angles, wherein the
|
||||
/// translation is double-precision, and the remainder of the ops are single,
|
||||
/// in which we will:
|
||||
///
|
||||
/// <ol>
|
||||
/// <li> Scale by 2.0 in each dimension
|
||||
/// <li> Rotate about the X, Y, and Z axes by 30, 60, and 90 degrees, respectively
|
||||
/// <li> Translate by 100 units in the Y direction
|
||||
/// </ol>
|
||||
///
|
||||
/// \code
|
||||
/// float3 xformOp:rotateXYZ = (30, 60, 90)
|
||||
/// float3 xformOp:scale = (2, 2, 2)
|
||||
/// double3 xformOp:translate = (0, 100, 0)
|
||||
/// uniform token[] xformOpOrder = [ "xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale" ]
|
||||
/// \endcode
|
||||
///
|
||||
/// The attributes appear in the dictionary order in which USD, by default,
|
||||
/// sorts them. To ensure the ops are recovered and evaluated in the correct
|
||||
/// order, the schema introduces the **xformOpOrder** attribute, which
|
||||
/// contains the names of the op attributes, in the precise sequence in which
|
||||
/// they should be pushed onto a transform stack. **Note** that the order is
|
||||
/// opposite to what you might expect, given the matrix algebra described in
|
||||
/// \ref UsdGeom_LinAlgBasics. This also dictates order of op creation,
|
||||
/// since each call to AddXformOp() adds a new op to the end of the
|
||||
/// \b xformOpOrder array, as a new "most-local" operation. See
|
||||
/// \ref usdGeom_xformableExamples "Example 2 below" for C++ code that could
|
||||
/// have produced this USD.
|
||||
///
|
||||
/// If it were important for the prim's rotations to be independently
|
||||
/// overridable, we could equivalently (at some performance cost) encode
|
||||
/// the transformation also like so:
|
||||
/// \code
|
||||
/// float xformOp:rotateX = 30
|
||||
/// float xformOp:rotateY = 60
|
||||
/// float xformOp:rotateZ = 90
|
||||
/// float3 xformOp:scale = (2, 2, 2)
|
||||
/// double3 xformOp:translate = (0, 100, 0)
|
||||
/// uniform token[] xformOpOrder = [ "xformOp:translate", "xformOp:rotateZ", "xformOp:rotateY", "xformOp:rotateX", "xformOp:scale" ]
|
||||
/// \endcode
|
||||
///
|
||||
/// Again, note that although we are encoding an XYZ rotation, the three
|
||||
/// rotations appear in the **xformOpOrder** in the opposite order, with Z,
|
||||
/// followed, by Y, followed by X.
|
||||
///
|
||||
/// Were we to add a Maya-style scalePivot to the above example, it might
|
||||
/// look like the following:
|
||||
/// \code
|
||||
/// float3 xformOp:rotateXYZ = (30, 60, 90)
|
||||
/// float3 xformOp:scale = (2, 2, 2)
|
||||
/// double3 xformOp:translate = (0, 100, 0)
|
||||
/// double3 xformOp:translate:scalePivot
|
||||
/// uniform token[] xformOpOrder = [ "xformOp:translate", "xformOp:rotateXYZ", "xformOp:translate:scalePivot", "xformOp:scale" ]
|
||||
/// \endcode
|
||||
///
|
||||
/// <b>Paired "Inverted" Ops</b>
|
||||
///
|
||||
/// We have been claiming that the ordered list of ops serves as a set
|
||||
/// of instructions to a transform stack, but you may have noticed in the last
|
||||
/// example that there is a missing operation - the pivot for the scale op
|
||||
/// needs to be applied in its inverse-form as a final (most local) op! In the
|
||||
/// AbcGeom::Xform schema, we would have encoded an actual "final" translation
|
||||
/// op whose value was authored by the exporter as the negation of the pivot's
|
||||
/// value. However, doing so would be brittle in USD, given that each op can
|
||||
/// be independently overridden, and the constraint that one attribute must be
|
||||
/// maintained as the negation of the other in order for successful
|
||||
/// re-importation of the schema cannot be expressed in USD.
|
||||
///
|
||||
/// Our solution leverages the **xformOpOrder** member of the schema, which,
|
||||
/// in addition to ordering the ops, may also contain one of two special
|
||||
/// tokens that address the paired op and "stack resetting" behavior.
|
||||
///
|
||||
/// The "paired op" behavior is encoded as an "!invert!" prefix in
|
||||
/// \b xformOpOrder, as the result of an AddXformOp(isInverseOp=True) call.
|
||||
/// The \b xformOpOrder for the last example would look like:
|
||||
/// \code
|
||||
/// uniform token[] xformOpOrder = [ "xformOp:translate", "xformOp:rotateXYZ", "xformOp:translate:scalePivot", "xformOp:scale", "!invert!xformOp:translate:scalePivot" ]
|
||||
/// \endcode
|
||||
///
|
||||
/// When asked for its value via UsdGeomXformOp::GetOpTransform(), an
|
||||
/// "inverted" Op (i.e. the "inverted" half of a set of paired Ops) will fetch
|
||||
/// the value of its paired attribute and return its negation. This works for
|
||||
/// all op types - an error will be issued if a "transform" type op is singular
|
||||
/// and cannot be inverted. When getting the authored value of an inverted op
|
||||
/// via UsdGeomXformOp::Get(), the raw, uninverted value of the associated
|
||||
/// attribute is returned.
|
||||
///
|
||||
/// For the sake of robustness, <b>setting a value on an inverted op is disallowed.</b>
|
||||
/// Attempting to set a value on an inverted op will result in a coding error
|
||||
/// and no value being set.
|
||||
///
|
||||
/// <b>Resetting the Transform Stack</b>
|
||||
///
|
||||
/// The other special op/token that can appear in \em xformOpOrder is
|
||||
/// \em "!resetXformStack!", which, appearing as the first element of
|
||||
/// \em xformOpOrder, indicates this prim should not inherit the transformation
|
||||
/// of its namespace parent. See SetResetXformStack()
|
||||
///
|
||||
/// <b>Expected Behavior for "Missing" Ops</b>
|
||||
///
|
||||
/// If an importer expects Scale-Rotate-Translate operations, but a prim
|
||||
/// has only translate and rotate ops authored, the importer should assume
|
||||
/// an identity scale. This allows us to optimize the data a bit, if only
|
||||
/// a few components of a very rich schema (like Maya's) are authored in the
|
||||
/// app.
|
||||
///
|
||||
/// \anchor usdGeom_xformableExamples
|
||||
/// <b>Using the C++ API</b>
|
||||
///
|
||||
/// #1. Creating a simple transform matrix encoding
|
||||
/// \snippet examples.cpp CreateMatrixWithDefault
|
||||
///
|
||||
/// #2. Creating the simple SRT from the example above
|
||||
/// \snippet examples.cpp CreateExampleSRT
|
||||
///
|
||||
/// #3. Creating a parameterized SRT with pivot using UsdGeomXformCommonAPI
|
||||
/// \snippet examples.cpp CreateSRTWithDefaults
|
||||
///
|
||||
/// #4. Creating a rotate-only pivot transform with animated
|
||||
/// rotation and translation
|
||||
/// \snippet examples.cpp CreateAnimatedTransform
|
||||
///
|
||||
///
|
||||
///
|
||||
class UsdGeomXformable : public UsdGeomImageable
|
||||
{
|
||||
public:
|
||||
/// Compile time constant representing what kind of schema this class is.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractTyped;
|
||||
|
||||
/// Construct a UsdGeomXformable on UsdPrim \p prim .
|
||||
/// Equivalent to UsdGeomXformable::Get(prim.GetStage(), prim.GetPath())
|
||||
/// for a \em valid \p prim, but will not immediately throw an error for
|
||||
/// an invalid \p prim
|
||||
explicit UsdGeomXformable(const UsdPrim& prim=UsdPrim())
|
||||
: UsdGeomImageable(prim)
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct a UsdGeomXformable on the prim held by \p schemaObj .
|
||||
/// Should be preferred over UsdGeomXformable(schemaObj.GetPrim()),
|
||||
/// as it preserves SchemaBase state.
|
||||
explicit UsdGeomXformable(const UsdSchemaBase& schemaObj)
|
||||
: UsdGeomImageable(schemaObj)
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor.
|
||||
USDGEOM_API
|
||||
virtual ~UsdGeomXformable();
|
||||
|
||||
/// 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
|
||||
static const TfTokenVector &
|
||||
GetSchemaAttributeNames(bool includeInherited=true);
|
||||
|
||||
/// Return a UsdGeomXformable holding the prim adhering to this
|
||||
/// schema at \p path on \p stage. If no prim exists at \p path on
|
||||
/// \p 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:
|
||||
///
|
||||
/// \code
|
||||
/// UsdGeomXformable(stage->GetPrimAtPath(path));
|
||||
/// \endcode
|
||||
///
|
||||
USDGEOM_API
|
||||
static UsdGeomXformable
|
||||
Get(const UsdStagePtr &stage, const SdfPath &path);
|
||||
|
||||
|
||||
protected:
|
||||
/// Returns the kind of schema this class belongs to.
|
||||
///
|
||||
/// \sa UsdSchemaKind
|
||||
USDGEOM_API
|
||||
UsdSchemaKind _GetSchemaKind() const override;
|
||||
|
||||
private:
|
||||
// needs to invoke _GetStaticTfType.
|
||||
friend class UsdSchemaRegistry;
|
||||
USDGEOM_API
|
||||
static const TfType &_GetStaticTfType();
|
||||
|
||||
static bool _IsTypedSchema();
|
||||
|
||||
// override SchemaBase virtuals.
|
||||
USDGEOM_API
|
||||
const TfType &_GetTfType() const override;
|
||||
|
||||
public:
|
||||
// --------------------------------------------------------------------- //
|
||||
// XFORMOPORDER
|
||||
// --------------------------------------------------------------------- //
|
||||
/// Encodes the sequence of transformation operations in the
|
||||
/// order in which they should be pushed onto a transform stack while
|
||||
/// visiting a UsdStage's prims in a graph traversal that will effect
|
||||
/// the desired positioning for this prim and its descendant prims.
|
||||
///
|
||||
/// You should rarely, if ever, need to manipulate this attribute directly.
|
||||
/// It is managed by the AddXformOp(), SetResetXformStack(), and
|
||||
/// SetXformOpOrder(), and consulted by GetOrderedXformOps() and
|
||||
/// GetLocalTransformation().
|
||||
///
|
||||
/// | ||
|
||||
/// | -- | -- |
|
||||
/// | Declaration | `uniform token[] xformOpOrder` |
|
||||
/// | C++ Type | VtArray<TfToken> |
|
||||
/// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->TokenArray |
|
||||
/// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
|
||||
USDGEOM_API
|
||||
UsdAttribute GetXformOpOrderAttr() const;
|
||||
|
||||
/// See GetXformOpOrderAttr(), and also
|
||||
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
|
||||
/// If specified, author \p defaultValue as the attribute's default,
|
||||
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
|
||||
/// the default for \p writeSparsely is \c false.
|
||||
USDGEOM_API
|
||||
UsdAttribute CreateXformOpOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
|
||||
|
||||
public:
|
||||
// ===================================================================== //
|
||||
// Feel free to add custom code below this line, it will be preserved by
|
||||
// the code generator.
|
||||
//
|
||||
// Just remember to:
|
||||
// - Close the class declaration with };
|
||||
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
|
||||
// - Close the include guard with #endif
|
||||
// ===================================================================== //
|
||||
// --(BEGIN CUSTOM CODE)--
|
||||
|
||||
/// \class XformQuery
|
||||
///
|
||||
/// Helper class that caches the ordered vector of UsGeomXformOps that
|
||||
/// contribute to the local transformation of an xformable prim
|
||||
///
|
||||
/// Internally, the class initializes UsdAttributeQuery objects for the
|
||||
/// xformOp attributes in order to facilitate efficient querying of their
|
||||
/// values.
|
||||
///
|
||||
/// \note This object does not listen to change notification. If a
|
||||
/// consumer is holding onto a UsdGeomXformable::XformQuery object, it is
|
||||
/// their responsibility to dispose of it, in response to a resync
|
||||
/// change to the associated xformOp attributes. The class provides the
|
||||
/// convenience method IncludesXformOpAttr for this purpose.
|
||||
///
|
||||
class XformQuery {
|
||||
public:
|
||||
XformQuery():
|
||||
_resetsXformStack(false)
|
||||
{ }
|
||||
|
||||
/// Constructs an XformQuery object for the given xformable prim.
|
||||
/// Caches the ordered xformOps and initializes an UsdAttributeQuery
|
||||
/// internally for all the associated attributes.
|
||||
USDGEOM_API
|
||||
XformQuery(const UsdGeomXformable &xformable);
|
||||
|
||||
/// Utilizes the internally cached UsdAttributeQuery's to efficiently
|
||||
/// compute the transform value at the given \p time.
|
||||
USDGEOM_API
|
||||
bool GetLocalTransformation(GfMatrix4d *transform,
|
||||
const UsdTimeCode time) const;
|
||||
|
||||
/// Returns whether the xformable resets its parent's transformation.
|
||||
bool GetResetXformStack() const {
|
||||
return _resetsXformStack;
|
||||
}
|
||||
|
||||
/// Returns whether the xform value might change over time.
|
||||
USDGEOM_API
|
||||
bool TransformMightBeTimeVarying() const;
|
||||
|
||||
/// Sets the vector of times at which xformOp samples have been
|
||||
/// authored in the cached set of xform ops.
|
||||
///
|
||||
/// \sa UsdXformable::GetTimeSamples
|
||||
USDGEOM_API
|
||||
bool GetTimeSamples(std::vector<double> *times) const;
|
||||
|
||||
/// Sets the vector of times in the \p interval at which xformOp
|
||||
/// samples have been authored in the cached set of xform ops.
|
||||
///
|
||||
/// \sa UsdXformable::GetTimeSamples
|
||||
USDGEOM_API
|
||||
bool GetTimeSamplesInInterval(const GfInterval &interval,
|
||||
std::vector<double> *times) const;
|
||||
|
||||
/// Returns whether the given attribute affects the local
|
||||
/// transformation computed for this query.
|
||||
USDGEOM_API
|
||||
bool IsAttributeIncludedInLocalTransform(
|
||||
const TfToken &attrName) const;
|
||||
|
||||
private:
|
||||
// Cached copy of the vector of ordered xform ops.
|
||||
std::vector<UsdGeomXformOp> _xformOps;
|
||||
|
||||
// Cache whether the xformable has !resetsXformStack! in its
|
||||
// xformOpOrder.
|
||||
bool _resetsXformStack;
|
||||
};
|
||||
|
||||
/// Add an affine transformation to the local stack represented by this
|
||||
/// Xformable. This will fail if there is already a transform operation
|
||||
/// of the same name in the ordered ops on this prim (i.e. as returned
|
||||
/// by GetOrderedXformOps()), or if an op of the same name exists at all
|
||||
/// on the prim with a different precision than that specified.
|
||||
///
|
||||
/// The newly created operation will become the most-locally applied
|
||||
/// transformation on the prim, and will appear last in the list
|
||||
/// returned by GetOrderedXformOps(). It is OK to begin authoring values
|
||||
/// to the returned UsdGeomXformOp immediately, interspersed with
|
||||
/// subsequent calls to AddXformOp() - just note the order of application,
|
||||
/// which \em can be changed at any time (and in stronger layers) via
|
||||
/// SetXformOpOrder().
|
||||
///
|
||||
/// \param opType is the type of transform operation, one of
|
||||
/// \ref UsdGeomXformOp::Type.
|
||||
/// \param precision allows you to specify the precision with which you
|
||||
/// desire to encode the data. This should be one of the values in
|
||||
/// the enum \ref UsdGeomXformOp::Precision .
|
||||
/// \param opSuffix allows you to specify the purpose/meaning of the op in
|
||||
/// the stack. When opSuffix is specified, the associated attribute's
|
||||
/// name is set to "xformOp:<opType>:<opSuffix>".
|
||||
/// \param isInverseOp is used to indicate an inverse transformation
|
||||
/// operation.
|
||||
///
|
||||
/// \return a UsdGeomXformOp that can be used to author to the operation.
|
||||
/// An error is issued and the returned object will be invalid
|
||||
/// (evaluate to false) if the op being added already exists in
|
||||
/// \ref GetXformOpOrderAttr() "xformOpOrder" or if the
|
||||
/// arguments supplied are invalid.
|
||||
///
|
||||
/// \note If the attribute associated with the op already exists, but isn't
|
||||
/// of the requested precision, a coding error is issued, but a valid
|
||||
/// xformOp is returned with the existing attribute.
|
||||
///
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddXformOp(UsdGeomXformOp::Type const opType,
|
||||
UsdGeomXformOp::Precision const
|
||||
precision=UsdGeomXformOp::PrecisionDouble,
|
||||
TfToken const &opSuffix = TfToken(),
|
||||
bool isInverseOp=false) const;
|
||||
|
||||
/// Add a translate operation to the local stack represented by this
|
||||
/// xformable.
|
||||
///
|
||||
/// \sa AddXformOp()
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddTranslateOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionDouble,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a scale operation to the local stack represented by this
|
||||
/// xformable.
|
||||
///
|
||||
/// \sa AddXformOp()
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddScaleOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation about the X-axis to the local stack represented by
|
||||
/// this xformable.
|
||||
///
|
||||
/// Set the angle value of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp()
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateXOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation about the YX-axis to the local stack represented by
|
||||
/// this xformable.
|
||||
///
|
||||
/// Set the angle value of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp()
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateYOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation about the Z-axis to the local stack represented by
|
||||
/// this xformable.
|
||||
///
|
||||
/// \sa AddXformOp()
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateZOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation op with XYZ rotation order to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// Set the angle value of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp(), \ref usdGeom_rotationPackingOrder "note on angle packing order"
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateXYZOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation op with XZY rotation order to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// Set the angle values of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp(), \ref usdGeom_rotationPackingOrder "note on angle packing order"
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateXZYOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation op with YXZ rotation order to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// Set the angle values of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp(), \ref usdGeom_rotationPackingOrder "note on angle packing order"
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateYXZOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation op with YZX rotation order to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// Set the angle values of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp(), \ref usdGeom_rotationPackingOrder "note on angle packing order"
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateYZXOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation op with ZXY rotation order to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// Set the angle values of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp(), \ref usdGeom_rotationPackingOrder "note on angle packing order"
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateZXYOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a rotation op with ZYX rotation order to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// Set the angle values of the resulting UsdGeomXformOp <b>in degrees</b>
|
||||
/// \sa AddXformOp(), \ref usdGeom_rotationPackingOrder "note on angle packing order"
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddRotateZYXOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a orient op (arbitrary axis/angle rotation) to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// \sa AddXformOp()
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddOrientOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Add a tranform op (4x4 matrix transformation) to the local stack
|
||||
/// represented by this xformable.
|
||||
///
|
||||
/// \sa AddXformOp()
|
||||
///
|
||||
/// Note: This method takes a precision argument only to be consistent
|
||||
/// with the other types of xformOps. The only valid precision here is
|
||||
/// double since matrix values cannot be encoded in floating-pt precision
|
||||
/// in Sdf.
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp AddTransformOp(
|
||||
UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionDouble,
|
||||
TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
|
||||
|
||||
/// Specify whether this prim's transform should reset the transformation
|
||||
/// stack inherited from its parent prim.
|
||||
///
|
||||
/// By default, parent transforms are inherited. SetResetXformStack() can be
|
||||
/// called at any time during authoring, but will always add a
|
||||
/// '!resetXformStack!' op as the \em first op in the ordered list, if one
|
||||
/// does not exist already. If one already exists, and \p resetXform is
|
||||
/// false, it will remove all ops upto and including the last
|
||||
/// "!resetXformStack!" op.
|
||||
USDGEOM_API
|
||||
bool SetResetXformStack(bool resetXform) const;
|
||||
|
||||
/// Does this prim reset its parent's inherited transformation?
|
||||
///
|
||||
/// Returns true if "!resetXformStack!" appears \em anywhere in xformOpOrder.
|
||||
/// When this returns true, all ops upto the last "!resetXformStack!" in
|
||||
/// xformOpOrder are ignored when computing the local transformation.
|
||||
///
|
||||
USDGEOM_API
|
||||
bool GetResetXformStack() const;
|
||||
|
||||
/// Reorder the already-existing transform ops on this prim.
|
||||
///
|
||||
/// All elements in \p orderedXformOps must be valid and represent attributes
|
||||
/// on this prim. Note that it is \em not required that all the existing
|
||||
/// operations be present in \p orderedXformOps, so this method can be used to
|
||||
/// completely change the transformation structure applied to the prim.
|
||||
///
|
||||
/// If \p resetXformStack is set to true, then "!resetXformOp! will be
|
||||
/// set as the first op in xformOpOrder, to indicate that the prim does
|
||||
/// not inherit its parent's transformation.
|
||||
///
|
||||
/// \note If you wish to re-specify a prim's transformation completely in
|
||||
/// a stronger layer, you should first call this method with an \em empty
|
||||
/// \p orderedXformOps vector. From there you can call AddXformOp() just as if
|
||||
/// you were authoring to the prim from scratch.
|
||||
///
|
||||
/// \return false if any of the elements of \p orderedXformOps are not extant
|
||||
/// on this prim, or if an error occurred while authoring the ordering
|
||||
/// metadata. Under either condition, no scene description is authored.
|
||||
///
|
||||
/// \sa GetOrderedXformOps()
|
||||
USDGEOM_API
|
||||
bool SetXformOpOrder(std::vector<UsdGeomXformOp> const &orderedXformOps,
|
||||
bool resetXformStack = false) const;
|
||||
|
||||
/// Return the ordered list of transform operations to be applied to
|
||||
/// this prim, in least-to-most-local order. This is determined by the
|
||||
/// intersection of authored op-attributes and the explicit ordering of
|
||||
/// those attributes encoded in the \c xformOpOrder attribute on this prim.
|
||||
/// Any entries in \c xformOpOrder that do not correspond to valid
|
||||
/// attributes on the xformable prim are skipped and a warning is issued.
|
||||
///
|
||||
/// A UsdGeomTransformable that has not had any ops added via AddXformOp()
|
||||
/// will return an empty vector.
|
||||
///
|
||||
/// The function also sets \p resetsXformStack to true if "!resetXformStack!"
|
||||
/// appears \em anywhere in xformOpOrder (i.e., if the prim resets its
|
||||
/// parent's inherited transformation).
|
||||
///
|
||||
/// \note A coding error is issued if resetsXformStack is NULL.
|
||||
///
|
||||
/// \sa GetResetXformStack()
|
||||
USDGEOM_API
|
||||
std::vector<UsdGeomXformOp> GetOrderedXformOps(bool *resetsXformStack) const;
|
||||
|
||||
/// Clears the local transform stack.
|
||||
USDGEOM_API
|
||||
bool ClearXformOpOrder() const;
|
||||
|
||||
/// Clears the existing local transform stack and creates a new xform op of
|
||||
/// type 'transform'.
|
||||
///
|
||||
/// This API is provided for convenience since this is the most common
|
||||
/// xform authoring operation.
|
||||
///
|
||||
/// \sa ClearXformOpOrder()
|
||||
/// \sa AddTransformOp()
|
||||
USDGEOM_API
|
||||
UsdGeomXformOp MakeMatrixXform() const;
|
||||
|
||||
/// Determine whether there is any possibility that this prim's \em local
|
||||
/// transformation may vary over time.
|
||||
///
|
||||
/// The determination is based on a snapshot of the authored state of the
|
||||
/// op attributes on the prim, and may become invalid in the face of
|
||||
/// further authoring.
|
||||
USDGEOM_API
|
||||
bool TransformMightBeTimeVarying() const;
|
||||
|
||||
/// \overload
|
||||
/// Determine whether there is any possibility that this prim's \em local
|
||||
/// transformation may vary over time, using a pre-fetched (cached) list of
|
||||
/// ordered xform ops supplied by the client.
|
||||
///
|
||||
/// The determination is based on a snapshot of the authored state of the
|
||||
/// op attributes on the prim, and may become invalid in the face of
|
||||
/// further authoring.
|
||||
USDGEOM_API
|
||||
bool TransformMightBeTimeVarying(
|
||||
const std::vector<UsdGeomXformOp> &ops) const;
|
||||
|
||||
/// Sets \p times to the union of all the timesamples at which xformOps that
|
||||
/// are included in the xformOpOrder attribute are authored.
|
||||
///
|
||||
/// This clears the \p times vector before accumulating sample times
|
||||
/// from all the xformOps.
|
||||
///
|
||||
/// \sa UsdAttribute::GetTimeSamples
|
||||
USDGEOM_API
|
||||
bool GetTimeSamples(std::vector<double> *times) const;
|
||||
|
||||
/// Sets \p times to the union of all the timesamples in the interval,
|
||||
/// \p interval, at which xformOps that are included in the xformOpOrder
|
||||
/// attribute are authored.
|
||||
///
|
||||
/// This clears the \p times vector before accumulating sample times
|
||||
/// from all the xformOps.
|
||||
///
|
||||
/// \sa UsdAttribute::GetTimeSamples
|
||||
USDGEOM_API
|
||||
bool GetTimeSamplesInInterval(const GfInterval &interval,
|
||||
std::vector<double> *times) const;
|
||||
|
||||
/// Returns the union of all the timesamples at which the attributes
|
||||
/// belonging to the given \p orderedXformOps are authored.
|
||||
///
|
||||
/// This clears the \p times vector before accumulating sample times
|
||||
/// from \p orderedXformOps.
|
||||
///
|
||||
/// \sa UsdGeomXformable::GetTimeSamples
|
||||
USDGEOM_API
|
||||
static bool GetTimeSamples(
|
||||
std::vector<UsdGeomXformOp> const &orderedXformOps,
|
||||
std::vector<double> *times);
|
||||
|
||||
/// Returns the union of all the timesamples in the \p interval
|
||||
/// at which the attributes belonging to the given \p orderedXformOps
|
||||
/// are authored.
|
||||
///
|
||||
/// This clears the \p times vector before accumulating sample times
|
||||
/// from \p orderedXformOps.
|
||||
///
|
||||
/// \sa UsdGeomXformable::GetTimeSamplesInInterval
|
||||
USDGEOM_API
|
||||
static bool GetTimeSamplesInInterval(
|
||||
std::vector<UsdGeomXformOp> const &orderedXformOps,
|
||||
const GfInterval &interval,
|
||||
std::vector<double> *times);
|
||||
|
||||
/// Computes the fully-combined, local-to-parent transformation for this prim.
|
||||
///
|
||||
/// If a client does not need to manipulate the individual ops themselves,
|
||||
/// and requires only the combined transform on this prim, this method will
|
||||
/// take care of all the data marshalling and linear algebra needed to
|
||||
/// combine the ops into a 4x4 affine transformation matrix, in
|
||||
/// double-precision, regardless of the precision of the op inputs.
|
||||
///
|
||||
/// \param transform is the output parameter that will hold the local
|
||||
/// transform.
|
||||
/// \param resetsXformStack is the output parameter that informs client
|
||||
/// whether they need to reset the transform stack before pushing
|
||||
/// \p transform.
|
||||
/// \param time is the UsdTimeCode at which to sample the ops.
|
||||
///
|
||||
/// \return true on success, false if there was an error reading data.
|
||||
///
|
||||
/// \note A coding error is issued if \p transform or \p resetsXformStack
|
||||
/// is NULL.
|
||||
///
|
||||
USDGEOM_API
|
||||
bool GetLocalTransformation(
|
||||
GfMatrix4d *transform,
|
||||
bool *resetsXformStack,
|
||||
const UsdTimeCode time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// \overload
|
||||
/// Computes the fully-combined, local-to-parent transformation for this
|
||||
/// prim as efficiently as possible, using a pre-fetched (cached) list of
|
||||
/// ordered xform ops supplied by the client.
|
||||
///
|
||||
/// \param transform is the output parameter that will hold the local
|
||||
/// transform.
|
||||
/// \param resetsXformStack is the output parameter that informs client
|
||||
/// whether they need to reset the transform stack before pushing
|
||||
/// \p transform.
|
||||
/// \param ops is the ordered set of xform ops for this prim, and will be
|
||||
/// queried without any validity checking. Passing this in can save
|
||||
/// significant value-resolution costs, if the client is able to
|
||||
/// retain this data from a call to GetOrderedXformOps().
|
||||
/// \param time is the UsdTimeCode at which to sample the ops.
|
||||
///
|
||||
/// \return true on success, false if there was an error reading data.
|
||||
///
|
||||
/// \note A coding error is issued if \p transform or \p resetsXformStack
|
||||
/// is NULL.
|
||||
///
|
||||
USDGEOM_API
|
||||
bool GetLocalTransformation(GfMatrix4d *transform,
|
||||
bool *resetsXformStack,
|
||||
const std::vector<UsdGeomXformOp> &ops,
|
||||
const UsdTimeCode time = UsdTimeCode::Default()) const;
|
||||
|
||||
/// \overload
|
||||
/// This is a static version of the preceding function that takes
|
||||
/// a cached list of ordered xform ops.
|
||||
///
|
||||
/// \param transform is the output parameter that will hold the local
|
||||
/// transform.
|
||||
/// \param ops is the ordered set of xform ops that must be combined
|
||||
/// together to compute the local transformation.
|
||||
/// \param time is the UsdTimeCode at which to sample the ops.
|
||||
///
|
||||
/// \return true on success, false if there was an error reading data.
|
||||
///
|
||||
USDGEOM_API
|
||||
static bool GetLocalTransformation(GfMatrix4d *transform,
|
||||
std::vector<UsdGeomXformOp> const &ops,
|
||||
const UsdTimeCode time);
|
||||
|
||||
/// Returns true if the attribute named \p attrName could affect the local
|
||||
/// transformation of an xformable prim.
|
||||
USDGEOM_API
|
||||
static bool IsTransformationAffectedByAttrNamed(const TfToken &attrName);
|
||||
|
||||
private:
|
||||
// Extracts the value of the xformOpOrder attribute. Returns false if
|
||||
// the xformOpOrder attribute doesn't exist on the prim (eg. when the prim
|
||||
// type is incompatible or if it's a pure over).
|
||||
bool _GetXformOpOrderValue(VtTokenArray *xformOpOrder) const;
|
||||
|
||||
// Helper function for getting xformops with or without attribute queries.
|
||||
std::vector<UsdGeomXformOp>
|
||||
_GetOrderedXformOps(bool *resetsXformStack,
|
||||
bool withAttributeQueries) const;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user