HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_AnimScene.h
Go to the documentation of this file.
1 #ifndef __GLTF_AnimScene_h__
2 #define __GLTF_AnimScene_h__
3 
4 #include "GLTFZ_API.h"
5 #include "GLTF_Translator.h"
6 #include "GLTF_Types.h"
7 
8 #include <CL/CL_SimpleChannel.h>
9 #include <GA/GA_Handle.h>
10 #include <UT/UT_Array.h>
11 #include <UT/UT_Map.h>
12 #include <UT/UT_StringHolder.h>
13 #include <UT/UT_Vector3.h>
14 #include <UT/UT_VectorTypes.h>
15 
16 class GLTF_ErrorManager;
17 class GLTF_Reader;
18 class GU_Detail;
19 struct cgltf_node;
20 
22 {
23 public:
24 
26  {
30  };
31 
33  {
36  Cubic
37  };
38 
39  struct GLTF_Channel
40  {
41  GLTF_Index myJoint; // Index into the myJoints array
44 
46  UT_Array<float> myValues; // This can be Vector3 or Vector4 depending on myTargetPath
47 
49  };
50 
52  {
56  };
57 
58 public:
60 
61  // Load in the animations from a GLTF file.
62  bool load(
63  GLTF_Reader& reader,
64  GU_Detail* gdp,
65  GLTF_Index anim_idx,
66  GLTF_ErrorManager& errors);
67 
68  // Update the animation for the specified frame.
69  bool update(
70  GLTF_Reader& reader,
71  GU_Detail* gdp,
72  float time);
73 
74  void getFrameRange(
75  GLTF_Index anim_idx,
76  fpreal& start,
77  fpreal& end) const;
78 
79  void setSkeletonColor(const UT_Vector3R color) { mySkeletonColor = color; }
80 
81  GLTF_Index getAnimationId() const { return myAnimation.myAnimId; }
82  const UT_StringHolder& getAnimationName() const { return myAnimation.myAnimName; }
83 
84 private:
85 
86  // Finds the index of a cgltf_node object that is the root of the skeleton
87  // (i.e. a common ancestor of all of the joints).
88  bool getSkeletonRoot(
89  GLTF_Reader &gltf_reader,
90  const GLTF_Index skin_idx,
91  GLTF_Index &root_node_idx,
92  GLTF_ErrorManager& errors);
93 
94  bool updateAnimatedJointHierarchy(
95  GLTF_Reader& reader,
96  GU_Detail* gdp,
97  const GLTF_Index joint_idx,
98  const UT_Matrix4& parent_tm,
99  float time);
100 
101  GLTF_Animation myAnimation;
102  UT_Array<GLTF_Index> myRootNodes; // Index into the myJoints array
104  GLTF_Translator::Joint> myJoints;
105 
106  UT_Vector3R mySkeletonColor{0.0, 0.09, 1.0};
107 };
108 
109 #endif // __GLTF_AnimScene_h__
Unsorted map container.
Definition: UT_Map.h:109
UT_Array< float > myKeyframes
GT_API const UT_StringHolder time
GLuint start
Definition: glcorearb.h:475
void setSkeletonColor(const UT_Vector3R color)
GLTF_Interpolation myInterpolation
UT_Array< float > myValues
GLTF_Index getAnimationId() const
GLuint GLuint end
Definition: glcorearb.h:475
UT_Array< GLTF_Channel > myChannels
std::size_t GLTF_Index
Definition: GLTF_Types.h:6
GLTF_ChannelTarget myTarget
GLuint color
Definition: glcorearb.h:1261
fpreal64 fpreal
Definition: SYS_Types.h:278
#define GLTFZ_API
Definition: GLTFZ_API.h:37
const UT_StringHolder & getAnimationName() const
UT_Array< CL_SimpleChannel > myChannelComponents