CC-Fractal-Suite
COP2_FractalMatte.h
Go to the documentation of this file.
1 
5 #pragma once
6 
7  // HDK
8 #include <COP2/COP2_PixelOp.h>
9 #include <RU/RU_PixelFunctions.h>
10 
11 namespace CC
12 {
13 
20 class COP2_FractalMatte : public COP2_PixelOp
21 {
22 public:
23 
24  static OP_TemplatePair myTemplatePair;
25  static OP_VariablePair myVariablePair;
26  static PRM_Template myTemplateList[];
27  static CH_LocalVariable myVariableList[];
28 
30  static const char* myInputLabels[];
31 
33  friend class OP;
34 
35 protected:
37  virtual RU_PixelFunction* addPixelFunction(
38  const TIL_Plane*,
39  int,
40  fpreal32 t,
41  int,
42  int,
43  int thread);
44 
46  virtual bool updateParmsFlags() override;
47 
48 private:
49 
52  OP_Network* parent,
53  const char* name,
54  OP_Operator* entry);
55 
56  virtual ~COP2_FractalMatte();
57 
58 };
59 
66 class cop2_FractalMatteFunc : public RU_PixelFunction
67 {
68 public:
69 
72  enum class ModeType
73  {
74  MODULUS,
75  COMPARISON,
76  BLENDCOLOR
77  };
78 
82  enum class ComparisonType
83  {
84  LESS_THAN,
85  LESS_THAN_EQUALS,
86  EQUALS,
87  GREATER_THAN_EQUALS,
88  GREATER_THAN,
89  NOT_EQUALS
90  };
91 
94  enum class BlendType
95  {
96  LINEAR,
97  QUADRATIC,
98  CONSTANT
99  };
100 
103  fpreal modulo, fpreal offset, bool invert = false);
104 
107  fpreal compValue, ComparisonType compType, bool invert = false);
108 
111  std::vector<fpreal>sizes,
112  std::vector<UT_Color>colors,
113  BlendType blendType,
114  fpreal32 offset,
115  fpreal32 blendOffset,
116  fpreal32 weightMult = 1.0f, // Zero values here are really bad
117  bool invert = false);
118 protected:
121  virtual bool eachComponentDifferent() const
122  {
123  if (mode == ModeType::BLENDCOLOR)
124  return true;
125  // Unless a BLENDCOLOR, all components can be the same.
126  return false;
127  }
128 
130  virtual bool needAllComponents() const
131  {
132  return false;
133  }
134 
136  static fpreal32 checkModulus(
137  RU_PixelFunction* pf,
139  fpreal32 pixelValue,
141  int comp);
142 
144  static fpreal32 checkComparison(
145  RU_PixelFunction* pf,
146  fpreal32 pixelValue,
147  int comp);
148 
150  static fpreal32 checkBlendColors(
151  RU_PixelFunction* pf,
152  fpreal32 pixelValue,
153  int comp);
154 
158  virtual RUPixelFunc getPixelFunction() const
159  {
160  switch (mode)
161  {
162  case ModeType::MODULUS:
163  return checkModulus;
164  case ModeType::COMPARISON:
165  return checkComparison;
166  case ModeType::BLENDCOLOR:
167  return checkBlendColors;
168  default:
169  return checkModulus;
170  }
171  }
172 
173 private:
174  fpreal32 modulo{ 0.0f };
175  fpreal32 offset{ 0.0f };
176  bool invert{ false };
177  fpreal32 compValue{ 0.0 };
178  std::vector<fpreal> sizes;
179  std::vector<UT_Color> colors;
180  BlendType blendType;
181  ComparisonType compType{ ComparisonType::LESS_THAN };
182  ModeType mode{ ModeType::MODULUS };
183  fpreal32 colorOffset{ 0.0f };
184  fpreal32 blendOffset{ 1.0f };
185 };
186 }
ComparisonType
When in the comparison mode, specifies the different kinds of comparisons we are allowed to make...
Definition: COP2_FractalMatte.h:82
OP is meant to remove the need to write public &#39;myConstructor&#39; methods in every class like the exampl...
Definition: FractalNode.h:359
virtual bool needAllComponents() const
Tells Houdini if all components must be cooked or not.
Definition: COP2_FractalMatte.h:130
Fractal Matte Operator class.
Definition: COP2_FractalMatte.h:20
static const char * myInputLabels[]
Label the names of the inputs in the Houdini UI.
Definition: COP2_FractalMatte.h:30
ModeType
Enumerates the different type of fundamental operators we can perform on the upstream fractals...
Definition: COP2_FractalMatte.h:72
virtual RUPixelFunc getPixelFunction() const
This is how we signal to RU_PixelFunction what method must be called per-pixel.
Definition: COP2_FractalMatte.h:158
virtual RU_PixelFunction * addPixelFunction(const TIL_Plane *, int, fpreal32 t, int, int, int thread)
We must override this method, which returns a pixel function.
Definition: COP2_FractalMatte.cpp:175
Definition: COP2_Buddhabrot.h:17
virtual bool eachComponentDifferent() const
Tells Houdini whether &#39;component&#39;, here meaning image plane, should be different or not...
Definition: COP2_FractalMatte.h:121
Pixel Function used to interpret the upstream fractals.
Definition: COP2_FractalMatte.h:66
BlendType
When in the blendcolor mode, specifies the strategy used to blend the colors between different value ...
Definition: COP2_FractalMatte.h:94
virtual bool updateParmsFlags() override
Use to hide/unhide parameters.
Definition: COP2_FractalMatte.cpp:250