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