HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_StickyShared.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: OBJ_StickyShared.h (Custom Library, C++)
7  *
8  * COMMENTS: A common parent class for the sticky and sticky-blend objects.
9  *
10  */
11 
12 #ifndef __OBJ_StickyShared__
13 #define __OBJ_StickyShared__
14 
15 #include "OBJ_Null.h"
16 
17 #include "OBJ_API.h"
18 #include <UT/UT_Vector2.h>
19 #include <UT/UT_Vector3Array.h>
20 #include <GU/GU_DetailHandle.h>
21 #include <GA/GA_Types.h>
22 
24 {
34 
36 };
37 
38 class GU_UVCache;
39 class GEO_Vertex;
40 class GEO_Hull;
41 
43 {
44 public:
46  const char *name,
47  OP_Operator *op);
48  ~OBJ_StickyShared() override;
49 
50  OBJ_OBJECT_TYPE getObjectType() const override;
51 
52  static OP_Node *myConstructor(OP_Network *net,
53  const char *name,
54  OP_Operator *entry);
55 
56  static int clearUVCacheStatic(void *, int, fpreal,
57  const PRM_Template *);
58  void clearUVCache();
59 
60  // 2d transform code:
62  UT_DMatrix4 &mat,
63  OP_Context &context) override
64  { mat.identity(); return true; }
65 
66 
67  virtual void STICKYGEOPATH(UT_String &str, fpreal t) {}
69  {
70  evalString(str, "stickyattrib", 0, t);
71  }
72  virtual void STICKYUV(UT_Vector2R &uv, fpreal t) {}
73  virtual fpreal STICKYROT(fpreal t) { return 0; }
74  bool FETCHWORLD()
75  {
76  return evalInt("fetchworld", 0, 0.0f);
77  }
78  bool FETCHORIENT()
79  {
80  return evalInt("stickyorient", 0, 0.0f);
81  }
82 
84  {
85  return evalInt("stickyuvconstant", 0, t);
86  }
87 
88  bool WRAPU(fpreal t)
89  {
90  return evalInt("stickywrapu", 0, t);
91  }
92  bool WRAPV(fpreal t)
93  {
94  return evalInt("stickywrapu", 0, t);
95  }
96 
98  {
99  urange.x() = evalFloat("stickyurange",0,t);
100  urange.y() = evalFloat("stickyurange",1,t);
101  }
103  {
104  vrange.x() = evalFloat("stickyvrange",0,t);
105  vrange.y() = evalFloat("stickyvrange",1,t);
106  }
107 
108  // This gets an aproximation of how many real world units should
109  // map into one UV unit.
110  // It uses the current U/V location to seed itself, or the
111  // last known good value otherwise.
112  fpreal getWorldToUVScaleFactor(fpreal t);
113 
114  // This returns if the V axis is inverted with respect to the
115  // canonical coordinate system.
116  bool isVAxisInverted() const
117  { return myVAxisInvert; }
118 
119 protected:
120  void zeroPrimCacheValues(const GU_Detail *gdp,
121  GA_Offset prim_off);
122  void buildHullCacheValues(const GU_Detail *gdp,
123  const char *uvname,
124  const GEO_Hull *hull);
125  void buildPrimCacheValues(const GU_Detail *gdp,
126  const char *uvname,
127  GA_Offset prim_off);
128  void getVertexOrientation(UT_Vector3 &nml,
129  UT_Vector3 &uaxis,
130  UT_Vector3 &vaxis,
131  const GU_Detail *gdp,
132  const char *uvname,
133  GA_Offset v1,
134  GA_Offset v2,
135  GA_Offset v3);
136  // Used to get pointer to indirection indices for each object type
137  int *getIndirect() const override { return 0; }
138 
139  OP_ERROR cookMyObj(OP_Context &context) override;
140 
141  virtual void getUV(UT_Vector2R &uv, OP_Context &context) {}
142 
143  // Rebuilds the UV cache, if necessary.
144  void rebuildUVCache(fpreal t);
145 
146  GU_DetailHandle getStuckGdp(fpreal t);
147 
148  // Rebuild input dependencies
149  virtual void createInputDependencies(fpreal t);
150  virtual OP_ERROR lockStickyInputs(OP_Context& context);
151  virtual void unlockStickyInputs(OP_Context &context);
152 
153 private:
154  GU_UVCache *myUVCache;
155  UT_Vector3Array myNmlCache;
156  UT_Vector3Array myUAxisCache;
157  UT_Vector3Array myVAxisCache;
158  UT_Array<GA_OffsetArray> myRingZero;
159  fpreal myLastScaleFactor;
160  bool myVAxisInvert;
161 };
162 
163 #endif
164 
bool isVAxisInverted() const
virtual fpreal STICKYROT(fpreal t)
bool WRAPU(fpreal t)
GA_API const UT_StringHolder uv
void STICKYATTRIB(UT_String &str, fpreal t)
virtual void STICKYGEOPATH(UT_String &str, fpreal t)
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
static OP_Node * myConstructor(OP_Network *net, const char *name, OP_Operator *entry)
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:423
GA_Size GA_Offset
Definition: GA_Types.h:646
GLfloat f
Definition: glcorearb.h:1926
virtual void STICKYUV(UT_Vector2R &uv, fpreal t)
void evalString(UT_String &val, int pi, int vi, fpreal t) const
bool get2DWorldTransform(UT_DMatrix4 &mat, OP_Context &context) override
OBJ_StickySharedIndex
virtual OP_ERROR cookMyObj(OP_Context &context)
void identity()
Set the matrix to identity.
Definition: UT_Matrix4.h:1128
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
void STICKYURANGE(UT_Vector2R &urange, fpreal t)
fpreal64 fpreal
Definition: SYS_Types.h:277
GLfloat GLfloat v1
Definition: glcorearb.h:817
bool WRAPV(fpreal t)
OBJ_OBJECT_TYPE getObjectType() const override
Definition: OBJ_Null.h:47
exint evalInt(int pi, int vi, fpreal t) const
virtual void getUV(UT_Vector2R &uv, OP_Context &context)
bool ASSUMEUVCONSTANT(fpreal t)
#define OBJ_API
Definition: OBJ_API.h:10
void STICKYVRANGE(UT_Vector2R &vrange, fpreal t)
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:425
OBJ_OBJECT_TYPE
Definition: OBJ_Node.h:73
int * getIndirect() const override