All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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"
31 #include "pxr/usd/usdGeom/imageable.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  UsdSchemaType _GetSchemaType() 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 
410  USDGEOM_API
411  bool GetTimeSamples(std::vector<double> *times) const;
412 
417  USDGEOM_API
418  bool GetTimeSamplesInInterval(const GfInterval &interval,
419  std::vector<double> *times) const;
420 
423  USDGEOM_API
425  const TfToken &attrName) const;
426 
427  private:
428  // Cached copy of the vector of ordered xform ops.
429  std::vector<UsdGeomXformOp> _xformOps;
430 
431  // Cache whether the xformable has !resetsXformStack! in its
432  // xformOpOrder.
433  bool _resetsXformStack;
434  };
435 
471  USDGEOM_API
475  TfToken const &opSuffix = TfToken(),
476  bool isInverseOp=false) const;
477 
482  USDGEOM_API
485  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
486 
491  USDGEOM_API
494  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
495 
501  USDGEOM_API
504  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
505 
511  USDGEOM_API
514  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
515 
520  USDGEOM_API
523  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
524 
530  USDGEOM_API
533  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
534 
540  USDGEOM_API
543  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
544 
550  USDGEOM_API
553  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
554 
560  USDGEOM_API
563  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
564 
570  USDGEOM_API
573  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
574 
580  USDGEOM_API
583  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
584 
589  USDGEOM_API
592  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
593 
603  USDGEOM_API
606  TfToken const &opSuffix = TfToken(), bool isInverseOp=false) const;
607 
617  USDGEOM_API
618  bool SetResetXformStack(bool resetXform) const;
619 
626  USDGEOM_API
627  bool GetResetXformStack() const;
628 
650  USDGEOM_API
651  bool SetXformOpOrder(std::vector<UsdGeomXformOp> const &orderedXformOps,
652  bool resetXformStack = false) const;
653 
671  USDGEOM_API
672  std::vector<UsdGeomXformOp> GetOrderedXformOps(bool *resetsXformStack) const;
673 
675  USDGEOM_API
676  bool ClearXformOpOrder() const;
677 
686  USDGEOM_API
688 
695  USDGEOM_API
696  bool TransformMightBeTimeVarying() const;
697 
706  USDGEOM_API
708  const std::vector<UsdGeomXformOp> &ops) const;
709 
717  USDGEOM_API
718  bool GetTimeSamples(std::vector<double> *times) const;
719 
728  USDGEOM_API
729  bool GetTimeSamplesInInterval(const GfInterval &interval,
730  std::vector<double> *times) const;
731 
739  USDGEOM_API
740  static bool GetTimeSamples(
741  std::vector<UsdGeomXformOp> const &orderedXformOps,
742  std::vector<double> *times);
743 
752  USDGEOM_API
753  static bool GetTimeSamplesInInterval(
754  std::vector<UsdGeomXformOp> const &orderedXformOps,
755  const GfInterval &interval,
756  std::vector<double> *times);
757 
778  USDGEOM_API
780  GfMatrix4d *transform,
781  bool *resetsXformStack,
782  const UsdTimeCode time = UsdTimeCode::Default()) const;
783 
805  USDGEOM_API
806  bool GetLocalTransformation(GfMatrix4d *transform,
807  bool *resetsXformStack,
808  const std::vector<UsdGeomXformOp> &ops,
809  const UsdTimeCode time = UsdTimeCode::Default()) const;
810 
823  USDGEOM_API
824  static bool GetLocalTransformation(GfMatrix4d *transform,
825  std::vector<UsdGeomXformOp> const &ops,
826  const UsdTimeCode time);
827 
830  USDGEOM_API
831  static bool IsTransformationAffectedByAttrNamed(const TfToken &attrName);
832 
833 private:
834  // Extracts the value of the xformOpOrder attribute. Returns false if
835  // the xformOpOrder attribute doesn't exist on the prim (eg. when the prim
836  // type is incompatible or if it's a pure over).
837  bool _GetXformOpOrderValue(VtTokenArray *xformOpOrder) const;
838 
839  // Helper function for getting xformops with or without attribute queries.
840  std::vector<UsdGeomXformOp>
841  _GetOrderedXformOps(bool *resetsXformStack,
842  bool withAttributeQueries) const;
843 };
844 
845 PXR_NAMESPACE_CLOSE_SCOPE
846 
847 #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.
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.
USDGEOM_API bool GetResetXformStack() const
Does this prim reset its parent&#39;s inherited transformation?
USDGEOM_API UsdSchemaType _GetSchemaType() const override
Returns the type of schema this class belongs to.
USDGEOM_API UsdGeomXformOp MakeMatrixXform() const
Clears the existing local transform stack and creates a new xform op of type &#39;transform&#39;.
UsdGeomXformable(const UsdSchemaBase &schemaObj)
Construct a UsdGeomXformable on the prim held by schemaObj .
Definition: xformable.h:272
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 ...
UsdGeomXformable(const UsdPrim &prim=UsdPrim())
Construct a UsdGeomXformable on UsdPrim prim .
Definition: xformable.h:264
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.
USDGEOM_API bool GetLocalTransformation(GfMatrix4d *transform, const UsdTimeCode time) const
Utilizes the internally cached UsdAttributeQuery&#39;s to efficiently compute the transform value at the ...
static const UsdSchemaType schemaType
Compile time constant representing what kind of schema this class is.
Definition: xformable.h:258
Schema wrapper for UsdAttribute for authoring and computing transformation operations, as consumed by UsdGeomXformable schema.
Definition: xformOp.h:111
USDGEOM_API bool TransformMightBeTimeVarying() const
Determine whether there is any possibility that this prim&#39;s local transformation may vary over time...
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.
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 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...
Type
Enumerates the set of all transformation operation types.
Definition: xformOp.h:116
static USDGEOM_API bool IsTransformationAffectedByAttrNamed(const TfToken &attrName)
Returns true if the attribute named attrName could affect the local transformation of an xformable pr...
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...
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
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 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.
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.
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.
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...
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:89
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...
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.
Double precision.
Definition: xformOp.h:141
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
USDGEOM_API bool IsAttributeIncludedInLocalTransform(const TfToken &attrName) const
Returns whether the given attribute affects the local transformation computed for this query...
USDGEOM_API UsdAttribute GetXformOpOrderAttr() const
Encodes the sequence of transformation operations in the order in which they should be pushed onto a ...
virtual USDGEOM_API ~UsdGeomXformable()
Destructor.
UsdSchemaType
An enum representing which type of schema a given schema class belongs to.
Definition: common.h:127
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:433
A basic mathematical interval class.
Definition: interval.h:50
Represents a non-concrete typed schema.
bool GetResetXformStack() const
Returns whether the xformable resets its parent&#39;s transformation.
Definition: xformable.h:398
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
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 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 ClearXformOpOrder() const
Clears the local transform stack.
Precision
Precision with which the value of the tranformation operation is encoded.
Definition: xformOp.h:140
USDGEOM_API bool SetResetXformStack(bool resetXform) const
Specify whether this prim&#39;s transform should reset the transformation stack inherited from its parent...
Contains an asset path and an optional resolved path.
Definition: assetPath.h:43
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.
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for &#39;default&#39;.
Definition: timeCode.h:113
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 bool GetLocalTransformation(GfMatrix4d *transform, bool *resetsXformStack, const UsdTimeCode time=UsdTimeCode::Default()) const
Computes the fully-combined, local-to-parent transformation for this prim.
TfType represents a dynamic runtime type.
Definition: type.h:70
Singleton registry that provides access to prim and property definition information for registered Us...
USDGEOM_API bool TransformMightBeTimeVarying() const
Returns whether the xform value might change over time.
USDGEOM_API bool SetXformOpOrder(std::vector< UsdGeomXformOp > const &orderedXformOps, bool resetXformStack=false) const
Reorder the already-existing transform ops on this prim.
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...
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:182
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 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. ...