Loading...
Searching...
No Matches
UsdGeomXformOp Class Reference

Schema wrapper for UsdAttribute for authoring and computing transformation operations, as consumed by UsdGeomXformable schema. More...

#include <xformOp.h>

Public Types

enum  Type {
  TypeInvalid , TypeTranslate , TypeScale , TypeRotateX ,
  TypeRotateY , TypeRotateZ , TypeRotateXYZ , TypeRotateXZY ,
  TypeRotateYXZ , TypeRotateYZX , TypeRotateZXY , TypeRotateZYX ,
  TypeOrient , TypeTransform
}
 Enumerates the set of all transformation operation types. More...
 
enum  Precision { PrecisionDouble , PrecisionFloat , PrecisionHalf }
 Precision with which the value of the tranformation operation is encoded. More...
 

Public Member Functions

USDGEOM_API UsdGeomXformOp (const UsdAttribute &attr, bool isInverseOp=false)
 Speculative constructor that will produce a valid UsdGeomXformOp when attr already represents an attribute that is XformOp, and produces an invalid XformOp otherwise (i.e.
 
Data Encoding Queries
Type GetOpType () const
 Return the operation type of this op, one of UsdGeomXformOp::Type.
 
USDGEOM_API Precision GetPrecision () const
 Returns the precision level of the xform op.
 
bool IsInverseOp () const
 Returns whether the xformOp represents an inverse operation.
 
USDGEOM_API TfToken GetOpName () const
 Returns the opName as it appears in the xformOpOrder attribute.
 
USDGEOM_API bool HasSuffix (TfToken const &suffix) const
 Does this op have the given suffix in its name.
 

Static Public Member Functions

Static Helper API
static USDGEOM_API bool IsXformOp (const UsdAttribute &attr)
 Test whether a given UsdAttribute represents valid XformOp, which implies that creating a UsdGeomXformOp from the attribute will succeed.
 
static USDGEOM_API bool IsXformOp (const TfToken &attrName)
 Test whether a given attrbute name represents a valid XformOp, which implies that creating a UsdGeomXformOp from the corresponding UsdAttribute will succeed.
 
static USDGEOM_API TfToken const & GetOpTypeToken (Type const opType)
 Returns the TfToken used to encode the given opType.
 
static USDGEOM_API Type GetOpTypeEnum (TfToken const &opTypeToken)
 Returns the Type enum associated with the given opTypeToken.
 
static USDGEOM_API Precision GetPrecisionFromValueTypeName (const SdfValueTypeName &typeName)
 Returns the precision corresponding to the given value typeName.
 
static USDGEOM_API const SdfValueTypeNameGetValueTypeName (const Type opType, const Precision precision)
 Returns the value typeName token that corresponds to the given combination of opType and precision.
 
static USDGEOM_API TfToken GetOpName (const Type opType, const TfToken &opSuffix=TfToken(), bool inverse=false)
 Returns the xformOp's name as it appears in xformOpOrder, given the opType, the (optional) suffix and whether it is an inverse operation.
 

UsdAttribute API

class UsdGeomXformable
 
bool operator== (const UsdGeomXformOp &lhs, const UsdGeomXformOp &rhs)
 Equality comparison.
 
bool operator!= (const UsdGeomXformOp &lhs, const UsdGeomXformOp &rhs)
 Inequality comparison.
 
 operator UsdAttribute const & () const
 Allow UsdGeomXformOp to auto-convert to UsdAttribute, so you can pass a UsdGeomXformOp to any function that accepts a UsdAttribute or const-ref thereto.
 
UsdAttribute const & GetAttr () const
 Explicit UsdAttribute extractor.
 
bool IsDefined () const
 Return true if the wrapped UsdAttribute::IsDefined(), and in addition the attribute is identified as a XformOp.
 
 operator bool () const
 Explicit bool conversion operator.
 
TfToken const & GetName () const
 
TfToken GetBaseName () const
 
TfToken GetNamespace () const
 
std::vector< std::string > SplitName () const
 
SdfValueTypeName GetTypeName () const
 
template<typename T >
bool Get (T *value, UsdTimeCode time=UsdTimeCode::Default()) const
 Get the attribute value of the XformOp at time.
 
template<typename T >
bool Set (T const &value, UsdTimeCode time=UsdTimeCode::Default()) const
 Set the attribute value of the XformOp at time.
 
bool GetTimeSamples (std::vector< double > *times) const
 Populates the list of time samples at which the associated attribute is authored.
 
bool GetTimeSamplesInInterval (const GfInterval &interval, std::vector< double > *times) const
 Populates the list of time samples within the given interval, at which the associated attribute is authored.
 
size_t GetNumTimeSamples () const
 Returns the number of time samples authored for this xformOp.
 
USDGEOM_API UsdGeomXformOp (const UsdAttribute &attr, bool isInverseOp, _ValidAttributeTagType)
 
USDGEOM_API UsdGeomXformOp (UsdAttributeQuery &&query, bool isInverseOp, _ValidAttributeTagType)
 

Computing with Ops

template<typename T >
bool GetAs (T *value, UsdTimeCode time) const
 We allow ops to be encoded with varying degrees of precision, depending on the clients needs and constraints.
 
USDGEOM_API GfMatrix4d GetOpTransform (UsdTimeCode time) const
 Return the 4x4 matrix that applies the transformation encoded in this op at time.
 
bool MightBeTimeVarying () const
 Determine whether there is any possibility that this op's value may vary over time.
 
static USDGEOM_API GfMatrix4d GetOpTransform (Type const opType, VtValue const &opVal, bool isInverseOp=false)
 Return the 4x4 matrix that applies the transformation encoded by op opType and data value opVal.
 

Detailed Description

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 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.

Note
On packing order of rotateABC triples
The order in which the axis rotations are recorded in a Vec3* for the six rotateABC Euler triples is always the same: vec[0] = X, vec[1] = Y, vec[2] = Z . The A, B, C in the op name dictate the order in which their corresponding elements are consumed by the rotation, not how they are laid out.

Definition at line 110 of file xformOp.h.

Member Enumeration Documentation

◆ Precision

enum Precision

Precision with which the value of the tranformation operation is encoded.

Enumerator
PrecisionDouble 

Double precision.

PrecisionFloat 

Floating-point precision.

PrecisionHalf 

Half-float precision.

Definition at line 139 of file xformOp.h.

◆ Type

enum Type

Enumerates the set of all transformation operation types.

Enumerator
TypeInvalid 

Represents an invalid xformOp.

TypeTranslate 

XYZ translation.

TypeScale 

XYZ scale.

TypeRotateX 

Rotation about the X-axis, in degrees.

TypeRotateY 

Rotation about the Y-axis, in degrees.

TypeRotateZ 

Rotation about the Z-axis, in degrees.

TypeRotateXYZ 

Set of 3 canonical Euler rotations in XYZ order.

TypeRotateXZY 

Set of 3 canonical Euler rotations in XZY order.

TypeRotateYXZ 

Set of 3 canonical Euler rotations in YXZ order.

TypeRotateYZX 

Set of 3 canonical Euler rotations in YZX order.

TypeRotateZXY 

Set of 3 canonical Euler rotations in ZXY order.

TypeRotateZYX 

Set of 3 canonical Euler rotations in ZYX order.

TypeOrient 

Arbitrary axis/angle rotation, expressed as a quaternion.

TypeTransform 

A 4x4 matrix transformation.

Definition at line 115 of file xformOp.h.

Constructor & Destructor Documentation

◆ UsdGeomXformOp() [1/2]

UsdGeomXformOp ( )
inline

Definition at line 147 of file xformOp.h.

◆ UsdGeomXformOp() [2/2]

USDGEOM_API UsdGeomXformOp ( const UsdAttribute attr,
bool  isInverseOp = false 
)
explicit

Speculative constructor that will produce a valid UsdGeomXformOp when attr already represents an attribute that is XformOp, and produces an invalid XformOp otherwise (i.e.

explicit-bool conversion operator will return false).

Calling 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.

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.

Member Function Documentation

◆ Get()

bool Get ( T *  value,
UsdTimeCode  time = UsdTimeCode::Default() 
) const
inline

Get the attribute value of the XformOp at time.

Note
For inverted ops, this returns the raw, uninverted value.

Definition at line 382 of file xformOp.h.

◆ GetAs()

bool GetAs ( T *  value,
UsdTimeCode  time 
) const
inline

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.

Returns
true if a value was successfully read and converted to the requested datatype (see VtValue::Cast()), false otherwise. A problem reading or failure to convert will cause an error to be emitted.
Note
the requested type T must be constructable by assignment

Definition at line 266 of file xformOp.h.

◆ GetAttr()

UsdAttribute const & GetAttr ( ) const
inline

Explicit UsdAttribute extractor.

Definition at line 330 of file xformOp.h.

◆ GetBaseName()

TfToken GetBaseName ( ) const
inline
See also
UsdAttribute::GetBaseName()

Definition at line 366 of file xformOp.h.

◆ GetName()

TfToken const & GetName ( ) const
inline
See also
UsdAttribute::GetName()

Definition at line 363 of file xformOp.h.

◆ GetNamespace()

TfToken GetNamespace ( ) const
inline
See also
UsdAttribute::GetNamespace()

Definition at line 369 of file xformOp.h.

◆ GetNumTimeSamples()

size_t GetNumTimeSamples ( ) const
inline

Returns the number of time samples authored for this xformOp.

Definition at line 421 of file xformOp.h.

◆ GetOpName() [1/2]

USDGEOM_API TfToken GetOpName ( ) const

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.

◆ GetOpName() [2/2]

static USDGEOM_API TfToken GetOpName ( const Type  opType,
const TfToken opSuffix = TfToken(),
bool  inverse = false 
)
static

Returns the xformOp's name as it appears in xformOpOrder, given the opType, the (optional) suffix and whether it is an inverse operation.

◆ GetOpTransform() [1/2]

static USDGEOM_API GfMatrix4d GetOpTransform ( Type const  opType,
VtValue const &  opVal,
bool  isInverseOp = false 
)
static

Return the 4x4 matrix that applies the transformation encoded by op opType and data value opVal.

If isInverseOp is true, then the inverse of the tranformation represented by the op/value pair is returned.

An error will be issued if opType is not one of the values in the enum UsdGeomXformOp::Type or if opVal cannot be converted to a suitable input to opType

◆ GetOpTransform() [2/2]

USDGEOM_API GfMatrix4d GetOpTransform ( UsdTimeCode  time) const

Return the 4x4 matrix that applies the transformation encoded in this op at 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.

◆ GetOpType()

Type GetOpType ( ) const
inline

Return the operation type of this op, one of UsdGeomXformOp::Type.

Definition at line 221 of file xformOp.h.

◆ GetOpTypeEnum()

static USDGEOM_API Type GetOpTypeEnum ( TfToken const &  opTypeToken)
static

Returns the Type enum associated with the given opTypeToken.

◆ GetOpTypeToken()

static USDGEOM_API TfToken const & GetOpTypeToken ( Type const  opType)
static

Returns the TfToken used to encode the given opType.

Note that an empty TfToken is used to represent TypeInvalid

◆ GetPrecision()

USDGEOM_API Precision GetPrecision ( ) const

Returns the precision level of the xform op.

◆ GetPrecisionFromValueTypeName()

static USDGEOM_API Precision GetPrecisionFromValueTypeName ( const SdfValueTypeName typeName)
static

Returns the precision corresponding to the given value typeName.

◆ GetTimeSamples()

bool GetTimeSamples ( std::vector< double > *  times) const
inline

Populates the list of time samples at which the associated attribute is authored.

Definition at line 408 of file xformOp.h.

◆ GetTimeSamplesInInterval()

bool GetTimeSamplesInInterval ( const GfInterval interval,
std::vector< double > *  times 
) const
inline

Populates the list of time samples within the given interval, at which the associated attribute is authored.

Definition at line 414 of file xformOp.h.

◆ GetTypeName()

SdfValueTypeName GetTypeName ( ) const
inline
See also
UsdAttribute::GetTypeName()

Definition at line 375 of file xformOp.h.

◆ GetValueTypeName()

static USDGEOM_API const SdfValueTypeName & GetValueTypeName ( const Type  opType,
const Precision  precision 
)
static

Returns the value typeName token that corresponds to the given combination of opType and precision.

◆ HasSuffix()

USDGEOM_API bool HasSuffix ( TfToken const &  suffix) const

Does this op have the given suffix in its name.

◆ IsDefined()

bool IsDefined ( ) const
inline

Return true if the wrapped UsdAttribute::IsDefined(), and in addition the attribute is identified as a XformOp.

Definition at line 336 of file xformOp.h.

◆ IsInverseOp()

bool IsInverseOp ( ) const
inline

Returns whether the xformOp represents an inverse operation.

Definition at line 230 of file xformOp.h.

◆ IsXformOp() [1/2]

static USDGEOM_API bool IsXformOp ( const TfToken attrName)
static

Test whether a given attrbute name represents a valid XformOp, which implies that creating a UsdGeomXformOp from the corresponding UsdAttribute will succeed.

◆ IsXformOp() [2/2]

static USDGEOM_API bool IsXformOp ( const UsdAttribute attr)
static

Test whether a given UsdAttribute represents valid XformOp, which implies that creating a UsdGeomXformOp from the attribute will succeed.

Success implies that attr.IsDefined() is true.

◆ MightBeTimeVarying()

bool MightBeTimeVarying ( ) const
inline

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.

Definition at line 316 of file xformOp.h.

◆ operator bool()

operator bool ( ) const
inlineexplicit

Explicit bool conversion operator.

An XformOp object converts to true iff it is valid for querying and authoring values and metadata, (which is identically equivalent to IsDefined()), and converts to false otherwise.

Definition at line 344 of file xformOp.h.

◆ operator UsdAttribute const &()

operator UsdAttribute const & ( ) const
inline

Allow UsdGeomXformOp to auto-convert to UsdAttribute, so you can pass a UsdGeomXformOp to any function that accepts a UsdAttribute or const-ref thereto.

Definition at line 327 of file xformOp.h.

◆ Set()

bool Set ( T const &  value,
UsdTimeCode  time = UsdTimeCode::Default() 
) const
inline

Set the attribute value of the XformOp at 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.

Definition at line 393 of file xformOp.h.

◆ SplitName()

std::vector< std::string > SplitName ( ) const
inline
See also
UsdAttribute::SplitName()

Definition at line 372 of file xformOp.h.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const UsdGeomXformOp lhs,
const UsdGeomXformOp rhs 
)
friend

Inequality comparison.

Return false if lhs and rhs represent the same underlying UsdAttribute, true otherwise.

Definition at line 357 of file xformOp.h.

◆ operator==

bool operator== ( const UsdGeomXformOp lhs,
const UsdGeomXformOp rhs 
)
friend

Equality comparison.

Return true if lhs and rhs represent the same underlying UsdAttribute, false otherwise.

Definition at line 350 of file xformOp.h.

◆ UsdGeomXformable

friend class UsdGeomXformable
friend

Definition at line 438 of file xformOp.h.


The documentation for this class was generated from the following file: