HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_UVTransform.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 UV Transform SOP
9  *
10  * Note: This is the first example of a SOP which uses
11  * the GDT functionality as a means towards optimal
12  * interactive performance. Notice how it does not
13  * use the "beginNewOperation" functionality
14  * of SOP_GDT. However, SOP_GDT provides facilities
15  * for restoring the input geometry extremely quickly.
16  *
17  * IMPORTANT: Any changes made to this SOP will probably
18  * need to be made to SOP_UVEdit, and vice versa!!!
19  *
20  */
21 
22 #ifndef __SOP_UVTransform_h__
23 #define __SOP_UVTransform_h__
24 
25 #include "SOP_API.h"
26 #include "SOP_GDT.h"
28 
29 class PRM_MenuEntry;
30 
31 enum {
32  // Group parameters
35 
37 
38  // Transform parameters
46 
47  // Soft Parameters
49 
50 #define SOP_UVTRANSFORM_NUM_SOFT_PARMS (8)
59 };
60 
62 {
63 public:
64  SOP_UVTransform(OP_Network *net, const char *name,
65  OP_Operator *entry);
66  ~SOP_UVTransform() override;
67 
68  bool updateParmsFlags() override;
69 
70  static OP_Node *myConstructor(OP_Network *net,
71  const char *name,
72  OP_Operator *entry);
73 
74  static PRM_Template myTemplateList[];
75  static PRM_Template myObsoleteList[];
76  static CH_LocalVariable myVariables[];
77 
78  bool evalVariableValue(
79  fpreal &v,
80  int index,
81  int thread) override;
82  // create overload that delegates to super class to avoid shadow warnings
84  UT_String &v,
85  int i,
86  int thread) override
87  {
89  v, i, thread);
90  }
91 
93  int alone = 0) override;
94 
96  PRM_ParmList *obsolete_parms) override;
97 
98  void setVisualization(bool val) override;
99 
100  // An enum by which functions can report actions taken regarding a
101  // particular attribute.
103  {
104  NO_CHANGE, CHANGED_EXISTING, REPLACED_EXISTING, ADDED_MISSING
105  };
106 
107  void getDescriptiveParmName(UT_String &name) const override
108  {
109  name = "uvattrib";
110  }
111 
112 protected:
113  OP_ERROR cookMySop(OP_Context &context) override;
114  const char *inputLabel(unsigned idx) const override;
115 
116  bool getGroupCentroid(
117  OP_Context &context,
118  UT_Vector3 &centroid) override;
119 
120  void getXformOrder(
121  UT_XformOrder &xord,
122  const CH_Channel *chp) const override;
123 
124 
125 #ifdef INTEL_COMPILER
126 private:
127  SOP_UVTransform(const SOP_UVTransform& ) : SOP_GDT(NULL, NULL, NULL) { }
128 #endif
129 private:
130  // Selection
131  int GRPTYPE() const
132  { return evalInt(SOP_UVTRANSFORM_GRPTYPE_IDX, 0, 0); }
133 
134  // Transform
135  int TRS() const
136  { return evalInt(SOP_UVTRANSFORM_TRS_IDX, 0, 0); }
137  int XYZ() const
138  { return evalInt(SOP_UVTRANSFORM_XYZ_IDX, 0, 0); }
139  fpreal TX(fpreal t) const
140  { return evalFloat(SOP_UVTRANSFORM_T_IDX, 0, t); }
141  fpreal TY(fpreal t) const
142  { return evalFloat(SOP_UVTRANSFORM_T_IDX, 1, t); }
143  fpreal TZ(fpreal t) const
144  { return evalFloat(SOP_UVTRANSFORM_T_IDX, 2, t); }
145  fpreal RX(fpreal t) const
146  { return evalFloat(SOP_UVTRANSFORM_R_IDX, 0, t); }
147  fpreal RY(fpreal t) const
148  { return evalFloat(SOP_UVTRANSFORM_R_IDX, 1, t); }
149  fpreal RZ(fpreal t) const
150  { return evalFloat(SOP_UVTRANSFORM_R_IDX, 2, t); }
151  fpreal SX(fpreal t) const
152  { return evalFloat(SOP_UVTRANSFORM_S_IDX, 0, t); }
153  fpreal SY(fpreal t) const
154  { return evalFloat(SOP_UVTRANSFORM_S_IDX, 1, t); }
155  fpreal SZ(fpreal t) const
156  { return evalFloat(SOP_UVTRANSFORM_S_IDX, 2, t); }
157  fpreal SHEAR_XY(fpreal t) const
158  { return evalFloat(SOP_UVTRANSFORM_SHEAR_IDX, 0, t); }
159  fpreal SHEAR_XZ(fpreal t) const
160  { return evalFloat(SOP_UVTRANSFORM_SHEAR_IDX, 1, t); }
161  fpreal SHEAR_YZ(fpreal t) const
162  { return evalFloat(SOP_UVTRANSFORM_SHEAR_IDX, 2, t); }
163  fpreal PX(fpreal t) const
164  { return evalFloat(SOP_UVTRANSFORM_P_IDX, 0, t); }
165  fpreal PY(fpreal t) const
166  { return evalFloat(SOP_UVTRANSFORM_P_IDX, 1, t); }
167  fpreal PZ(fpreal t) const
168  { return evalFloat(SOP_UVTRANSFORM_P_IDX, 2, t); }
169 
170  // Soft
171  fpreal RADIUS(fpreal t) const
172  { return evalFloat(SOP_UVTRANSFORM_RADIUS_IDX, 0, t); }
173  int SOFTTYPE() const
174  { return evalInt(SOP_UVTRANSFORM_SOFTTYPE_IDX, 0, 0); }
175  fpreal TANDEG0(fpreal t) const
176  { return evalFloat(SOP_UVTRANSFORM_TANGENT_IDX,0, t); }
177  fpreal TANDEG1(fpreal t) const
178  { return evalFloat(SOP_UVTRANSFORM_TANGENT_IDX,1, t); }
179  void KERNEL(UT_String &str, fpreal t) const
180  { evalString(str, SOP_UVTRANSFORM_KERNEL_IDX, 0, t); }
181  int METRIC() const
182  { return evalInt(SOP_UVTRANSFORM_METRIC_IDX, 0, 0); }
183  int GLOBAL() const
184  { return evalInt(SOP_UVTRANSFORM_GLOBAL_IDX, 0, 0); }
185  int UVGLOBAL() const
186  { return evalInt(SOP_UVTRANSFORM_UVGLOBAL_IDX,0,0); }
187  int VISUALIZE_FALLOFF(fpreal t) const
188  { return evalInt(SOP_UVTRANSFORM_VISFALLOFF_IDX, 0, t); }
189  bool falloffAttributeRequested(fpreal t) const;
190 
191  // Group Calculations
192  void computeTransformGroups(GA_AttributeOwner owner, bool changed_input);
193  void computeSelectionCentroid(GA_AttributeOwner owner);
194 
195  // Full Bounding Box Calculation
196  void computeBBox(GA_AttributeOwner owner);
197 
198  // UV Transform
199  void doTransform(GA_AttributeOwner owner, const GA_RWHandleV3 &uvattrib, fpreal t, AttribAction &falloff_action);
200 
201  GA_AttributeOwner myOwner;
202  bool myCentroidComputed;
203  UT_Vector3 myInitialCentroid;
204  bool myBBoxComputed;
205  UT_BoundingBox myBBox;
206 
207  GA_VertexGroup *myVtxGroup;
208  GA_PointGroup *myPtGroup;
209 
210  GEO_SoftTransformCache mySoftCache;
211  bool mySoftCacheDirty;
212 
213  bool myVisualizationFlag;
214  bool mySetFalloffOnLastCook;
215  bool myOverwroteInputFalloff;
216 };
217 
218 #endif
virtual void setVisualization(bool)
Definition: SOP_Node.h:863
virtual bool updateParmsFlags()
bool evalVariableValue(fpreal &val, int index, int thread) override
const GLdouble * v
Definition: glcorearb.h:837
Transformation order of scales, rotates, and translates.
Definition: UT_XformOrder.h:23
const char * inputLabel(unsigned idx) const override
virtual void getXformOrder(UT_XformOrder &xord, const CH_Channel *chp) const
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
void getDescriptiveParmName(UT_String &name) const override
void evalString(UT_String &val, int pi, int vi, fpreal t) const
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual bool getGroupCentroid(OP_Context &, UT_Vector3 &)
Definition: SOP_Node.h:1595
virtual OP_ERROR cookInputGroups(OP_Context &context, int alone=0)
GLdouble t
Definition: glad.h:2397
#define SOP_GDT_GRP_IDX
Definition: SOP_GDT.h:22
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
GA_AttributeOwner
Definition: GA_Types.h:35
virtual void resolveObsoleteParms(PRM_ParmList *)
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:786
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define SOP_API
Definition: SOP_API.h:10
bool evalVariableValue(UT_String &v, int i, int thread) override
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0