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  virtual ~SOP_UVTransform();
67 
68  virtual bool updateParmsFlags();
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  virtual bool evalVariableValue(fpreal &v, int index, int thread);
79  // create overload that delegates to super class to avoid shadow warnings
80  virtual bool evalVariableValue(UT_String &v, int i, int thread)
81  { return SOP_Node::evalVariableValue(v, i, thread); }
82 
83  virtual OP_ERROR cookInputGroups(OP_Context &context,
84  int alone = 0);
85 
86  virtual void resolveObsoleteParms(
87  PRM_ParmList *obsolete_parms);
88 
89  virtual void setVisualization(int val);
90 
91  // An enum by which functions can report actions taken regarding a
92  // particular attribute.
94  {
95  NO_CHANGE, CHANGED_EXISTING, REPLACED_EXISTING, ADDED_MISSING
96  };
97 
98  virtual void getDescriptiveParmName(UT_String &name) const
99  {
100  name = "uvattrib";
101  }
102 
103 protected:
104  virtual OP_ERROR cookMySop(OP_Context &context);
105  virtual const char *inputLabel(unsigned idx) const;
106 
107  virtual bool getGroupCentroid(OP_Context &context,
108  UT_Vector3 &centroid);
109 
110  virtual void getXformOrder(UT_XformOrder &xord,
111  const CH_Channel *chp) const;
112 
113 
114 #ifdef INTEL_COMPILER
115 private:
116  SOP_UVTransform(const SOP_UVTransform& ) : SOP_GDT(NULL, NULL, NULL) { }
117 #endif
118 private:
119  // Selection
120  int GRPTYPE() const
121  { return evalInt(SOP_UVTRANSFORM_GRPTYPE_IDX, 0, 0); }
122 
123  // Transform
124  int TRS() const
125  { return evalInt(SOP_UVTRANSFORM_TRS_IDX, 0, 0); }
126  int XYZ() const
127  { return evalInt(SOP_UVTRANSFORM_XYZ_IDX, 0, 0); }
128  fpreal TX(fpreal t) const
129  { return evalFloat(SOP_UVTRANSFORM_T_IDX, 0, t); }
130  fpreal TY(fpreal t) const
131  { return evalFloat(SOP_UVTRANSFORM_T_IDX, 1, t); }
132  fpreal TZ(fpreal t) const
133  { return evalFloat(SOP_UVTRANSFORM_T_IDX, 2, t); }
134  fpreal RX(fpreal t) const
135  { return evalFloat(SOP_UVTRANSFORM_R_IDX, 0, t); }
136  fpreal RY(fpreal t) const
137  { return evalFloat(SOP_UVTRANSFORM_R_IDX, 1, t); }
138  fpreal RZ(fpreal t) const
139  { return evalFloat(SOP_UVTRANSFORM_R_IDX, 2, t); }
140  fpreal SX(fpreal t) const
141  { return evalFloat(SOP_UVTRANSFORM_S_IDX, 0, t); }
142  fpreal SY(fpreal t) const
143  { return evalFloat(SOP_UVTRANSFORM_S_IDX, 1, t); }
144  fpreal SZ(fpreal t) const
145  { return evalFloat(SOP_UVTRANSFORM_S_IDX, 2, t); }
146  fpreal SHEAR_XY(fpreal t) const
147  { return evalFloat(SOP_UVTRANSFORM_SHEAR_IDX, 0, t); }
148  fpreal SHEAR_XZ(fpreal t) const
149  { return evalFloat(SOP_UVTRANSFORM_SHEAR_IDX, 1, t); }
150  fpreal SHEAR_YZ(fpreal t) const
151  { return evalFloat(SOP_UVTRANSFORM_SHEAR_IDX, 2, t); }
152  fpreal PX(fpreal t) const
153  { return evalFloat(SOP_UVTRANSFORM_P_IDX, 0, t); }
154  fpreal PY(fpreal t) const
155  { return evalFloat(SOP_UVTRANSFORM_P_IDX, 1, t); }
156  fpreal PZ(fpreal t) const
157  { return evalFloat(SOP_UVTRANSFORM_P_IDX, 2, t); }
158 
159  // Soft
160  fpreal RADIUS(fpreal t) const
161  { return evalFloat(SOP_UVTRANSFORM_RADIUS_IDX, 0, t); }
162  int SOFTTYPE() const
163  { return evalInt(SOP_UVTRANSFORM_SOFTTYPE_IDX, 0, 0); }
164  fpreal TANDEG0(fpreal t) const
165  { return evalFloat(SOP_UVTRANSFORM_TANGENT_IDX,0, t); }
166  fpreal TANDEG1(fpreal t) const
167  { return evalFloat(SOP_UVTRANSFORM_TANGENT_IDX,1, t); }
168  void KERNEL(UT_String &str, fpreal t) const
169  { evalString(str, SOP_UVTRANSFORM_KERNEL_IDX, 0, t); }
170  int METRIC() const
171  { return evalInt(SOP_UVTRANSFORM_METRIC_IDX, 0, 0); }
172  int GLOBAL() const
173  { return evalInt(SOP_UVTRANSFORM_GLOBAL_IDX, 0, 0); }
174  int UVGLOBAL() const
175  { return evalInt(SOP_UVTRANSFORM_UVGLOBAL_IDX,0,0); }
176  int VISUALIZE_FALLOFF(fpreal t) const
177  { return evalInt(SOP_UVTRANSFORM_VISFALLOFF_IDX, 0, t); }
178  bool falloffAttributeRequested(fpreal t) const;
179 
180  // Group Calculations
181  void computeTransformGroups(GA_AttributeOwner owner, bool changed_input);
182  void computeSelectionCentroid(GA_AttributeOwner owner);
183 
184  // Full Bounding Box Calculation
185  void computeBBox(GA_AttributeOwner owner);
186 
187  // UV Transform
188  void doTransform(GA_AttributeOwner owner, const GA_RWHandleV3 &uvattrib, fpreal t, AttribAction &falloff_action);
189 
190  GA_AttributeOwner myOwner;
191  bool myCentroidComputed;
192  UT_Vector3 myInitialCentroid;
193  bool myBBoxComputed;
194  UT_BoundingBox myBBox;
195 
196  GA_VertexGroup *myVtxGroup;
197  GA_PointGroup *myPtGroup;
198 
199  GEO_SoftTransformCache mySoftCache;
200  bool mySoftCacheDirty;
201 
202  bool myVisualizationFlag;
203  bool mySetFalloffOnLastCook;
204  bool myOverwroteInputFalloff;
205 };
206 
207 #endif
virtual bool updateParmsFlags()
const GLdouble * v
Definition: glcorearb.h:836
virtual void getDescriptiveParmName(UT_String &name) const
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
virtual const char * inputLabel(unsigned idx) const override
3D Vector class.
virtual bool evalVariableValue(fpreal &val, int index, int thread) override
png_uint_32 i
Definition: png.h:2877
virtual bool evalVariableValue(UT_String &v, int i, int thread)
void evalString(UT_String &val, int pi, int vi, fpreal t) const
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual bool getGroupCentroid(OP_Context &, UT_Vector3 &)
Definition: SOP_Node.h:1568
virtual OP_ERROR cookInputGroups(OP_Context &context, int alone=0)
#define SOP_GDT_GRP_IDX
Definition: SOP_GDT.h:22
GA_AttributeOwner
Definition: GA_Types.h:33
double fpreal
Definition: SYS_Types.h:270
virtual void resolveObsoleteParms(PRM_ParmList *)
GLuint index
Definition: glcorearb.h:785
GLuint GLfloat * val
Definition: glcorearb.h:1607
#define SOP_API
Definition: SOP_API.h:10
virtual void setVisualization(int)
Definition: SOP_Node.h:832
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0