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_StringRef &purpose,
44  const UT_StringHolder &shapeattrib);
45 
47 {
48  Animation,
49  BindPose,
50  RestPose
51 };
52 
53 /// Opaque type containing cached data for HUSDimportSkeletonPose(). The cache
54 /// is initialized by HUSDimportSkeleton().
56 {
57 public:
58  struct Impl;
59 
62 
63  bool isValid() const { return bool(myImpl); }
64 
65  /// Clear the cached data.
66  void reset();
67 
68  /// Allocate empty cached data, replacing any existing data.
69  void init();
70 
71  /// @{
72  /// Access the cached data.
73  const Impl &impl() const { return *myImpl; }
74  Impl &impl() { return *myImpl; }
75  /// @}
76 
77 private:
78  UT_UniquePtr<Impl> myImpl;
79 };
80 
81 /// Imports all Skeleton primitives underneath the provided SkelRoot prim.
82 /// A point is created for each joint, and joints are connected to their
83 /// parents by polyline primitives.
84 /// Use HUSDimportSkeletonPose() to set the skeleton's transforms. The pose
85 /// type is only used in this method to initialize attributes that aren't
86 /// time-varying.
87 /// The HUSD_SkeletonCache is initialized for use with HUSDimportSkeletonPose().
89  GU_Detail &gdp,
90  HUSD_SkeletonCache &cache,
91  HUSD_AutoReadLock &readlock,
92  const UT_StringRef &skelrootpath,
93  HUSD_SkeletonPoseType pose_type);
94 
95 /// Updates the pose using the skeleton geometry and cached data created by
96 /// HUSDimportSkeleton().
98  GU_Detail &gdp,
99  const HUSD_SkeletonCache &cache,
100  HUSD_AutoReadLock &readlock,
101  HUSD_SkeletonPoseType pose_type,
102  fpreal timecode);
103 
104 /// Builds an agent rig from the SkelRoot's first Skeleton prim.
107  const UT_StringRef &skelrootpath,
108  const UT_StringHolder &rig_name,
109  bool create_locomotion_joint);
110 
111 /// Imports all skinnable primitives underneath the provided SkelRoot prim
112 /// (which are associated with the skeleton used for HUSDimportRig()), and adds
113 /// the shape bindings to the provided layer.
114 HUSD_API bool
117  HUSD_AutoReadLock &readlock,
118  const UT_StringRef &skelrootpath,
119  const UT_StringRef &purpose,
120  const UT_Vector3F &layer_bounds_scale);
121 
122 /// Initialize an agent clip from the animation associated with the skeleton
123 /// used for HUSDimportAgentRig().
124 /// The clip is assigned a name from the skeleton primitive's name.
127  HUSD_AutoReadLock &readlock,
128  const UT_StringRef &skelrootpath);
129 
130 /// Import clips from the provided primitive pattern, which can match against
131 /// either SkelRoot or Skeleton prims.
132 /// The clips are assigned names from the USD primitives' names.
135  HUSD_AutoReadLock &readlock,
136  const UT_StringRef &prim_pattern);
137 
138 #endif
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:63
GLboolean reset
Definition: glad.h:5138
Wrapper around hboost::intrusive_ptr.
HUSD_SkeletonPoseType
Definition: HUSD_Skeleton.h:46
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:73
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 timecode)
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)