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 <GU/GU_AgentClip.h>
23 #include <GU/GU_AgentRig.h>
24 #include <SYS/SYS_Types.h>
25 #include <UT/UT_UniquePtr.h>
26 
27 class GU_AgentClip;
28 class GU_AgentLayer;
29 class GU_AgentShapeLib;
30 class GU_Detail;
31 class HUSD_AutoReadLock;
32 class UT_StringHolder;
33 class UT_StringRef;
34 
35 /// Returns the path to a SkelRoot prim in the stage, or the empty string.
38 
39 /// Imports all skinnable primitives underneath the provided SkelRoot prim.
40 HUSD_API bool
42  const UT_StringRef &skelrootpath,
43  const UT_StringHolder &shapeattrib);
44 
46 {
47  Animation,
48  BindPose,
49  RestPose
50 };
51 
52 /// Opaque type containing cached data for HUSDimportSkeletonPose(). The cache
53 /// is initialized by HUSDimportSkeleton().
55 {
56 public:
57  struct Impl;
58 
61 
62  bool isValid() const { return bool(myImpl); }
63 
64  /// Clear the cached data.
65  void reset();
66 
67  /// Allocate empty cached data, replacing any existing data.
68  void init();
69 
70  /// @{
71  /// Access the cached data.
72  const Impl &impl() const { return *myImpl; }
73  Impl &impl() { return *myImpl; }
74  /// @}
75 
76 private:
77  UT_UniquePtr<Impl> myImpl;
78 };
79 
80 /// Imports all Skeleton primitives underneath the provided SkelRoot prim.
81 /// A point is created for each joint, and joints are connected to their
82 /// parents by polyline primitives.
83 /// Use HUSDimportSkeletonPose() to set the skeleton's transforms. The pose
84 /// type is only used in this method to initialize attributes that aren't
85 /// time-varying.
86 /// The HUSD_SkeletonCache is initialized for use with HUSDimportSkeletonPose().
88  GU_Detail &gdp,
89  HUSD_SkeletonCache &cache,
90  HUSD_AutoReadLock &readlock,
91  const UT_StringRef &skelrootpath,
92  HUSD_SkeletonPoseType pose_type);
93 
94 /// Updates the pose using the skeleton geometry and cached data created by
95 /// HUSDimportSkeleton().
97  GU_Detail &gdp,
98  const HUSD_SkeletonCache &cache,
99  HUSD_AutoReadLock &readlock,
100  HUSD_SkeletonPoseType pose_type,
101  fpreal time);
102 
103 /// Builds an agent rig from the SkelRoot's first Skeleton prim.
106  const UT_StringRef &skelrootpath,
107  const UT_StringHolder &rig_name,
108  bool create_locomotion_joint);
109 
110 /// Imports all skinnable primitives underneath the provided SkelRoot prim
111 /// (which are associated with the skeleton used for HUSDimportRig()), and adds
112 /// the shape bindings to the provided layer.
113 HUSD_API bool
116  HUSD_AutoReadLock &readlock,
117  const UT_StringRef &skelrootpath,
118  fpreal layer_bounds_scale);
119 
120 /// Initialize an agent clip from the animation associated with the skeleton
121 /// used for HUSDimportAgentRig().
122 /// The clip is assigned a name from the skeleton primitive's name.
125  HUSD_AutoReadLock &readlock,
126  const UT_StringRef &skelrootpath);
127 
128 /// Import clips from the provided primitive pattern, which can match against
129 /// either SkelRoot or Skeleton prims.
130 /// The clips are assigned names from the USD primitives' names.
133  HUSD_AutoReadLock &readlock,
134  const UT_StringRef &prim_pattern);
135 
136 #endif
HUSD_API UT_StringHolder HUSDdefaultSkelRootPath(HUSD_AutoReadLock &readlock)
Returns the path to a SkelRoot prim in the stage, or the empty string.
GT_API const UT_StringHolder time
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
GLboolean reset
Definition: glew.h:4959
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
HUSD_API bool HUSDimportSkinnedGeometry(GU_Detail &gdp, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath, const UT_StringHolder &shapeattrib)
Imports all skinnable primitives underneath the provided SkelRoot prim.
bool isValid() const
Definition: HUSD_Skeleton.h:62
HUSD_API bool HUSDimportAgentShapes(GU_AgentShapeLib &shapelib, GU_AgentLayer &layer, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath, fpreal layer_bounds_scale)
Wrapper around hboost::intrusive_ptr.
HUSD_SkeletonPoseType
Definition: HUSD_Skeleton.h:45
HUSD_API bool HUSDimportSkeleton(GU_Detail &gdp, HUSD_SkeletonCache &cache, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath, HUSD_SkeletonPoseType pose_type)
const Impl & impl() const
Definition: HUSD_Skeleton.h:72
fpreal64 fpreal
Definition: SYS_Types.h:277
HUSD_API bool HUSDimportSkeletonPose(GU_Detail &gdp, const HUSD_SkeletonCache &cache, HUSD_AutoReadLock &readlock, HUSD_SkeletonPoseType pose_type, fpreal time)
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.
GLint GLboolean GLint layer
Definition: glew.h:3601
HUSD_API GU_AgentClipPtr HUSDimportAgentClip(const GU_AgentRigConstPtr &rig, HUSD_AutoReadLock &readlock, const UT_StringRef &skelrootpath)