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:
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 
88  bool setPoseInfo(UT_Array<fpreal> &pose_times, int num_poses);
89  UT_Matrix4R combineLocal(const UT_Matrix4R &L,
90  const UT_Matrix4R &pW,
91  const UT_Matrix3R &pLS,
92  const UT_Matrix3R &pLS_inv,
94  bool stretch_is_diag,
95  UT_Matrix3R *LS);
96  bool computePairWeight(int start_sample, int end_sample);
97 
98  bool isCandidatePathShorter(const KeyPath &path,
99  const PairWeight &cand);
100  bool computeShortestPaths(int num_keys, UT_AutoInterrupt &boss);
101 
102  fpreal computePathError(int keys_before);
103  int findOptimalKeyMap(int max_keys, fpreal tolerance);
104  void computeKeyMap(int num_keys);
105 
106  KeyPath &getShortPath(int end_sample, int keys_before);
107  PairWeight &getWeight(int start_sample, int end_sample);
108  UT_Vector3R *getPosChannel(int sample);
109  UT_Vector3R *getTrnChannel(int sample);
110  UT_Quaternion *getRotChannel(int sample);
111  UT_Matrix3R *getStretchChannel(int sample);
112 
113 private:
114  // Pose Varaibles
115  int myNumPoses;
116  UT_Array<fpreal> myPoseTimes;
117  UT_Array<bool> myPoseIsKeyed;
118 
119  // Joint Variables
120  int myNumJoints;
121  GA_OffsetArray myJointOffsets;
122  UT_IntArray myParents;
123 
124  UT_Array<bool> myDoComputeLocalScale;
125  UT_IntArray myScaleInheritance;
126 
127  UT_UniquePtr<UT_Vector3R[]> myPosChannels;
128  UT_UniquePtr<UT_Vector3R[]> myTrnChannels;
129  UT_UniquePtr<UT_Quaternion[]> myRotChannels;
130  UT_UniquePtr<UT_Matrix3R[]> myStretchChannels;
131  UT_Array<bool> myStretchIsDiag;
132 
133  // Weight Variables
134  bool myMaxStepIsBounded;
135  int myMaxStep;
136  int myMaxComputedStep;
137 
138  GU_MotionClipSalientPoses::Method myWeightMethod;
139  UT_Array<PairWeight> myFramePairWeight;
140 
141  // Path Variables
142  int myNumKeysComputed;
143 
144  UT_Array<KeyPath> myShortPaths;
145 
146  // Key Map Variables
147  bool myKeyMapIsValid;
148  int myKeyMapLength;
149  fpreal myKeyMapError;
150  UT_Array<int> myKeyMap;
151 };
152 
153 #endif
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:33
#define GU_API
Definition: GU_API.h:14
GLenum mode
Definition: glcorearb.h:98
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
fpreal64 fpreal
Definition: SYS_Types.h:277
UT_ScaleInheritanceMode
Scale inheritance modes.