HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_Skeleton.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16 
17 #ifndef __HUSD_Skeleton_h__
18 #define __HUSD_Skeleton_h__
19 
20 #include "HUSD_API.h"
21 
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_TimeCode.h"
24 
25 #include <GU/GU_AgentClip.h>
26 #include <GU/GU_AgentRig.h>
27 #include <SYS/SYS_Types.h>
28 #include <UT/UT_NonCopyable.h>
29 #include <UT/UT_UniquePtr.h>
30 
31 class GU_AgentClip;
32 class GU_AgentLayer;
33 class GU_AgentShapeLib;
34 class GU_Detail;
35 class HUSD_AutoReadLock;
36 class UT_StringHolder;
37 class UT_StringRef;
38 
39 /// Returns the path to a SkelRoot prim in the stage, or the empty string.
42 
43 /// Imports all skinnable primitives underneath the provided SkelRoot prim.
44 HUSD_API bool
46  const UT_StringRef &skelrootpath,
47  const UT_StringRef &purpose,
48  const UT_StringHolder &shapeattrib);
49 
51 {
52  Animation,
53  BindPose,
54  RestPose
55 };
56 
57 /// Opaque type containing cached data for HUSDimportSkeletonPose(). The cache
58 /// is initialized by HUSDimportSkeleton().
60 {
61 public:
62  struct Impl;
63 
66 
68 
69  bool isValid() const { return bool(myImpl); }
70 
71  /// Clear the cached data.
72  void reset();
73 
74  /// Allocate empty cached data for the stage, replacing any existing data.
75  bool init(
76  HUSD_AutoReadLock &readlock,
77  const HUSD_LockedStagePtr &locked_stage);
78 
79  /// @{
80  /// Access the cached data.
81  const Impl &impl() const { return *myImpl; }
82  Impl &impl() { return *myImpl; }
83  /// @}
84 
85 private:
86  UT_UniquePtr<Impl> myImpl;
87 };
88 
89 /// Imports all Skeleton primitives underneath the provided SkelRoot prim.
90 /// A point is created for each joint, and joints are connected to their
91 /// parents by polyline primitives.
92 /// Use HUSDimportSkeletonPose() to set the skeleton's transforms. The pose
93 /// type is only used in this method to initialize attributes that aren't
94 /// time-varying.
95 /// The HUSD_SkeletonCache is initialized for use with HUSDimportSkeletonPose().
96 /// The locked stage is required if the data handle is from a LOP node.
98  GU_Detail &gdp,
99  HUSD_SkeletonCache &cache,
100  HUSD_AutoReadLock &readlock,
101  const HUSD_LockedStagePtr &locked_stage,
102  const UT_StringRef &skelrootpath,
103  HUSD_SkeletonPoseType pose_type);
104 
105 /// Updates the pose using the skeleton geometry and cached data created by
106 /// HUSDimportSkeleton().
108  GU_Detail &gdp,
109  const HUSD_SkeletonCache &cache,
110  HUSD_SkeletonPoseType pose_type,
111  HUSD_TimeCode timecode);
112 
113 /// Builds an agent rig from the SkelRoot's first Skeleton prim.
116  const UT_StringRef &skelrootpath,
117  const UT_StringHolder &rig_name,
118  bool create_locomotion_joint);
119 
120 /// Imports all skinnable primitives underneath the provided SkelRoot prim
121 /// (which are associated with the skeleton used for HUSDimportRig()), and adds
122 /// the shape bindings to the provided layer.
123 HUSD_API bool
126  HUSD_AutoReadLock &readlock,
127  const UT_StringRef &skelrootpath,
128  const UT_StringRef &purpose,
129  const UT_Vector3F &layer_bounds_scale);
130 
131 /// Initialize an agent clip from the animation associated with the skeleton
132 /// used for HUSDimportAgentRig().
133 /// The clip is assigned a name from the skeleton primitive's name.
136  HUSD_AutoReadLock &readlock,
137  const UT_StringRef &skelrootpath);
138 
139 /// Import clips from the provided primitive pattern, which can match against
140 /// either SkelRoot or Skeleton prims.
141 /// The clips are assigned names from the USD primitives' names.
144  HUSD_AutoReadLock &readlock,
145  const UT_StringRef &prim_pattern);
146 
147 #endif
HUSD_API bool HUSDimportSkeleton(GU_Detail &gdp, HUSD_SkeletonCache &cache, HUSD_AutoReadLock &readlock, const HUSD_LockedStagePtr &locked_stage, const UT_StringRef &skelrootpath, HUSD_SkeletonPoseType pose_type)
HUSD_API UT_StringHolder HUSDdefaultSkelRootPath(HUSD_AutoReadLock &readlock)
Returns the path to a SkelRoot prim in the stage, or the empty string.
HUSD_API UT_Array< GU_AgentClipPtr > HUSDimportAgentClips(const GU_AgentRigConstPtr &rig, HUSD_AutoReadLock &readlock, const UT_StringRef &prim_pattern)
#define HUSD_API
Definition: HUSD_API.h:32
HUSD_API bool HUSDimportSkinnedGeometry(GU_Detail &gdp, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath, const UT_StringRef &purpose, const UT_StringHolder &shapeattrib)
Imports all skinnable primitives underneath the provided SkelRoot prim.
HUSD_API bool HUSDimportAgentShapes(GU_AgentShapeLib &shapelib, GU_AgentLayer &layer, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath, const UT_StringRef &purpose, const UT_Vector3F &layer_bounds_scale)
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
bool isValid() const
Definition: HUSD_Skeleton.h:69
GLboolean reset
Definition: glad.h:5138
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
Wrapper around hboost::intrusive_ptr.
HUSD_SkeletonPoseType
Definition: HUSD_Skeleton.h:50
HUSD_API bool HUSDimportSkeletonPose(GU_Detail &gdp, const HUSD_SkeletonCache &cache, HUSD_SkeletonPoseType pose_type, HUSD_TimeCode timecode)
const Impl & impl() const
Definition: HUSD_Skeleton.h:81
UT_SharedPtr< HUSD_LockedStage > HUSD_LockedStagePtr
HUSD_API GU_AgentRigPtr HUSDimportAgentRig(HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath, const UT_StringHolder &rig_name, bool create_locomotion_joint)
Builds an agent rig from the SkelRoot's first Skeleton prim.
HUSD_API GU_AgentClipPtr HUSDimportAgentClip(const GU_AgentRigConstPtr &rig, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath)