HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_MotionClipSalientPoses.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GU_MotionClipSalientPoses.h ( GU Library, C++)
7  *
8  * COMMENTS: Finds salient poses from a motion clip.
9  *
10  */
11 
12 #ifndef __GU_MOTIONCLIPSALIENTPOSES_H__
13 #define __GU_MOTIONCLIPSALIENTPOSES_H__
14 
15 #include "GU_API.h"
16 
17 #include "GU_DetailHandle.h"
18 #include "GU_MotionClip.h"
19 
20 #include <UT/UT_Interrupt.h>
21 #include <UT/UT_String.h>
22 #include <UT/UT_UniquePtr.h>
23 #include <UT/UT_ValArray.h>
24 #include <UT/UT_WorkBuffer.h>
25 
27 {
28 public:
29 
30  enum class Method
31  {
32  MinFrame = 0,
33  MinJoint = 1,
34  MinAvg = 2
35  };
36 
38  virtual ~GU_MotionClipSalientPoses();
39 
40  int getKeySample(int key);
41  fpreal getKeyTime(int key);
42  bool isPoseKeyed(int pose);
43 
44  bool keyMapIsValid() { return myKeyMapIsValid; }
45  int keyMapLength() { return myKeyMapLength; }
46  fpreal keyMapError() { return myKeyMapError; }
47 
48  int numPoses() { return myNumPoses; }
49 
50  bool initializeChannels(UT_Array<GU_Detail> &clip,
51  UT_Array<fpreal> &pose_times,
52  int num_poses,
53  UT_WorkBuffer &err_msg);
54  bool computeWeights(bool use_max_step,
55  int max_step,
56  UT_WorkBuffer &err_msg);
57  void computeKeys(int num_keys,
58  bool reduce_past_target,
59  fpreal tolerance,
61  UT_WorkBuffer &error_msg);
62 
63 private:
64 
65  class PairWeight
66  {
67  public:
68  fpreal worst_pose;
69  fpreal worst_joint;
70  fpreal pose_sum;
71  };
72  class KeyPath
73  {
74  public:
75  fpreal worst_pose;
76  fpreal worst_joint;
77  fpreal pose_sum;
78  int key;
79  };
80 
81  void resetArrays();
82 
83  void unboundMaxStep();
84  bool boundMaxStep(int max_step);
85 
86  bool initializeJointArrays(GU_Detail *frame_gdp,
87  UT_WorkBuffer &err_msg);
88 
89  bool setPoseInfo(UT_Array<fpreal> &pose_times, int num_poses,
90  UT_WorkBuffer &err_msg);
91  UT_Matrix4R combineLocal(const UT_Matrix4R &L,
92  const UT_Matrix4R &pW,
93  const UT_Matrix3R &pLS,
94  const UT_Matrix3R &pLS_inv,
96  bool stretch_is_diag,
97  UT_Matrix3R *LS);
98  bool computePairWeight(int start_sample, int end_sample);
99 
100  bool isCandidatePathShorter(const KeyPath &path,
101  const PairWeight &cand);
102  bool computeShortestPaths(int num_keys, UT_AutoInterrupt &boss);
103 
104  fpreal computePathError(int keys_before);
105  int findOptimalKeyMap(int max_keys, fpreal tolerance);
106  void computeKeyMap(int num_keys);
107 
108  KeyPath &getShortPath(int end_sample, int keys_before);
109  PairWeight &getWeight(int start_sample, int end_sample);
110  UT_Vector3R *getPosChannel(int sample);
111  UT_Vector3R *getTrnChannel(int sample);
112  UT_Quaternion *getRotChannel(int sample);
113  UT_Matrix3R *getStretchChannel(int sample);
114 
115 private:
116  // Pose Varaibles
117  int myNumPoses;
118  UT_Array<fpreal> myPoseTimes;
119  UT_Array<bool> myPoseIsKeyed;
120 
121  // Joint Variables
122  int myNumJoints;
123  GA_OffsetArray myJointOffsets;
124  UT_IntArray myParents;
125 
126  UT_Array<bool> myDoComputeLocalScale;
127  UT_IntArray myScaleInheritance;
128 
129  UT_UniquePtr<UT_Vector3R[]> myPosChannels;
130  UT_UniquePtr<UT_Vector3R[]> myTrnChannels;
131  UT_UniquePtr<UT_Quaternion[]> myRotChannels;
132  UT_UniquePtr<UT_Matrix3R[]> myStretchChannels;
133  UT_Array<bool> myStretchIsDiag;
134 
135  // Weight Variables
136  bool myMaxStepIsBounded;
137  int myMaxStep;
138  int myMaxComputedStep;
139 
140  GU_MotionClipSalientPoses::Method myWeightMethod;
141  UT_Array<PairWeight> myFramePairWeight;
142 
143  // Path Variables
144  int myNumKeysComputed;
145 
146  UT_Array<KeyPath> myShortPaths;
147 
148  // Key Map Variables
149  bool myKeyMapIsValid;
150  int myKeyMapLength;
151  fpreal myKeyMapError;
152  UT_Array<int> myKeyMap;
153 };
154 
155 #endif
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
#define GU_API
Definition: GU_API.h:14
GLenum mode
Definition: glcorearb.h:99
fpreal64 fpreal
Definition: SYS_Types.h:277
UT_ScaleInheritanceMode
Scale inheritance modes.
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T clip(const T &p, const Box< T > &box) IMATH_NOEXCEPT
Definition: ImathBoxAlgo.h:29