HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_SkeletalAnimation.h
Go to the documentation of this file.
1 #ifndef __GLTF_SkeletalAnimation_h__
2 #define __GLTF_SkeletalAnimation_h__
3 
4 #include "GLTFZ_API.h"
5 #include "GLTF_Channel.h"
6 #include "GLTF_Translator.h"
7 #include "GLTF_Types.h"
8 
9 #include <GA/GA_Handle.h>
10 #include <UT/UT_Array.h>
11 #include <UT/UT_Map.h>
12 #include <UT/UT_Set.h>
13 #include <UT/UT_StringHolder.h>
14 #include <UT/UT_Vector3.h>
15 #include <UT/UT_VectorTypes.h>
16 
17 class GLTF_ErrorManager;
18 class GLTF_Reader;
19 class GU_Detail;
20 struct cgltf_node;
21 
23 {
24 public:
25 
27  {
31  };
32 
33 public:
34 
35  /// Export API
36 
37  void reset();
38 
39  void setRestTime(fpreal time) { myRestTime = time; }
40  fpreal getRestTime() const { return myRestTime; }
41 
42 public:
44 
45  bool loadSkeletalAnimation(
46  GLTF_Reader& reader,
47  GU_Detail* gdp,
48  GLTF_Index anim_idx,
49  GLTF_ErrorManager& errors);
50 
51  bool loadRestPose(
52  GLTF_Reader& reader,
53  GU_Detail* gdp,
54  GLTF_Index skin_node_idx,
55  GLTF_ErrorManager& errors);
56 
57  void getFrameRange(GLTF_Index anim_idx,
58  fpreal& start,
59  fpreal& end) const;
60 
62  {
63  mySkeletonColor = color;
64  }
66  {
67  myImportSpace = space;
68  }
69 
70  void getActiveAnimationIds(UT_Array<GLTF_Index>& ids) const;
71  UT_StringHolder getActiveAnimationName(GLTF_Index id) const;
72 
73  bool updateSkeletalAnimation(GLTF_Reader& reader,
74  GU_Detail* gdp,
75  float time);
76 
77  bool isSceneAnimated(const GLTF_Reader& reader,
78  const GLTF_Index scene_idx) const;
79  bool isNodeAnimated(const GLTF_Reader& reader,
80  const GLTF_Index node_idx) const;
81 
82 private:
83 
84  // Finds the index of a cgltf_node object that is the root of the skeleton
85  // (i.e. a common ancestor of all of the joints).
86  bool getSkeletonRoot(
87  GLTF_Reader &gltf_reader,
88  const GLTF_Index skin_idx,
89  GLTF_Index &root_node_idx,
90  GLTF_ErrorManager& errors);
91 
92  bool updateAnimatedJointHierarchy(
93  GLTF_Reader& reader,
94  GU_Detail* gdp,
95  const GLTF_Index joint_idx,
96  const UT_Matrix4& parent_tm,
97  float time);
98 
99  bool loadAnimation(
100  GLTF_Reader& reader,
101  GLTF_Animation& anim,
102  const GLTF_Index anim_idx,
103  GLTF_ErrorManager& errors);
104 
105  using GLTF_NodeChannelTarget = std::pair<GLTF_Index, GLTF_ChannelTarget>;
106 
107  UT_Set<GLTF_NodeChannelTarget> myNodeChannelPairs;
108 
109  // Skeletal Animation Class Members
110  GLTF_Animation mySkeletalAnimation;
111  UT_Array<GLTF_Index> myRootNodes; // Index into the myJoints array
113  GLTF_Translator::Node> myJoints;
114  UT_Vector3R mySkeletonColor{0.0, 0.09, 1.0};
115  GLTF_Translator::ImportSpace myImportSpace =
117 
118  fpreal myRestTime = 1.0f;
119 };
120 
121 #endif // __GLTF_SkeletalAnimation_h__
Unsorted map container.
Definition: UT_Map.h:114
GT_API const UT_StringHolder time
void setSkeletonColor(const UT_Vector3R color)
GLuint start
Definition: glcorearb.h:475
void setImportSpace(GLTF_Translator::ImportSpace space)
GLboolean reset
Definition: glad.h:5138
GLuint GLuint end
Definition: glcorearb.h:475
std::size_t GLTF_Index
Definition: GLTF_Types.h:13
GLuint color
Definition: glcorearb.h:1261
fpreal64 fpreal
Definition: SYS_Types.h:283
#define GLTFZ_API
Definition: GLTFZ_API.h:37
GLuint * ids
Definition: glcorearb.h:652