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