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 
58 {
59  /// Uses the stage's time code range.
60  Stage,
61  /// Uses the range of time samples for attributes which are used to compute
62  /// the skeleton animation.
64  /// Use a manually-specified time code range.
65  Custom
66 };
67 
68 /// Opaque type containing cached data for HUSDimportSkeletonPose(). The cache
69 /// is initialized by HUSDimportSkeleton().
71 {
72 public:
73  struct Impl;
74 
77 
79 
80  bool isValid() const { return bool(myImpl); }
81 
82  /// Clear the cached data.
83  void reset();
84 
85  /// Allocate empty cached data for the stage, replacing any existing data.
86  bool init(
87  HUSD_AutoReadLock &readlock,
88  const HUSD_LockedStagePtr &locked_stage);
89 
90  /// @{
91  /// Access the cached data.
92  const Impl &impl() const { return *myImpl; }
93  Impl &impl() { return *myImpl; }
94  /// @}
95 
96 private:
97  UT_UniquePtr<Impl> myImpl;
98 };
99 
100 /// Imports all Skeleton primitives underneath the provided SkelRoot prim.
101 /// A point is created for each joint, and joints are connected to their
102 /// parents by polyline primitives.
103 /// Use HUSDimportSkeletonPose() to set the skeleton's transforms. The pose
104 /// type is only used in this method to initialize attributes that aren't
105 /// time-varying.
106 /// The HUSD_SkeletonCache is initialized for use with HUSDimportSkeletonPose().
107 /// The locked stage is required if the data handle is from a LOP node.
109  GU_Detail &gdp,
110  HUSD_SkeletonCache &cache,
111  HUSD_AutoReadLock &readlock,
112  const HUSD_LockedStagePtr &locked_stage,
113  const UT_StringRef &skelrootpath,
114  HUSD_SkeletonPoseType pose_type);
115 
116 /// Updates the pose using the skeleton geometry and cached data created by
117 /// HUSDimportSkeleton().
119  GU_Detail &gdp,
120  const HUSD_SkeletonCache &cache,
121  HUSD_SkeletonPoseType pose_type,
122  HUSD_TimeCode timecode);
123 
124 /// Builds an agent rig from the SkelRoot's first Skeleton prim.
127  const UT_StringRef &skelrootpath,
128  const UT_StringHolder &rig_name,
129  bool create_locomotion_joint);
130 
131 /// Imports all skinnable primitives underneath the provided SkelRoot prim
132 /// (which are associated with the skeleton used for HUSDimportRig()), and adds
133 /// the shape bindings to the provided layer.
134 HUSD_API bool
137  HUSD_AutoReadLock &readlock,
138  const UT_StringRef &skelrootpath,
139  const UT_StringRef &purpose,
140  const UT_Vector3F &layer_bounds_scale);
141 
142 /// Initialize an agent clip from the animation associated with the skeleton
143 /// used for HUSDimportAgentRig().
144 /// The clip is assigned a name from the skeleton primitive's name.
147  HUSD_AutoReadLock &readlock,
148  const UT_StringRef &skelrootpath,
149  HUSD_ClipRangeMode clip_range_mode,
150  HUSD_TimeCode custom_start_tc,
151  HUSD_TimeCode custom_end_tc,
152  fpreal64 custom_tc_per_s);
153 
154 /// Import clips from the provided primitive pattern, which can match against
155 /// either SkelRoot or Skeleton prims.
156 /// The clips are assigned names from the USD primitives' names.
159  HUSD_AutoReadLock &readlock,
160  const UT_StringRef &prim_pattern,
161  HUSD_ClipRangeMode clip_range_mode,
162  HUSD_TimeCode custom_start_tc,
163  HUSD_TimeCode custom_end_tc,
164  fpreal64 custom_tc_per_s);
165 
166 #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.
Uses the stage's time code range.
#define HUSD_API
Definition: HUSD_API.h:31
HUSD_API GU_AgentClipPtr HUSDimportAgentClip(const GU_AgentRigConstPtr &rig, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath, HUSD_ClipRangeMode clip_range_mode, HUSD_TimeCode custom_start_tc, HUSD_TimeCode custom_end_tc, fpreal64 custom_tc_per_s)
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.
OutGridT const XformOp bool bool
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
double fpreal64
Definition: SYS_Types.h:201
bool isValid() const
Definition: HUSD_Skeleton.h:80
GLboolean reset
Definition: glad.h:5138
Use a manually-specified time code range.
#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_ClipRangeMode
Definition: HUSD_Skeleton.h:57
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:92
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 UT_Array< GU_AgentClipPtr > HUSDimportAgentClips(const GU_AgentRigConstPtr &rig, HUSD_AutoReadLock &readlock, const UT_StringRef &prim_pattern, HUSD_ClipRangeMode clip_range_mode, HUSD_TimeCode custom_start_tc, HUSD_TimeCode custom_end_tc, fpreal64 custom_tc_per_s)