HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_SlideModifierPaint.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 Library (C++)
7  *
8  * COMMENTS: The SlideModifierPaint SOP, which is used to paint a per-point
9  * sliding attribute for use in muscle sliding
10  *
11  */
12 
13 #ifndef __SOP_SlideModifierPaint_h__
14 #define __SOP_SlideModifierPaint_h__
15 
16 #include "SOP_API.h"
17 #include <GU/GU_Brush.h>
18 #include <GEO/GEO_Detail.h>
19 
20 #include "SOP_GDT.h"
21 #include "SOP_BrushBase.h"
22 
23 class PRM_MenuEntry;
24 
25 enum {
26  // Group parameters
28 
30 
31 #define SOP_SLIDEPAINT_NUM_DEFORM_PARMS (10)
42 
43 #define SOP_SLIDEPAINT_NUM_NIB_PARMS (18)
62 
63 #define SOP_SLIDEPAINT_NUM_SYM_PARMS (9)
73 
74 #define SOP_SLIDEPAINT_NUM_RAY_PARMS (11)
86 };
87 
89 {
90 public:
91  SOP_SlideModifierPaint(OP_Network *net, const char *name, OP_Operator *entry);
92  virtual ~SOP_SlideModifierPaint();
93 
94  virtual bool updateParmsFlags() override;
95 
96  static OP_Node *myConstructor(OP_Network *net,
97  const char *name,
98  OP_Operator *entry);
99 
100  static PRM_Template myTemplateList[];
101  static PRM_Template myObsoleteList[];
102 
103  virtual void setAccumulateStencil(bool yesno) override
104  {
106  }
107  virtual void setRayOrigin(const UT_Vector3 &orig, fpreal t) override
108  {
112  }
113  virtual void setRayOrientation(const UT_Vector3 &orient, fpreal t) override
114  {
115  setFloat(SOP_SLIDEPAINT_RAY_ORIENT_IDX, 0, t, orient.x());
116  setFloat(SOP_SLIDEPAINT_RAY_ORIENT_IDX, 1, t, orient.y());
117  setFloat(SOP_SLIDEPAINT_RAY_ORIENT_IDX, 2, t, orient.z());
118  }
119  virtual void setHitPrimitive(int primidx, fpreal t) override
120  {
121  setInt(SOP_SLIDEPAINT_RAY_HITPRIM_IDX, 0, t, primidx);
122  }
123  virtual void setHitPoint(int pt, fpreal t) override
124  {
126  }
127  virtual void setHitUVW(fpreal u, fpreal v, fpreal w, fpreal t) override
128  {
132  }
133  virtual void setHitPressure(fpreal p, fpreal t) override
134  {
136  }
137  virtual void setRadius(fpreal r, fpreal t) override
138  {
140  }
141  virtual void setUVRadius(fpreal r, fpreal t) override
142  {
144  }
145  virtual void setBrushEvent(SOP_BrushEvent event) override
146  {
147  setInt(SOP_SLIDEPAINT_RAY_EVENT_IDX, 0, 0, int(event));
148  }
149  virtual void setBrushOp(SOP_BrushOp op) override
150  {
151  int iop;
152  switch (op)
153  {
154  case SOP_BRUSHOP_SMOOTHATTRIB: iop = 1; break;
155  case SOP_BRUSHOP_ERASE: iop = 2; break;
156  case SOP_BRUSHOP_PAINT:
157  default: iop = 0; break;
158  }
159  setInt(SOP_SLIDEPAINT_OP_IDX, 0, 0, iop);
160  }
161  virtual void setBrushShape(SOP_BrushShape shape) override
162  {
163  setInt(SOP_SLIDEPAINT_SHAPE_IDX, 0, 0, int(shape));
164  }
165  virtual void setProjectionType(int projtype) override
166  {
167  setInt(SOP_SLIDEPAINT_PROJTYPE_IDX, 0, 0, projtype);
168  }
169  virtual void useForegroundColor(void) override
170  { myUseFG = true; }
171  virtual void useBackgroundColor(void) override
172  { myUseFG = false; }
173 
174  virtual void setCurrentColor(const UT_Vector3 &cd) override
175  { }
176  virtual void setVisualization(int state) override
177  {
178  // only trigger recooks if different!
179  if( myForceVisualize != state )
180  {
181  myForceVisualize = state;
182  forceRecook();
183  }
184  }
185 
186 protected:
187  virtual const char *inputLabel(unsigned idx) const override;
188 
189  // Override this function, so that we can recreate the
190  // slideModifier attribute every time the source is
191  // duplicated
192  virtual void duplicateChangedSourceWrapper(
193  unsigned idx,
194  OP_Context &context,
195  int *changed,
196  bool force=false) override;
197 
198 protected:
199  virtual void doErase() override;
200 
201 public:
202  virtual int altersGeometry() const override { return 0; }
203  virtual int altersColor() const override { return 1; }
204  virtual fpreal RAWRADIUS(fpreal t) override
205  { return evalFloat(SOP_SLIDEPAINT_RAD_IDX, 0, t); }
206  virtual fpreal RAWUVRADIUS(fpreal t) override
207  { return evalFloat(SOP_SLIDEPAINT_UVRAD_IDX, 0, t); }
208  virtual fpreal RADIUSPRESSURE(fpreal t) override
209  { return evalFloat(SOP_SLIDEPAINT_RADPRESSURE_IDX, 0, t); }
210  virtual fpreal RAWOPACITY(fpreal t) override
211  {return evalFloat(SOP_SLIDEPAINT_OPAC_IDX, 0, t) ; }
212  virtual fpreal OPACITYPRESSURE(fpreal t) override
213  {return evalFloat(SOP_SLIDEPAINT_OPACPRESSURE_IDX, 0, t) ; }
214 
215  virtual SOP_BrushOp OP(void) override
216  {
217  switch (evalInt(SOP_SLIDEPAINT_OP_IDX, 0, 0))
218  {
219  case 0:
220  return SOP_BRUSHOP_PAINT;
221  case 1:
223  case 2:
224  default:
225  return SOP_BRUSHOP_ERASE;
226  }
227  }
228 
229  virtual int ACCUMSTENCIL(void) override
230  { return evalInt(SOP_SLIDEPAINT_STENCILACCUM_IDX, 0, 0);}
231  virtual int PROJECTIONTYPE(void) override
232  { return evalInt(SOP_SLIDEPAINT_PROJTYPE_IDX, 0, 0); }
233  virtual int REALTIME(void) override
234  { return evalInt(SOP_SLIDEPAINT_REALTIME_IDX, 0, 0); }
235  virtual int SHAPE(fpreal t) override
236  { return evalInt(SOP_SLIDEPAINT_SHAPE_IDX, 0, t); }
237 
238 protected:
241  SOP_INFLATE_MODIFIER
242  };
243 
244  virtual int MERGEMODE() override
245  { return evalInt(SOP_SLIDEPAINT_MERGEMODE_IDX, 0, 0); }
246  virtual void SCRIPT (UT_String &, fpreal ) override{}
247  virtual int AXIS(void) override { return 0 ; }
248  virtual fpreal USERX(fpreal) override { return 0.0; }
249  virtual fpreal USERY(fpreal) override { return 0.0; }
250  virtual fpreal USERZ(fpreal) override { return 0.0; }
251 
252  virtual fpreal RAYORIENTX(fpreal t) override
254  virtual fpreal RAYORIENTY(fpreal t) override
256  virtual fpreal RAYORIENTZ(fpreal t) override
258  virtual fpreal RAYHITX(fpreal t) override
260  virtual fpreal RAYHITY(fpreal t) override
262  virtual fpreal RAYHITZ(fpreal t) override
264  virtual fpreal RAYHITU(fpreal t) override
265  { return evalFloat(SOP_SLIDEPAINT_RAY_HITUVW_IDX, 0,t); }
266  virtual fpreal RAYHITV(fpreal t) override
267  { return evalFloat(SOP_SLIDEPAINT_RAY_HITUVW_IDX, 1,t); }
268  virtual fpreal RAYHITW(fpreal t) override
269  { return evalFloat(SOP_SLIDEPAINT_RAY_HITUVW_IDX, 2,t); }
270  virtual fpreal RAYHITPRESSURE(fpreal t) override
272  virtual int PRIMHIT(fpreal t) override
273  { return evalInt(SOP_SLIDEPAINT_RAY_HITPRIM_IDX, 0,t); }
274  virtual int PTHIT(fpreal t) override
275  { return evalInt(SOP_SLIDEPAINT_RAY_HITPT_IDX, 0, t); }
276  virtual int EVENT() override
277  { return evalInt(SOP_SLIDEPAINT_RAY_EVENT_IDX, 0,0); }
278  virtual bool USE_FOREGROUND(void) override
279  { return myUseFG; }
280 
281  virtual fpreal FGR(fpreal t) override { return 1.0; }
282  virtual fpreal FGG(fpreal t) override { return 1.0; }
283  virtual fpreal FGB(fpreal t) override { return 1.0; }
284  virtual fpreal BGR(fpreal t) override { return 0.0; }
285  virtual fpreal BGG(fpreal t) override { return 0.0; }
286  virtual fpreal BGB(fpreal t) override { return 0.0; }
287 
288  virtual fpreal SOFTEDGE(fpreal t) override
289  { return evalFloat(SOP_SLIDEPAINT_SOFTEDGE_IDX, 0, t); }
290  virtual void KERNEL(UT_String &str, fpreal t) override
291  { evalString(str, SOP_SLIDEPAINT_KERNEL_IDX, 0, t); }
292  virtual int UPTYPE(fpreal t) override
293  { return evalInt(SOP_SLIDEPAINT_UPTYPE_IDX, 0, t); }
294  virtual fpreal UPX(fpreal t) override
295  { return evalFloat(SOP_SLIDEPAINT_UPVECTOR_IDX, 0, t); }
296  virtual fpreal UPY(fpreal t) override
297  { return evalFloat(SOP_SLIDEPAINT_UPVECTOR_IDX, 1, t); }
298  virtual fpreal UPZ(fpreal t) override
299  { return evalFloat(SOP_SLIDEPAINT_UPVECTOR_IDX, 2, t); }
300 
301  virtual fpreal PAPERNOISE(fpreal t) override
302  { return evalFloat(SOP_SLIDEPAINT_PAPER_IDX, 0, t); }
303  virtual fpreal SPLATTER(fpreal t) override
304  { return evalFloat(SOP_SLIDEPAINT_SPLATTER_IDX, 0, t); }
305  virtual void BITMAP(UT_String &str, fpreal t) override
306  { evalString(str, SOP_SLIDEPAINT_BITMAP_IDX, 0, t); }
307  virtual int BITMAPCHAN(fpreal t) override
308  { return evalInt(SOP_SLIDEPAINT_BITMAPCHAN_IDX, 0, t); }
309  virtual fpreal ANGLE(fpreal t) override
310  { return evalFloat(SOP_SLIDEPAINT_ANGLE_IDX, 0, t); }
311  virtual fpreal SQUASH(fpreal t) override
312  { return evalFloat(SOP_SLIDEPAINT_SQUASH_IDX, 0, t); }
313  virtual int DOSTAMPING() override
314  { return 0; }
315  virtual int WRITEALPHA() override
316  { return 0; }
317 
318  virtual int OVERRIDECD() override
319  { return 1; } // Always override an attribute
320 
321  // Chose the attribute name to override. We base this on the current
322  // value in the 'Attribute to Paint' menu. Ideally, it should be
323  // straightforward to add additional muscle-related attributes to
324  // paint by just adding to the menu and setting the attribute to
325  // paint accordingly.
326  virtual void CDNAME(UT_String &str, fpreal t) override
327  {
328  int attrib_to_paint;
329 
330  attrib_to_paint
332 
333  switch ( attrib_to_paint )
334  {
335  case SOP_SLIDE_MODIFIER:
336  {
338  break;
339  }
340  case SOP_INFLATE_MODIFIER:
341  {
343  break;
344  }
345  default:
346  {
348  break;
349  }
350  }
351  }
352 
353  virtual int OVERRIDEALPHA() override
354  { return 0; }
355  virtual void ALPHANAME(UT_String & /*str*/, fpreal /*t*/) override
356  {}
357  virtual int OVERRIDENML() override { return 0; }
358  virtual void NMLNAME(UT_String & /*str*/, fpreal /*t*/) override {}
359 
360  virtual fpreal SYMMETRYDIRX(fpreal t) override
361  { return evalFloat(SOP_SLIDEPAINT_SYMAXIS_IDX, 0, t); }
362  virtual fpreal SYMMETRYDIRY(fpreal t) override
363  { return evalFloat(SOP_SLIDEPAINT_SYMAXIS_IDX, 1, t); }
364  virtual fpreal SYMMETRYDIRZ(fpreal t) override
365  { return evalFloat(SOP_SLIDEPAINT_SYMAXIS_IDX, 2, t); }
366  virtual fpreal SYMMETRYORIGX(fpreal t) override
367  { return evalFloat(SOP_SLIDEPAINT_SYMORIG_IDX, 0, t); }
368  virtual fpreal SYMMETRYORIGY(fpreal t) override
369  { return evalFloat(SOP_SLIDEPAINT_SYMORIG_IDX, 1, t); }
370  virtual fpreal SYMMETRYORIGZ(fpreal t) override
371  { return evalFloat(SOP_SLIDEPAINT_SYMORIG_IDX, 2, t); }
372  virtual int DOREFLECTION() override
373  { return evalInt(SOP_SLIDEPAINT_DOREFLECT_IDX,0, 0); }
374  virtual int DOROTATION() override
375  { return evalInt(SOP_SLIDEPAINT_DOROTATION_IDX,0, 0); }
376  virtual int SYMMETRYROT(fpreal t) override
377  { return evalInt(SOP_SLIDEPAINT_SYMROT_IDX,0, t); }
378  virtual fpreal SYMMETRYDIST(fpreal t) override
379  { return evalFloat(SOP_SLIDEPAINT_SYMDIST_IDX,0, t); }
380 
381  virtual int DOUVREFLECTION() override
382  { return evalInt(SOP_SLIDEPAINT_DOUVREFLECT_IDX, 0, 0); }
383  virtual fpreal SYMMETRYUVORIGU(fpreal t) override
384  { return evalFloat(SOP_SLIDEPAINT_SYMUVORIG_IDX, 0, t); }
385  virtual fpreal SYMMETRYUVORIGV(fpreal t) override
386  { return evalFloat(SOP_SLIDEPAINT_SYMUVORIG_IDX, 1, t); }
387  virtual fpreal SYMMETRYUVANGLE(fpreal t) override
388  { return evalFloat(SOP_SLIDEPAINT_SYMUVANGLE_IDX, 0, t);}
389 
390  virtual int ADDATTRIB() override
391  { return 0; }
392  virtual int VISUALIZE() override
393  { return myForceVisualize ||
395  virtual fpreal VISLOW(fpreal t) override
396  { return evalFloat(SOP_SLIDEPAINT_VISRANGE_IDX, 0, t); }
397  virtual fpreal VISHIGH(fpreal t) override
398  { return evalFloat(SOP_SLIDEPAINT_VISRANGE_IDX, 1, t); }
399  virtual int VISMODE() override
400  { return evalInt(SOP_SLIDEPAINT_VISMODE_IDX, 0, 0); }
401 
402  virtual int USECONNECTIVITY() override
404  virtual int USENORMALS() override
405  { return evalInt(SOP_SLIDEPAINT_USENORMALS_IDX, 0, 0); }
406  virtual int USEDEPTH() override
407  { return evalInt(SOP_SLIDEPAINT_USEDEPTH_IDX, 0, 0); }
408  virtual fpreal DEPTH(fpreal t) override
409  { return evalFloat(SOP_SLIDEPAINT_DEPTH_IDX, 0, t); }
410  virtual fpreal HEIGHT(fpreal t) override
411  { return evalFloat(SOP_SLIDEPAINT_DEPTH_IDX, 1, t); }
412 
413 
414  // Find out if the brush has moved or done anything to cause us to add its
415  // effect to the current gdp.
416  virtual bool hasStrokeChanged(fpreal t) override;
417  virtual bool hasStyleChanged(fpreal t) override;
418 
419  // Find if the nib file has changed:
420  virtual bool hasNibFileChanged(fpreal t) override;
421  virtual bool hasAccumStencilChanged(fpreal t) override;
422  virtual bool hasNibLookChanged(fpreal t) override;
423 
424  virtual bool hasVisrangeChanged(fpreal t) override;
425 
426 private:
427  // Store attribute offsets for the various attributes we can affect
428  GA_ROAttributeRef mySlideOffset;
429  GA_ROAttributeRef myInflateOffset;
430 
431  // Inidicates whether or not we should use the
432  // foreground or background colour when painting.
433  bool myUseFG;
434 
435 };
436 
437 #endif
virtual void BITMAP(UT_String &str, fpreal t) override
virtual int PRIMHIT(fpreal t) override
virtual bool updateParmsFlags()
virtual void setRayOrientation(const UT_Vector3 &orient, fpreal t) override
virtual int VISMODE() override
virtual int ADDATTRIB() override
virtual int DOREFLECTION() override
virtual int DOROTATION() override
virtual fpreal SYMMETRYORIGY(fpreal t) override
virtual bool hasAccumStencilChanged(fpreal t)=0
virtual void ALPHANAME(UT_String &, fpreal) override
virtual fpreal BGR(fpreal t) override
virtual void setVisualization(int state) override
virtual void NMLNAME(UT_String &, fpreal) override
virtual int SYMMETRYROT(fpreal t) override
const GLdouble * v
Definition: glcorearb.h:836
virtual fpreal RAYORIENTY(fpreal t) override
virtual fpreal SQUASH(fpreal t) override
virtual fpreal PAPERNOISE(fpreal t) override
virtual void setHitPrimitive(int primidx, fpreal t) override
virtual bool hasStyleChanged(fpreal t)=0
virtual void useBackgroundColor(void) override
virtual void forceRecook(bool evensmartcache=true)
virtual fpreal SYMMETRYDIRX(fpreal t) override
virtual void CDNAME(UT_String &str, fpreal t) override
virtual fpreal SYMMETRYUVORIGU(fpreal t) override
fpreal evalFloat(int pi, int vi, fpreal t) const
virtual fpreal RAYHITPRESSURE(fpreal t) override
virtual fpreal SOFTEDGE(fpreal t) override
virtual fpreal SPLATTER(fpreal t) override
virtual fpreal RAYHITX(fpreal t) override
virtual const char * inputLabel(unsigned idx) const override
virtual int REALTIME(void) override
virtual fpreal SYMMETRYUVANGLE(fpreal t) override
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:498
virtual fpreal SYMMETRYUVORIGV(fpreal t) override
virtual fpreal RAYORIENTZ(fpreal t) override
virtual SOP_BrushOp OP(void) override
virtual fpreal USERX(fpreal) override
virtual fpreal RAYHITZ(fpreal t) override
virtual int UPTYPE(fpreal t) override
virtual int AXIS(void) override
virtual bool USE_FOREGROUND(void) override
virtual fpreal RAWUVRADIUS(fpreal t) override
virtual fpreal USERY(fpreal) override
struct _cl_event * event
Definition: glcorearb.h:2960
virtual int WRITEALPHA() override
virtual void setBrushOp(SOP_BrushOp op) override
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:502
virtual int altersColor() const override
virtual bool hasNibFileChanged(fpreal t)=0
virtual int USECONNECTIVITY() override
virtual fpreal FGR(fpreal t) override
virtual int PROJECTIONTYPE(void) override
virtual void useForegroundColor(void) override
virtual int PTHIT(fpreal t) override
virtual fpreal FGG(fpreal t) override
virtual void setCurrentColor(const UT_Vector3 &cd) override
virtual fpreal BGB(fpreal t) override
This class provides a way to manage a reference to an attribute permitting Read-Only access...
virtual fpreal VISHIGH(fpreal t) override
void evalString(UT_String &val, int pi, int vi, fpreal t) const
virtual int MERGEMODE() override
virtual fpreal USERZ(fpreal) override
virtual void setAccumulateStencil(bool yesno) override
virtual fpreal SYMMETRYORIGX(fpreal t) override
virtual fpreal VISLOW(fpreal t) override
virtual void setHitPressure(fpreal p, fpreal t) override
SOP_BrushOp
Definition: SOP_BrushBase.h:38
virtual void doErase()=0
virtual fpreal HEIGHT(fpreal t) override
virtual fpreal RAWRADIUS(fpreal t) override
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual fpreal SYMMETRYDIRZ(fpreal t) override
GA_API const UT_StringHolder orient
virtual int USEDEPTH() override
virtual int ACCUMSTENCIL(void) override
virtual void setBrushShape(SOP_BrushShape shape) override
#define SOP_GDT_GRP_IDX
Definition: SOP_GDT.h:22
virtual bool hasVisrangeChanged(fpreal)
virtual fpreal UPZ(fpreal t) override
virtual fpreal DEPTH(fpreal t) override
SYS_FORCE_INLINE T & y(void)
Definition: UT_Vector3.h:500
double fpreal
Definition: SYS_Types.h:270
virtual void setBrushEvent(SOP_BrushEvent event) override
virtual fpreal UPX(fpreal t) override
virtual int DOSTAMPING() override
virtual int EVENT() override
virtual bool hasStrokeChanged(fpreal t)=0
virtual fpreal ANGLE(fpreal t) override
virtual fpreal OPACITYPRESSURE(fpreal t) override
virtual fpreal RAYHITU(fpreal t) override
virtual int OVERRIDECD() override
void setFloat(int parmi, int vectori, fpreal t, fpreal value, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING)
void setInt(int parmi, int vectori, fpreal t, exint value)
virtual fpreal RAYHITW(fpreal t) override
#define GEO_STD_ATTRIB_INFLATE_MODIFIER
Definition: GEO_Detail.h:131
virtual fpreal RAWOPACITY(fpreal t) override
virtual void KERNEL(UT_String &str, fpreal t) override
virtual fpreal SYMMETRYDIST(fpreal t) override
virtual fpreal UPY(fpreal t) override
#define SOP_API
Definition: SOP_API.h:10
virtual void setProjectionType(int projtype) override
#define GEO_STD_ATTRIB_META_SLIDE
Definition: GEO_Detail.h:130
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
virtual bool hasNibLookChanged(fpreal t)=0
virtual void duplicateChangedSourceWrapper(unsigned idx, OP_Context &context, int *changed, bool force=false)
exint evalInt(int pi, int vi, fpreal t) const
SOP_BrushEvent
Definition: SOP_BrushBase.h:30
GLboolean r
Definition: glcorearb.h:1221
virtual int altersGeometry() const override
virtual fpreal RADIUSPRESSURE(fpreal t) override
virtual fpreal RAYHITY(fpreal t) override
SOP_BrushShape
Definition: SOP_BrushBase.h:62
virtual fpreal SYMMETRYDIRY(fpreal t) override
virtual void setRadius(fpreal r, fpreal t) override
virtual int DOUVREFLECTION() override
virtual void setHitPoint(int pt, fpreal t) override
virtual int SHAPE(fpreal t) override
virtual void setUVRadius(fpreal r, fpreal t) override
virtual fpreal FGB(fpreal t) override
virtual void setHitUVW(fpreal u, fpreal v, fpreal w, fpreal t) override
virtual fpreal SYMMETRYORIGZ(fpreal t) override
virtual fpreal RAYHITV(fpreal t) override
virtual void SCRIPT(UT_String &, fpreal) override
virtual int BITMAPCHAN(fpreal t) override
virtual fpreal BGG(fpreal t) override
virtual int OVERRIDEALPHA() override
virtual int USENORMALS() override
virtual int VISUALIZE() override
virtual void setRayOrigin(const UT_Vector3 &orig, fpreal t) override
virtual int OVERRIDENML() override
virtual fpreal RAYORIENTX(fpreal t) override