xformable.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDGEOM_GENERATED_XFORMABLE_H
25 #define USDGEOM_GENERATED_XFORMABLE_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdGeom/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdGeom/tokens.h"
35 
36 #include "pxr/usd/usdGeom/xformOp.h"
37 #include <vector>
38 
39 #include "pxr/base/vt/value.h"
40 
41 #include "pxr/base/gf/vec3d.h"
42 #include "pxr/base/gf/vec3f.h"
43 #include "pxr/base/gf/matrix4d.h"
44 
45 #include "pxr/base/tf/token.h"
46 #include "pxr/base/tf/type.h"
47 
48 PXR_NAMESPACE_OPEN_SCOPE
49 
50 class SdfAssetPath;
51 
52 // -------------------------------------------------------------------------- //
53 // XFORMABLE //
54 // -------------------------------------------------------------------------- //
55 
253 {
254 public:
259 
264  explicit UsdGeomXformable(const UsdPrim& prim=UsdPrim())
265  : UsdGeomImageable(prim)
266  {
267  }
268 
272  explicit UsdGeomXformable(const UsdSchemaBase& schemaObj)
273  : UsdGeomImageable(schemaObj)
274  {
275  }
276 
278  USDGEOM_API
279  virtual ~UsdGeomXformable();
280 
284  USDGEOM_API
285  static const TfTokenVector &
286  GetSchemaAttributeNames(bool includeInherited=true);
287 
297  USDGEOM_API
298  static UsdGeomXformable
299  Get(const UsdStagePtr &stage, const SdfPath &path);
300 
301 
302 protected:
306  USDGEOM_API
307  UsdSchemaKind _GetSchemaKind() const override;
308 
309 private:
310  // needs to invoke _GetStaticTfType.
311  friend class UsdSchemaRegistry;
312  USDGEOM_API
313  static const TfType &_GetStaticTfType();
314 
315  static bool _IsTypedSchema();
316 
317  // override SchemaBase virtuals.
318  USDGEOM_API
319  const TfType &_GetTfType() const override;
320 
321 public:
322  // --------------------------------------------------------------------- //
323  // XFORMOPORDER
324  // --------------------------------------------------------------------- //
341  USDGEOM_API
343 
349  USDGEOM_API
350  UsdAttribute CreateXformOpOrderAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
351 
352 public:
353  // ===================================================================== //
354  // Feel free to add custom code below this line, it will be preserved by
355  // the code generator.
356  //
357  // Just remember to:
358  // - Close the class declaration with };
359  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
360  // - Close the include guard with #endif
361  // ===================================================================== //
362  // --(BEGIN CUSTOM CODE)--
363 
379  class XformQuery {
380  public:
381  XformQuery():
382  _resetsXformStack(false)
383  { }
384 
388  USDGEOM_API
389  XformQuery(const UsdGeomXformable &xformable);
390 
393  USDGEOM_API
394  bool GetLocalTransformation(GfMatrix4d *transform,
395  const UsdTimeCode time) const;
396 
398  bool GetResetXformStack() const {
399  return _resetsXformStack;
400  }
401 
403  USDGEOM_API
404  bool TransformMightBeTimeVarying() const;
405 
407  USDGEOM_API
408  bool HasNonEmptyXformOpOrder() const;
409 
414  USDGEOM_API
415  bool GetTimeSamples(std::vector<double> *times) const;
416 
421  USDGEOM_API
422  bool GetTimeSamplesInInterval(const GfInterval &interval,
423  std::vector<double> *times) const;
424 
427  USDGEOM_API
429  const TfToken &attrName) const;
430 
431  private:
432  // Cached copy of the vector of ordered xform ops.
433  std::vector<UsdGeomXformOp> _xformOps;
434 
435  // Cache whether the xformable has !resetsXformStack! in its
436  // xformOpOrder.
437  bool _resetsXformStack;
438  };
439 
475  USDGEOM_API
479  TfToken const &opSuffix = TfToken(),
480  bool isInverseOp=false) const;
481 
486  USDGEOM_API
489  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
490 
495  USDGEOM_API
498  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
499 
505  USDGEOM_API
508  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
509 
515  USDGEOM_API
518  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
519 
524  USDGEOM_API
527  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
528 
534  USDGEOM_API
537  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
538 
544  USDGEOM_API
547  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
548 
554  USDGEOM_API
557  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
558 
564  USDGEOM_API
567  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
568 
574  USDGEOM_API
577  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
578 
584  USDGEOM_API
587  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
588 
593  USDGEOM_API
596  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
597 
607  USDGEOM_API
610  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
611 
621  USDGEOM_API
622  bool SetResetXformStack(bool resetXform) const;
623 
630  USDGEOM_API
631  bool GetResetXformStack() const;
632 
654  USDGEOM_API
655  bool SetXformOpOrder(std::vector<UsdGeomXformOp> const &orderedXformOps,
656  bool resetXformStack = false) const;
657 
675  USDGEOM_API
676  std::vector<UsdGeomXformOp> GetOrderedXformOps(bool *resetsXformStack) const;
677 
679  USDGEOM_API
680  bool ClearXformOpOrder() const;
681 
690  USDGEOM_API
692 
699  USDGEOM_API
700  bool TransformMightBeTimeVarying() const;
701 
710  USDGEOM_API
712  const std::vector<UsdGeomXformOp> &ops) const;
713 
721  USDGEOM_API
722  bool GetTimeSamples(std::vector<double> *times) const;
723 
732  USDGEOM_API
733  bool GetTimeSamplesInInterval(const GfInterval &interval,
734  std::vector<double> *times) const;
735 
743  USDGEOM_API
744  static bool GetTimeSamples(
745  std::vector<UsdGeomXformOp> const &orderedXformOps,
746  std::vector<double> *times);
747 
756  USDGEOM_API
757  static bool GetTimeSamplesInInterval(
758  std::vector<UsdGeomXformOp> const &orderedXformOps,
759  const GfInterval &interval,
760  std::vector<double> *times);
761 
782  USDGEOM_API
784  GfMatrix4d *transform,
785  bool *resetsXformStack,
786  const UsdTimeCode time = UsdTimeCode::Default()) const;
787 
809  USDGEOM_API
810  bool GetLocalTransformation(GfMatrix4d *transform,
811  bool *resetsXformStack,
812  const std::vector<UsdGeomXformOp> &ops,
813  const UsdTimeCode time = UsdTimeCode::Default()) const;
814 
827  USDGEOM_API
828  static bool GetLocalTransformation(GfMatrix4d *transform,
829  std::vector<UsdGeomXformOp> const &ops,
830  const UsdTimeCode time);
831 
834  USDGEOM_API
835  static bool IsTransformationAffectedByAttrNamed(const TfToken &attrName);
836 
837 private:
838  // Extracts the value of the xformOpOrder attribute. Returns false if
839  // the xformOpOrder attribute doesn't exist on the prim (eg. when the prim
840  // type is incompatible or if it's a pure over).
841  bool _GetXformOpOrderValue(VtTokenArray *xformOpOrder) const;
842 
843  // Helper function for getting xformops with or without attribute queries.
844  std::vector<UsdGeomXformOp>
845  _GetOrderedXformOps(bool *resetsXformStack,
846  bool withAttributeQueries) const;
847 };
848 
849 PXR_NAMESPACE_CLOSE_SCOPE
850 
851 #endif
USDGEOM_API UsdGeomXformOp AddRotateYOp(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.
USDGEOM_API UsdGeomXformOp AddTransformOp(UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionDouble, TfToken const &opSuffix=TfToken(), bool isInverseOp=false) const
Add a tranform op (4x4 matrix transformation) to the local stack represented by this xformable.
USDGEOM_API bool GetTimeSamples(std::vector< double > *times) const
Sets times to the union of all the timesamples at which xformOps that are included in the xformOpOrde...
USDGEOM_API bool TransformMightBeTimeVarying() const
Returns whether the xform value might change over time.
Floating-point precision.
Definition: xformOp.h:142
USDGEOM_API UsdGeomXformOp AddXformOp(UsdGeomXformOp::Type const opType, UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionDouble, TfToken const &opSuffix=TfToken(), bool isInverseOp=false) const
Add an affine transformation to the local stack represented by this Xformable.
UsdGeomXformable(const UsdSchemaBase &schemaObj)
Construct a UsdGeomXformable on the prim held by schemaObj .
Definition: xformable.h:272
UsdGeomXformable(const UsdPrim &prim=UsdPrim())
Construct a UsdGeomXformable on UsdPrim prim .
Definition: xformable.h:264
USDGEOM_API UsdAttribute CreateXformOpOrderAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
See GetXformOpOrderAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
USDGEOM_API UsdGeomXformOp AddRotateZXYOp(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.
Schema wrapper for UsdAttribute for authoring and computing transformation operations,...
Definition: xformOp.h:111
USDGEOM_API bool ClearXformOpOrder() const
Clears the local transform stack.
Type
Enumerates the set of all transformation operation types.
Definition: xformOp.h:116
USDGEOM_API bool GetResetXformStack() const
Does this prim reset its parent's inherited transformation?
static USDGEOM_API bool IsTransformationAffectedByAttrNamed(const TfToken &attrName)
Returns true if the attribute named attrName could affect the local transformation of an xformable pr...
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
USDGEOM_API UsdGeomXformOp AddRotateZOp(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.
USDGEOM_API UsdAttribute GetXformOpOrderAttr() const
Encodes the sequence of transformation operations in the order in which they should be pushed onto a ...
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Return a vector of names of all pre-declared attributes for this schema class and all its ancestor cl...
static const UsdSchemaKind schemaKind
Compile time constant representing what kind of schema this class is.
Definition: xformable.h:258
USDGEOM_API UsdGeomXformOp AddOrientOp(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.
USDGEOM_API UsdGeomXformOp MakeMatrixXform() const
Clears the existing local transform stack and creates a new xform op of type 'transform'.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
Definition: common.h:127
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
Returns the kind of schema this class belongs to.
Helper class that caches the ordered vector of UsGeomXformOps that contribute to the local transforma...
Definition: xformable.h:379
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
USDGEOM_API bool IsAttributeIncludedInLocalTransform(const TfToken &attrName) const
Returns whether the given attribute affects the local transformation computed for this query.
USDGEOM_API UsdGeomXformOp AddRotateZYXOp(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.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
virtual USDGEOM_API ~UsdGeomXformable()
Destructor.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
A basic mathematical interval class.
Definition: interval.h:50
USDGEOM_API std::vector< UsdGeomXformOp > GetOrderedXformOps(bool *resetsXformStack) const
Return the ordered list of transform operations to be applied to this prim, in least-to-most-local or...
USDGEOM_API UsdGeomXformOp AddRotateYXZOp(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.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
static USDGEOM_API UsdGeomXformable Get(const UsdStagePtr &stage, const SdfPath &path)
Return a UsdGeomXformable holding the prim adhering to this schema at path on stage.
USDGEOM_API bool HasNonEmptyXformOpOrder() const
Returns whether xformOpOrder is non-empty.
USDGEOM_API bool SetResetXformStack(bool resetXform) const
Specify whether this prim's transform should reset the transformation stack inherited from its parent...
USDGEOM_API UsdGeomXformOp AddRotateXOp(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.
USDGEOM_API UsdGeomXformOp AddRotateXZYOp(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.
Precision
Precision with which the value of the tranformation operation is encoded.
Definition: xformOp.h:140
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
USDGEOM_API bool SetXformOpOrder(std::vector< UsdGeomXformOp > const &orderedXformOps, bool resetXformStack=false) const
Reorder the already-existing transform ops on this prim.
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for 'default'.
Definition: timeCode.h:113
USDGEOM_API bool GetTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
Sets the vector of times in the interval at which xformOp samples have been authored in the cached se...
USDGEOM_API bool GetLocalTransformation(GfMatrix4d *transform, const UsdTimeCode time) const
Utilizes the internally cached UsdAttributeQuery's to efficiently compute the transform value at the ...
USDGEOM_API UsdGeomXformOp AddScaleOp(UsdGeomXformOp::Precision const precision=UsdGeomXformOp::PrecisionFloat, TfToken const &opSuffix=TfToken(), bool isInverseOp=false) const
Add a scale operation to the local stack represented by this xformable.
USDGEOM_API UsdGeomXformOp AddTranslateOp(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.
Represents a non-concrete typed schema.
TfType represents a dynamic runtime type.
Definition: type.h:64
bool GetResetXformStack() const
Returns whether the xformable resets its parent's transformation.
Definition: xformable.h:398
USDGEOM_API bool GetTimeSamples(std::vector< double > *times) const
Sets the vector of times at which xformOp samples have been authored in the cached set of xform ops.
Singleton registry that provides access to schema type information and the prim definitions for regis...
USDGEOM_API UsdGeomXformOp AddRotateYZXOp(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.
USDGEOM_API UsdGeomXformOp AddRotateXYZOp(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.
The base class for all schema types in Usd.
Definition: schemaBase.h:56
Base class for all prims that may require rendering or visualization of some sort.
Definition: imageable.h:74
Base class for all transformable prims, which allows arbitrary sequences of component affine transfor...
Definition: xformable.h:252
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:166
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
USDGEOM_API bool GetTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
Sets times to the union of all the timesamples in the interval, interval, at which xformOps that are ...
USDGEOM_API bool GetLocalTransformation(GfMatrix4d *transform, bool *resetsXformStack, const UsdTimeCode time=UsdTimeCode::Default()) const
Computes the fully-combined, local-to-parent transformation for this prim.
USDGEOM_API bool TransformMightBeTimeVarying() const
Determine whether there is any possibility that this prim's local transformation may vary over time.