HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_CaptureRegion.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: SOP_CaptureRegion.h ( SOP Library, C++)
7  *
8  * COMMENTS: The Capture Region SOP
9  */
10 
11 #ifndef __SOP_CaptureRegion__
12 #define __SOP_CaptureRegion__
13 
14 #include "SOP_API.h"
15 #include "SOP_Node.h"
16 
18 {
19 public:
20  // effective transform order of the capture region with respect to
21  // the bone space
23 
24  SOP_CaptureRegion(OP_Network *net, const char *name,
25  OP_Operator *entry);
26  ~SOP_CaptureRegion() override;
27 
28  static OP_Node *myConstructor(OP_Network *net, const char *name,
29  OP_Operator *entry);
30  static PRM_Template myTemplateList[];
31  static PRM_Template myObsoleteList[];
32 
33  // converts unused parameters
35  PRM_ParmList *obsolete_parms) override;
36 
37  // sets the capture parameters for the bone.
38  // Capture parameters "freeze" the current parameters by storing them
39  // (or accumulation of them) in the capture parameters. The capture
40  // parameters are used for capturing geometry by bone's capture regions.
41  // They are also used for displaying the capture pose when
42  // kinematic override is set to "CAPTURE"
43  void setCaptureParameters(OP_Context &context,
44  UT_String &errors);
45 
46  // transfers regular parameters to capture parameters
47  void copyRegularToCaptureParameters( OP_Context &context );
48 
49  // Clear the rig adjustment transform
50  void clearRigAdjustment(OP_Context &context);
51 
52  // sets the rig adjustment xform so that capture and animation volumes
53  // align together.
54  // We want to satisfy the equation which encodes the alignment
55  // of animation and capture regions in world space:
56  // rig_adjust * Ma * MA = Mc * MC
57  // rig_adjust = Mc * MC * MA^ * Ma^
58  // where:
59  // MA - is a world position of animation bone, and
60  // MC - is a world position of the capture bone,
61  // Mc - is a acapture region in capture bone space
62  // Ma - is a animation region in animation bone space
63  // ^ - denotes an inverse
64  // The arguments to this method are:
65  // bone_inv_anim = MA^
66  // bone_capture = MC
67  void setRigAdjustment(OP_Context &context,
68  const UT_DMatrix4 &bone_inv_anim,
69  const UT_DMatrix4 &bone_capture,
70  UT_String &errors);
71 
72  // Creates data for capturing
73  SYS_DEPRECATED(11.0) void getCaptureData(fpreal t, UT_Matrix4 &xform,
74  float *atr_data );
75  bool getCaptureData(fpreal t, UT_Matrix4 &xform,
76  float &bcap, float &tcap,
77  float &taperx, float &taperz,
78  float &iweight, float &oweight,
79  bool capture,
80  DEP_MicroNodeList *deplist=nullptr,
81  int *timedep=nullptr);
82 
83  // sets the capture parameters so that the region
84  // capture aligns with animation
85  void synchronizeCaptureToDeform(
86  OP_Context &context,
87  const UT_DMatrix4 &bone_anim,
88  const UT_DMatrix4 &bone_inv_capture,
89  UT_String &errors);
90 
91  // sets the animation parameters so that the region
92  // animation (deform) aligns with capture
93  void synchronizeDeformToCapture(
94  OP_Context &context,
95  const UT_DMatrix4 &bone_inv_anim,
96  const UT_DMatrix4 &bone_capture,
97  UT_String &errors);
98 
99  // get and set the matrix (adjusted for the zfactor)
100  void getCaptureXform( OP_Context &context, UT_DMatrix4 &xform );
101  void setCaptureXform( OP_Context &context, const UT_DMatrix4 &xform);
102 
103  // get and set the matrix (adjusted for the zfactor)
104  void getDeformXform( OP_Context &context, UT_DMatrix4 &xform );
105  void setDeformXform( OP_Context &context, const UT_DMatrix4 &xform );
106 
107  // obtains a rig adjustmen transform. This transform is calculated when
108  // animation bone position has been moved away from capture bone position
109  // without the intention of animating. This happend often in rigging
110  // process, for example adjusting joints of a limb after skin has been
111  // captured. Rig adjutment transform alligns the animation region
112  // with capture region so that no deformation occures on the skin.
113  void getRigAdjustXform( OP_Context & context, UT_DMatrix4 &xform );
114 
115  // indices to the parameters: must correspond to myTemplateList entries
117  {
118  I_SWITCHER = 0,
119 
130 
135 
146 
148  I_N_SOPCAPTURE_INDICES // should remain the last in this list
149  };
150 
151  float COLORR(fpreal t) { return evalFloat( I_COLOR, 0, t); }
152  float COLORG(fpreal t) { return evalFloat( I_COLOR, 1, t); }
153  float COLORB(fpreal t) { return evalFloat( I_COLOR, 2, t); }
154 
155  bool getTransform(TransformMode mode, UT_Matrix4D &xform,
156  OP_Context &context) override;
157 
158  protected:
159  OP_ERROR cookMySop(OP_Context &context) override;
160 
161 private:
162  // gets (capture override dependent) values for the capture region
163  void getParameters( fpreal t,
164  float &tx, float &ty, float &tz,
165  float &rx, float &ry, float &rz,
166  float &squash_x, float &squash_y, float &squash_z,
167  float &top_tube_sy, float &bot_tube_sy,
168  float &top_x, float &top_y, float &top_z,
169  float &bot_x, float &bot_y, float &bot_z,
170  int &axis,
171  bool capture,
172  DEP_MicroNodeList *deplist, int *timedep );
173 
174  // creates channel and inserts a reference in it
175  bool createChannelWithReference(const char* ch_name,
176  const char* ref,
177  CH_ExprLanguage language);
178  bool updateObsoleteParm(PRM_ParmList *obsolete_parms,
179  const char *old_parm_name, int vi,
180  const char *new_parm_name,
181  const char *new_chan_name,
182  const char *find_expr,
183  const char *replace_expr,
184  float scale);
185 
186  // sets the height and caps of the tube to match
187  void setDeformToCaptureTube( OP_Context &context );
188  void setCaptureToDeformTube( OP_Context &context );
189 
190  // NOTE: xform should be crackable with the CR_XFORM_ORDER (i.e., RTS)
191  void setRigAdjustXform(OP_Context &context,
192  const UT_DMatrix4 &xform,
193  UT_String &errors);
194 
195  // recalculates the value of the zfactor adjustment
196  void updateRigAdjusmentZFactor( OP_Context &context );
197 
198 
199  int AXIS() { return evalInt ( I_AXIS, 0, 0); }
200  float CENTERX(fpreal t) { return evalFloat( I_CENTER, 0, t); }
201  float CENTERY(fpreal t) { return evalFloat( I_CENTER, 1, t); }
202  float CENTERZ(fpreal t) { return evalFloat( I_CENTER, 2, t); }
203  float ORIENTX(fpreal t) { return evalFloat( I_ORIENT, 0, t); }
204  float ORIENTY(fpreal t) { return evalFloat( I_ORIENT, 1, t); }
205  float ORIENTZ(fpreal t) { return evalFloat( I_ORIENT, 2, t); }
206  float SQUASHX(fpreal t) { return evalFloat( I_SQUASH, 0, t); }
207  float SQUASHY(fpreal t) { return evalFloat( I_SQUASH, 1, t); }
208  float SQUASHZ(fpreal t) { return evalFloat( I_SQUASH, 2, t); }
209  float TOPHEIGHT(fpreal t) { return evalFloat( I_TOP_H, 0, t); }
210  float TOPX(fpreal t) { return evalFloat( I_TOP_CAP, 0, t); }
211  float TOPY(fpreal t) { return evalFloat( I_TOP_CAP, 1, t); }
212  float TOPZ(fpreal t) { return evalFloat( I_TOP_CAP, 2, t); }
213  float BOTHEIGHT(fpreal t) { return evalFloat( I_BOT_H, 0, t); }
214  float BOTX(fpreal t) { return evalFloat( I_BOT_CAP, 0, t); }
215  float BOTY(fpreal t) { return evalFloat( I_BOT_CAP, 1, t); }
216  float BOTZ(fpreal t) { return evalFloat( I_BOT_CAP, 2, t); }
217  float ZFACTOR(fpreal t) { return evalFloat( I_ZFACTOR, 0, t); }
218 
219  float RIGADJUSTTX(fpreal t) {return evalFloat( I_RIG_ADJUST_T, 0, t);}
220  float RIGADJUSTTY(fpreal t) {return evalFloat( I_RIG_ADJUST_T, 1, t);}
221  float RIGADJUSTTZ(fpreal t) {return evalFloat( I_RIG_ADJUST_T, 2, t);}
222  float RIGADJUSTRX(fpreal t) {return evalFloat( I_RIG_ADJUST_R, 0, t);}
223  float RIGADJUSTRY(fpreal t) {return evalFloat( I_RIG_ADJUST_R, 1, t);}
224  float RIGADJUSTRZ(fpreal t) {return evalFloat( I_RIG_ADJUST_R, 2, t);}
225  float RIGADJUSTSX(fpreal t) {return evalFloat( I_RIG_ADJUST_S, 0, t);}
226  float RIGADJUSTSY(fpreal t) {return evalFloat( I_RIG_ADJUST_S, 1, t);}
227  float RIGADJUSTSZ(fpreal t) {return evalFloat( I_RIG_ADJUST_S, 2, t);}
228  float RIGADJUSTZFACTOR(fpreal t)
229  {return evalFloat( I_RIG_ADJUST_ZFACTOR, 0, t);}
230 
231  int C_AXIS() { return evalInt ( I_C_AXIS, 0, 0); }
232  float C_CENTERX(fpreal t) { return evalFloat( I_C_CENTER, 0, t); }
233  float C_CENTERY(fpreal t) { return evalFloat( I_C_CENTER, 1, t); }
234  float C_CENTERZ(fpreal t) { return evalFloat( I_C_CENTER, 2, t); }
235  float C_ORIENTX(fpreal t) { return evalFloat( I_C_ORIENT, 0, t); }
236  float C_ORIENTY(fpreal t) { return evalFloat( I_C_ORIENT, 1, t); }
237  float C_ORIENTZ(fpreal t) { return evalFloat( I_C_ORIENT, 2, t); }
238  float C_SQUASHX(fpreal t) { return evalFloat( I_C_SQUASH, 0, t); }
239  float C_SQUASHY(fpreal t) { return evalFloat( I_C_SQUASH, 1, t); }
240  float C_SQUASHZ(fpreal t) { return evalFloat( I_C_SQUASH, 2, t); }
241  float C_TOPHEIGHT(fpreal t){ return evalFloat( I_C_TOP_H, 0, t); }
242  float C_TOPX(fpreal t) { return evalFloat( I_C_TOP_CAP, 0, t); }
243  float C_TOPY(fpreal t) { return evalFloat( I_C_TOP_CAP, 1, t); }
244  float C_TOPZ(fpreal t) { return evalFloat( I_C_TOP_CAP, 2, t); }
245  float C_BOTHEIGHT(fpreal t){ return evalFloat( I_C_BOT_H, 0, t); }
246  float C_BOTX(fpreal t) { return evalFloat( I_C_BOT_CAP, 0, t); }
247  float C_BOTY(fpreal t) { return evalFloat( I_C_BOT_CAP, 1, t); }
248  float C_BOTZ(fpreal t) { return evalFloat( I_C_BOT_CAP, 2, t); }
249  float C_ZFACTOR(fpreal t){ return evalFloat(I_C_ZFACTOR, 0, t); }
250  float C_INWEIGHT(fpreal t) { return evalFloat( I_C_RANGE_W, 0, t); }
251  float C_OUTWEIGHT(fpreal t){ return evalFloat( I_C_RANGE_W, 1, t); }
252 
253 
254  void setAXIS( int v) { setChRefInt ( I_AXIS, 0, 0, v); }
255  void setCENTER(const UT_Vector3 &v, fpreal t)
256  {
257  setChRefFloat( I_CENTER, 0, t, v.x());
258  setChRefFloat( I_CENTER, 1, t, v.y());
259  setChRefFloat( I_CENTER, 2, t, v.z());
260  }
261  void setORIENT(const UT_Vector3 &v, fpreal t)
262  {
263  setChRefFloat( I_ORIENT, 0, t, v.x());
264  setChRefFloat( I_ORIENT, 1, t, v.y());
265  setChRefFloat( I_ORIENT, 2, t, v.z());
266  }
267  void setSQUASH(const UT_Vector3 &v, fpreal t)
268  {
269  setChRefFloat( I_SQUASH, 0, t, v.x());
270  setChRefFloat( I_SQUASH, 1, t, v.y());
271  setChRefFloat( I_SQUASH, 2, t, v.z());
272  }
273  void setTOPHEIGHT(float v, fpreal t)
274  {
275  setChRefFloat( I_TOP_H, 0, t, v);
276  }
277  void setTOP(const UT_Vector3 &v, fpreal t)
278  {
279  setChRefFloat( I_TOP_CAP, 0, t, v.x());
280  setChRefFloat( I_TOP_CAP, 1, t, v.y());
281  setChRefFloat( I_TOP_CAP, 2, t, v.z());
282  }
283  void setBOTHEIGHT(float v, fpreal t)
284  {
285  setChRefFloat( I_BOT_H, 0, t, v);
286  }
287  void setBOT(const UT_Vector3 &v, fpreal t)
288  {
289  setChRefFloat( I_BOT_CAP, 0, t, v.x());
290  setChRefFloat( I_BOT_CAP, 1, t, v.y());
291  setChRefFloat( I_BOT_CAP, 2, t, v.z());
292  }
293  void setZFACTOR(float v, fpreal t)
294  {
295  setChRefFloat( I_ZFACTOR, 0, t, v);
296  }
297 
298 
299 
300  void setC_AXIS( int v) { setChRefInt ( I_C_AXIS, 0, 0, v); }
301  void setC_CENTER(const UT_Vector3 &v, fpreal t)
302  {
303  setChRefFloat( I_C_CENTER, 0, t, v.x());
304  setChRefFloat( I_C_CENTER, 1, t, v.y());
305  setChRefFloat( I_C_CENTER, 2, t, v.z());
306  }
307  void setC_ORIENT(const UT_Vector3 &v, fpreal t)
308  {
309  setChRefFloat( I_C_ORIENT, 0, t, v.x());
310  setChRefFloat( I_C_ORIENT, 1, t, v.y());
311  setChRefFloat( I_C_ORIENT, 2, t, v.z());
312  }
313  void setC_SQUASH(const UT_Vector3 &v, fpreal t)
314  {
315  setChRefFloat( I_C_SQUASH, 0, t, v.x());
316  setChRefFloat( I_C_SQUASH, 1, t, v.y());
317  setChRefFloat( I_C_SQUASH, 2, t, v.z());
318  }
319  void setC_TOPHEIGHT(float v, fpreal t)
320  {
321  setChRefFloat( I_C_TOP_H, 0, t, v);
322  }
323  void setC_TOP(const UT_Vector3 &v, fpreal t)
324  {
325  setChRefFloat( I_C_TOP_CAP, 0, t,v.x());
326  setChRefFloat( I_C_TOP_CAP, 1, t,v.y());
327  setChRefFloat( I_C_TOP_CAP, 2, t,v.z());
328  }
329  void setC_BOTHEIGHT(float v, fpreal t)
330  {
331  setChRefFloat( I_C_BOT_H, 0, t, v);
332  }
333  void setC_BOT(const UT_Vector3 &v, fpreal t)
334  {
335  setChRefFloat( I_C_BOT_CAP, 0, t,v.x());
336  setChRefFloat( I_C_BOT_CAP, 1, t,v.y());
337  setChRefFloat( I_C_BOT_CAP, 2, t,v.z());
338  }
339  void setC_ZFACTOR(float v, fpreal t)
340  {
341  setChRefFloat( I_C_ZFACTOR, 0, t, v);
342  }
343 
344  void setRIGADJUSTT(const UT_Vector3 &v, fpreal t)
345  {
346  setChRefFloat(I_RIG_ADJUST_T,0,t,v.x());
347  setChRefFloat(I_RIG_ADJUST_T,1,t,v.y());
348  setChRefFloat(I_RIG_ADJUST_T,2,t,v.z());
349  }
350  void setRIGADJUSTR(const UT_Vector3 &v, fpreal t)
351  {
352  setChRefFloat(I_RIG_ADJUST_R,0,t,v.x());
353  setChRefFloat(I_RIG_ADJUST_R,1,t,v.y());
354  setChRefFloat(I_RIG_ADJUST_R,2,t,v.z());
355  }
356  void setRIGADJUSTS(const UT_Vector3 &v, fpreal t)
357  {
358  setChRefFloat(I_RIG_ADJUST_S,0,t,v.x());
359  setChRefFloat(I_RIG_ADJUST_S,1,t,v.y());
360  setChRefFloat(I_RIG_ADJUST_S,2,t,v.z());
361  }
362  void setRIGADJUSTZFACTOR(float v, fpreal t)
363  {
364  setChRefFloat( I_RIG_ADJUST_ZFACTOR,
365  0, t, v );
366  }
367 
368 };
369 
370 #endif
static UT_XformOrder CR_XFORM_ORDER
#define SYS_DEPRECATED(__V__)
CH_ExprLanguage
void
Definition: png.h:1083
const GLdouble * v
Definition: glcorearb.h:837
virtual bool getTransform(TransformMode mode, UT_Matrix4D &xform, OP_Context &)
Transformation order of scales, rotates, and translates.
Definition: UT_XformOrder.h:23
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:667
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
float COLORB(fpreal t)
GA_API const UT_StringHolder scale
void setChRefFloat(int pi, int vi, fpreal t, fpreal val, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING, bool propagate=true)
GLint ref
Definition: glcorearb.h:124
float COLORR(fpreal t)
void setChRefInt(int pi, int vi, fpreal t, exint val, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING, bool propagate=true)
GLuint const GLchar * name
Definition: glcorearb.h:786
float COLORG(fpreal t)
GLdouble t
Definition: glad.h:2397
GLenum mode
Definition: glcorearb.h:99
virtual void resolveObsoleteParms(PRM_ParmList *)
fpreal64 fpreal
Definition: SYS_Types.h:277
#define SOP_API
Definition: SOP_API.h:10
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:665
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:663