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  ~SOP_SlideModifierPaint() override;
93 
94  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  void setAccumulateStencil(bool yesno) override
104  {
106  }
107  void setRayOrigin(const UT_Vector3 &orig, fpreal t) override
108  {
112  }
113  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  void setHitPrimitive(int primidx, fpreal t) override
120  {
121  setInt(SOP_SLIDEPAINT_RAY_HITPRIM_IDX, 0, t, primidx);
122  }
123  void setHitPoint(int pt, fpreal t) override
124  {
126  }
127  void setHitUVW(fpreal u, fpreal v, fpreal w, fpreal t) override
128  {
132  }
133  void setHitPressure(fpreal p, fpreal t) override
134  {
136  }
137  void setRadius(fpreal r, fpreal t) override
138  {
140  }
141  void setUVRadius(fpreal r, fpreal t) override
142  {
144  }
146  {
147  setInt(SOP_SLIDEPAINT_RAY_EVENT_IDX, 0, 0, int(event));
148  }
149  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  void setBrushShape(SOP_BrushShape shape) override
162  {
163  setInt(SOP_SLIDEPAINT_SHAPE_IDX, 0, 0, int(shape));
164  }
165  void setProjectionType(int projtype) override
166  {
167  setInt(SOP_SLIDEPAINT_PROJTYPE_IDX, 0, 0, projtype);
168  }
169  void useForegroundColor() override
170  { myUseFG = true; }
171  void useBackgroundColor() override
172  { myUseFG = false; }
173 
174  void setCurrentColor(const UT_Vector3 &cd) override
175  { }
176  void setVisualization(bool 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  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
193  unsigned idx,
195  int *changed,
196  bool force=false) override;
197 
198 protected:
199  void doErase() override;
200 
201 public:
202  int altersGeometry() const override { return 0; }
203  int altersColor() const override { return 1; }
205  { return evalFloat(SOP_SLIDEPAINT_RAD_IDX, 0, t); }
207  { return evalFloat(SOP_SLIDEPAINT_UVRAD_IDX, 0, t); }
209  { return evalFloat(SOP_SLIDEPAINT_RADPRESSURE_IDX, 0, t); }
211  {return evalFloat(SOP_SLIDEPAINT_OPAC_IDX, 0, t) ; }
213  {return evalFloat(SOP_SLIDEPAINT_OPACPRESSURE_IDX, 0, t) ; }
214 
215  SOP_BrushOp OP() 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  int ACCUMSTENCIL() override
230  { return evalInt(SOP_SLIDEPAINT_STENCILACCUM_IDX, 0, 0);}
231  int PROJECTIONTYPE() override
232  { return evalInt(SOP_SLIDEPAINT_PROJTYPE_IDX, 0, 0); }
233  int REALTIME() override
234  { return evalInt(SOP_SLIDEPAINT_REALTIME_IDX, 0, 0); }
235  int SHAPE(fpreal t) override
236  { return evalInt(SOP_SLIDEPAINT_SHAPE_IDX, 0, t); }
237 
238 protected:
241  SOP_INFLATE_MODIFIER
242  };
243 
244  int MERGEMODE() override
245  { return evalInt(SOP_SLIDEPAINT_MERGEMODE_IDX, 0, 0); }
246  void SCRIPT(UT_String &, fpreal) override {}
247  int AXIS() override { return 0 ; }
248  fpreal USERX(fpreal) override { return 0.0; }
249  fpreal USERY(fpreal) override { return 0.0; }
250  fpreal USERZ(fpreal) override { return 0.0; }
251 
258  fpreal RAYHITX(fpreal t) override
260  fpreal RAYHITY(fpreal t) override
262  fpreal RAYHITZ(fpreal t) override
264  fpreal RAYHITU(fpreal t) override
265  { return evalFloat(SOP_SLIDEPAINT_RAY_HITUVW_IDX, 0,t); }
266  fpreal RAYHITV(fpreal t) override
267  { return evalFloat(SOP_SLIDEPAINT_RAY_HITUVW_IDX, 1,t); }
268  fpreal RAYHITW(fpreal t) override
269  { return evalFloat(SOP_SLIDEPAINT_RAY_HITUVW_IDX, 2,t); }
272  int PRIMHIT(fpreal t) override
273  { return evalInt(SOP_SLIDEPAINT_RAY_HITPRIM_IDX, 0,t); }
274  int PTHIT(fpreal t) override
275  { return evalInt(SOP_SLIDEPAINT_RAY_HITPT_IDX, 0, t); }
276  int EVENT() override
277  { return evalInt(SOP_SLIDEPAINT_RAY_EVENT_IDX, 0,0); }
278  bool USE_FOREGROUND() override
279  { return myUseFG; }
280 
281  fpreal FGR(fpreal t) override { return 1.0; }
282  fpreal FGG(fpreal t) override { return 1.0; }
283  fpreal FGB(fpreal t) override { return 1.0; }
284  fpreal BGR(fpreal t) override { return 0.0; }
285  fpreal BGG(fpreal t) override { return 0.0; }
286  fpreal BGB(fpreal t) override { return 0.0; }
287 
289  { return evalFloat(SOP_SLIDEPAINT_SOFTEDGE_IDX, 0, t); }
290  void KERNEL(UT_String &str, fpreal t) override
291  { evalString(str, SOP_SLIDEPAINT_KERNEL_IDX, 0, t); }
292  int UPTYPE(fpreal t) override
293  { return evalInt(SOP_SLIDEPAINT_UPTYPE_IDX, 0, t); }
294  fpreal UPX(fpreal t) override
295  { return evalFloat(SOP_SLIDEPAINT_UPVECTOR_IDX, 0, t); }
296  fpreal UPY(fpreal t) override
297  { return evalFloat(SOP_SLIDEPAINT_UPVECTOR_IDX, 1, t); }
298  fpreal UPZ(fpreal t) override
299  { return evalFloat(SOP_SLIDEPAINT_UPVECTOR_IDX, 2, t); }
300 
302  { return evalFloat(SOP_SLIDEPAINT_PAPER_IDX, 0, t); }
304  { return evalFloat(SOP_SLIDEPAINT_SPLATTER_IDX, 0, t); }
305  void BITMAP(UT_String &str, fpreal t) override
306  { evalString(str, SOP_SLIDEPAINT_BITMAP_IDX, 0, t); }
307  int BITMAPCHAN(fpreal t) override
308  { return evalInt(SOP_SLIDEPAINT_BITMAPCHAN_IDX, 0, t); }
309  fpreal ANGLE(fpreal t) override
310  { return evalFloat(SOP_SLIDEPAINT_ANGLE_IDX, 0, t); }
311  fpreal SQUASH(fpreal t) override
312  { return evalFloat(SOP_SLIDEPAINT_SQUASH_IDX, 0, t); }
313  int DOSTAMPING() override
314  { return 0; }
315  int WRITEALPHA() override
316  { return 0; }
317 
318  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  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  int OVERRIDEALPHA() override
354  { return 0; }
355  void ALPHANAME(UT_String & /*str*/, fpreal /*t*/) override
356  {}
357  int OVERRIDENML() override { return 0; }
358  void NMLNAME(UT_String & /*str*/, fpreal /*t*/) override {}
359 
361  { return evalFloat(SOP_SLIDEPAINT_SYMAXIS_IDX, 0, t); }
363  { return evalFloat(SOP_SLIDEPAINT_SYMAXIS_IDX, 1, t); }
365  { return evalFloat(SOP_SLIDEPAINT_SYMAXIS_IDX, 2, t); }
367  { return evalFloat(SOP_SLIDEPAINT_SYMORIG_IDX, 0, t); }
369  { return evalFloat(SOP_SLIDEPAINT_SYMORIG_IDX, 1, t); }
371  { return evalFloat(SOP_SLIDEPAINT_SYMORIG_IDX, 2, t); }
372  int DOREFLECTION() override
373  { return evalInt(SOP_SLIDEPAINT_DOREFLECT_IDX,0, 0); }
374  int DOROTATION() override
375  { return evalInt(SOP_SLIDEPAINT_DOROTATION_IDX,0, 0); }
376  int SYMMETRYROT(fpreal t) override
377  { return evalInt(SOP_SLIDEPAINT_SYMROT_IDX,0, t); }
379  { return evalFloat(SOP_SLIDEPAINT_SYMDIST_IDX,0, t); }
380 
381  int DOUVREFLECTION() override
382  { return evalInt(SOP_SLIDEPAINT_DOUVREFLECT_IDX, 0, 0); }
384  { return evalFloat(SOP_SLIDEPAINT_SYMUVORIG_IDX, 0, t); }
386  { return evalFloat(SOP_SLIDEPAINT_SYMUVORIG_IDX, 1, t); }
388  { return evalFloat(SOP_SLIDEPAINT_SYMUVANGLE_IDX, 0, t);}
389 
390  int ADDATTRIB() override
391  { return 0; }
392  int VISUALIZE() override
393  { return myForceVisualize ||
395  fpreal VISLOW(fpreal t) override
396  { return evalFloat(SOP_SLIDEPAINT_VISRANGE_IDX, 0, t); }
397  fpreal VISHIGH(fpreal t) override
398  { return evalFloat(SOP_SLIDEPAINT_VISRANGE_IDX, 1, t); }
399  int VISMODE() override
400  { return evalInt(SOP_SLIDEPAINT_VISMODE_IDX, 0, 0); }
401 
402  int USECONNECTIVITY() override
404  int USENORMALS() override
405  { return evalInt(SOP_SLIDEPAINT_USENORMALS_IDX, 0, 0); }
406  int USEDEPTH() override
407  { return evalInt(SOP_SLIDEPAINT_USEDEPTH_IDX, 0, 0); }
408  fpreal DEPTH(fpreal t) override
409  { return evalFloat(SOP_SLIDEPAINT_DEPTH_IDX, 0, t); }
410  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  bool hasStrokeChanged(fpreal t) override;
417  bool hasStyleChanged(fpreal t) override;
418 
419  // Find if the nib file has changed:
420  bool hasNibFileChanged(fpreal t) override;
421  bool hasAccumStencilChanged(fpreal t) override;
422  bool hasNibLookChanged(fpreal t) override;
423 
424  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
fpreal SYMMETRYDIST(fpreal t) override
fpreal VISLOW(fpreal t) override
fpreal SYMMETRYDIRX(fpreal t) override
virtual bool updateParmsFlags()
void BITMAP(UT_String &str, fpreal t) override
fpreal RAYHITY(fpreal t) override
fpreal PAPERNOISE(fpreal t) override
virtual bool hasAccumStencilChanged(fpreal t)=0
GLuint const GLchar * name
Definition: glew.h:1814
fpreal RAYHITPRESSURE(fpreal t) override
void setHitPoint(int pt, fpreal t) override
fpreal SYMMETRYDIRY(fpreal t) override
void ALPHANAME(UT_String &, fpreal) override
void setHitPressure(fpreal p, fpreal t) override
fpreal USERX(fpreal) override
int BITMAPCHAN(fpreal t) override
fpreal SYMMETRYUVORIGV(fpreal t) override
const char * inputLabel(unsigned idx) const override
fpreal RAWUVRADIUS(fpreal t) override
void setUVRadius(fpreal r, fpreal t) override
virtual bool hasStyleChanged(fpreal t)=0
void SCRIPT(UT_String &, fpreal) override
virtual void forceRecook(bool evensmartcache=true)
fpreal evalFloat(int pi, int vi, fpreal t) const
fpreal DEPTH(fpreal t) override
fpreal FGG(fpreal t) override
int altersColor() const override
int UPTYPE(fpreal t) override
const GLdouble * v
Definition: glew.h:1391
fpreal RAYHITV(fpreal t) override
void setHitUVW(fpreal u, fpreal v, fpreal w, fpreal t) override
fpreal VISHIGH(fpreal t) override
void setBrushEvent(SOP_BrushEvent event) override
void setHitPrimitive(int primidx, fpreal t) override
fpreal USERY(fpreal) override
fpreal BGB(fpreal t) override
fpreal RAYORIENTY(fpreal t) override
fpreal RAYORIENTZ(fpreal t) override
fpreal UPZ(fpreal t) override
fpreal RAYHITZ(fpreal t) override
virtual bool hasNibFileChanged(fpreal t)=0
fpreal SPLATTER(fpreal t) override
void setRayOrientation(const UT_Vector3 &orient, fpreal t) override
SYS_FORCE_INLINE T & y()
Definition: UT_Vector3.h:513
int PTHIT(fpreal t) override
fpreal USERZ(fpreal) override
This class provides a way to manage a reference to an attribute permitting Read-Only access...
void evalString(UT_String &val, int pi, int vi, fpreal t) const
fpreal ANGLE(fpreal t) override
SYS_FORCE_INLINE T & z()
Definition: UT_Vector3.h:515
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
void setCurrentColor(const UT_Vector3 &cd) override
void setBrushOp(SOP_BrushOp op) override
fpreal FGR(fpreal t) override
SOP_BrushOp
Definition: SOP_BrushBase.h:38
virtual void doErase()=0
int SYMMETRYROT(fpreal t) override
fpreal UPX(fpreal t) override
void NMLNAME(UT_String &, fpreal) override
GA_API const UT_StringHolder orient
#define SOP_GDT_GRP_IDX
Definition: SOP_GDT.h:22
fpreal RAYHITX(fpreal t) override
fpreal FGB(fpreal t) override
fpreal SYMMETRYUVANGLE(fpreal t) override
void setAccumulateStencil(bool yesno) override
fpreal BGG(fpreal t) override
virtual bool hasVisrangeChanged(fpreal)
GLfloat GLfloat p
Definition: glew.h:16321
fpreal OPACITYPRESSURE(fpreal t) override
fpreal RAWOPACITY(fpreal t) override
fpreal UPY(fpreal t) override
cl_event event
Definition: glew.h:3695
fpreal SQUASH(fpreal t) override
void KERNEL(UT_String &str, fpreal t) override
virtual bool hasStrokeChanged(fpreal t)=0
fpreal RAYHITW(fpreal t) override
void setFloat(int parmi, int vectori, fpreal t, fpreal value, PRM_AddKeyType add_key=PRM_AK_MARK_PENDING)
fpreal RADIUSPRESSURE(fpreal t) override
fpreal64 fpreal
Definition: SYS_Types.h:277
void setInt(int parmi, int vectori, fpreal t, exint value)
#define GEO_STD_ATTRIB_INFLATE_MODIFIER
Definition: GEO_Detail.h:131
void setVisualization(bool state) override
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
#define SOP_API
Definition: SOP_API.h:10
fpreal BGR(fpreal t) override
fpreal SYMMETRYORIGY(fpreal t) override
SYS_FORCE_INLINE T & x()
Definition: UT_Vector3.h:511
void setRayOrigin(const UT_Vector3 &orig, fpreal t) override
SOP_BrushOp OP() override
#define GEO_STD_ATTRIB_META_SLIDE
Definition: GEO_Detail.h:130
virtual bool hasNibLookChanged(fpreal t)=0
fpreal SYMMETRYUVORIGU(fpreal t) override
fpreal HEIGHT(fpreal t) override
virtual void duplicateChangedSourceWrapper(unsigned idx, OP_Context &context, int *changed, bool force=false)
fpreal SYMMETRYDIRZ(fpreal t) override
fpreal SYMMETRYORIGX(fpreal t) override
exint evalInt(int pi, int vi, fpreal t) const
void setRadius(fpreal r, fpreal t) override
SOP_BrushEvent
Definition: SOP_BrushBase.h:30
fpreal RAYORIENTX(fpreal t) override
int PRIMHIT(fpreal t) override
SOP_BrushShape
Definition: SOP_BrushBase.h:62
fpreal RAYHITU(fpreal t) override
fpreal RAWRADIUS(fpreal t) override
GLdouble GLdouble t
Definition: glew.h:1398
int altersGeometry() const override
void setBrushShape(SOP_BrushShape shape) override
fpreal SYMMETRYORIGZ(fpreal t) override
void setProjectionType(int projtype) override
void CDNAME(UT_String &str, fpreal t) override
fpreal SOFTEDGE(fpreal t) override
int SHAPE(fpreal t) override