All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
jointWriter.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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 PXRUSDTRANSLATORS_JOINT_WRITER_H
25 #define PXRUSDTRANSLATORS_JOINT_WRITER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "usdMaya/primWriter.h"
31 
33 
34 #include "pxr/usd/sdf/path.h"
35 #include "pxr/usd/usd/timeCode.h"
36 #include "pxr/usd/usdGeom/xform.h"
37 #include "pxr/usd/usdSkel/animation.h"
38 #include "pxr/usd/usdSkel/animMapper.h"
39 #include "pxr/usd/usdSkel/skeleton.h"
40 #include "pxr/usd/usdSkel/topology.h"
41 
42 #include <maya/MFnDependencyNode.h>
43 
44 
45 PXR_NAMESPACE_OPEN_SCOPE
46 
47 
61 {
62 public:
64  const MFnDependencyNode& depNodeFn,
65  const SdfPath& usdPath,
66  UsdMayaWriteJobContext& jobCtx);
67 
68  void Write(const UsdTimeCode& usdTime) override;
69  bool ExportsGprims() const override;
70  bool ShouldPruneChildren() const override;
71 
74  static VtTokenArray GetJointNames(
75  const std::vector<MDagPath>& joints,
76  const MDagPath& rootJoint,
77  bool stripNamespaces);
78 
82  static SdfPath GetSkeletonPath(
83  const MDagPath& rootJoint,
84  bool stripNamespaces);
85 
86 private:
87  bool _WriteRestState();
88 
89  bool _valid;
90  UsdSkelSkeleton _skel;
91  UsdSkelAnimation _skelAnim;
92 
94  MDagPath _skelXformPath;
95 
97  MDagPath _jointHierarchyRootPath;
98 
99  UsdSkelTopology _topology;
100  UsdSkelAnimMapper _skelToAnimMapper;
101  std::vector<MDagPath> _joints, _animatedJoints;
102  UsdAttribute _skelXformAttr;
103  bool _skelXformIsAnimated;
104 };
105 
106 
107 PXR_NAMESPACE_CLOSE_SCOPE
108 
109 
110 #endif
static VtTokenArray GetJointNames(const std::vector< MDagPath > &joints, const MDagPath &rootJoint, bool stripNamespaces)
Gets the joint name tokens for the given dag paths, assuming a joint hierarchy with the given root jo...
Provides basic functionality and access to shared data for UsdMayaPrimWriters.
bool ShouldPruneChildren() const override
Whether the traversal routine using this prim writer should skip all of the Maya node&#39;s descendants w...
Object holding information describing skeleton topology.
Definition: topology.h:45
Describes a skel animation, where joint animation is stored in a vectorized form. ...
Definition: animation.h:62
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
static SdfPath GetSkeletonPath(const MDagPath &rootJoint, bool stripNamespaces)
Gets the expected path where a skeleton will be exported for the given root joint.
PXRUSDMAYA_API std::string stripNamespaces(const std::string &nodeName, const int nsDepth=-1)
Strip nsDepth namespaces from nodeName.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
void Write(const UsdTimeCode &usdTime) override
Main export function that runs when the traversal hits the node.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Describes a skeleton.
Definition: skeleton.h:63
bool ExportsGprims() const override
Whether this prim writer directly create one or more gprims on the current model on the USD stage...
Base class for all built-in and user-defined prim writers.
Definition: primWriter.h:64
Exports joint hierarchies (the hierarchies of DAG nodes rooted at a joint) as a UsdSkelSkeleton, along with a UsdSkelAnimation if the joints are animated or posed differently from their rest pose.
Definition: jointWriter.h:60