HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 OBJ_UVCache;
39 class GEO_Vertex;
40 class GEO_Hull;
41 
43 {
44 public:
46  const char *name,
47  OP_Operator *op);
48  virtual ~OBJ_StickyShared();
49 
50  virtual OBJ_OBJECT_TYPE getObjectType() const;
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:
61  virtual bool get2DWorldTransform(UT_DMatrix4 &mat,
62  OP_Context &context)
63  { mat.identity(); return true; }
64 
65 
66  virtual void STICKYGEOPATH(UT_String &str, fpreal t) {}
68  {
69  evalString(str, "stickyattrib", 0, t);
70  }
71  virtual void STICKYUV(UT_Vector2R &uv, fpreal t) {}
72  virtual fpreal STICKYROT(fpreal t) { return 0; }
73  bool FETCHWORLD()
74  {
75  return evalInt("fetchworld", 0, 0.0f);
76  }
77  bool FETCHORIENT()
78  {
79  return evalInt("stickyorient", 0, 0.0f);
80  }
81 
83  {
84  return evalInt("stickyuvconstant", 0, t);
85  }
86 
87  bool WRAPU(fpreal t)
88  {
89  return evalInt("stickywrapu", 0, t);
90  }
91  bool WRAPV(fpreal t)
92  {
93  return evalInt("stickywrapu", 0, t);
94  }
95 
96  void STICKYURANGE(UT_Vector2R &urange, fpreal t)
97  {
98  urange.x() = evalFloat("stickyurange",0,t);
99  urange.y() = evalFloat("stickyurange",1,t);
100  }
101  void STICKYVRANGE(UT_Vector2R &vrange, fpreal t)
102  {
103  vrange.x() = evalFloat("stickyvrange",0,t);
104  vrange.y() = evalFloat("stickyvrange",1,t);
105  }
106 
107  // This gets an aproximation of how many real world units should
108  // map into one UV unit.
109  // It uses the current U/V location to seed itself, or the
110  // last known good value otherwise.
111  fpreal getWorldToUVScaleFactor(fpreal t);
112 
113  // This returns if the V axis is inverted with respect to the
114  // canonical coordinate system.
115  bool isVAxisInverted() const
116  { return myVAxisInvert; }
117 
118 protected:
119  void zeroPrimCacheValues(const GU_Detail *gdp,
120  GA_Offset prim_off);
121  void buildHullCacheValues(const GU_Detail *gdp,
122  const char *uvname,
123  const GEO_Hull *hull);
124  void buildPrimCacheValues(const GU_Detail *gdp,
125  const char *uvname,
126  GA_Offset prim_off);
127  void getVertexOrientation(UT_Vector3 &nml,
128  UT_Vector3 &uaxis,
129  UT_Vector3 &vaxis,
130  const GU_Detail *gdp,
131  const char *uvname,
132  GA_Offset v1,
133  GA_Offset v2,
134  GA_Offset v3);
135  // Used to get pointer to indirection indices for each object type
136  virtual int *getIndirect() const { return 0; }
137 
138  virtual OP_ERROR cookMyObj(OP_Context &context);
139 
140  virtual void getUV(UT_Vector2R &uv, OP_Context &context) {}
141 
142  // Rebuilds the UV cache, if necessary.
143  void rebuildUVCache(fpreal t);
144 
145  GU_DetailHandle getStuckGdp(fpreal t);
146 
147  // Rebuild input dependencies
148  virtual void createInputDependencies(fpreal t);
149  virtual OP_ERROR lockStickyInputs(OP_Context& context);
150  virtual void unlockStickyInputs(OP_Context &context);
151 
152 private:
153  OBJ_UVCache *myUVCache;
154  UT_Vector3Array myNmlCache;
155  UT_Vector3Array myUAxisCache;
156  UT_Vector3Array myVAxisCache;
157  UT_Array<GA_OffsetArray> myRingZero;
158  fpreal myLastScaleFactor;
159  bool myVAxisInvert;
160 };
161 
162 #endif
163 
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
T & x(void)
Definition: UT_Vector2.h:284
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:817
3D Vector class.
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:818
2D Vector class.
Definition: UT_Vector2.h:137
virtual OBJ_OBJECT_TYPE getObjectType() const
Definition: OBJ_Null.h:47
virtual bool get2DWorldTransform(UT_DMatrix4 &mat, OP_Context &context)
GA_Size GA_Offset
Definition: GA_Types.h:617
GLfloat f
Definition: glcorearb.h:1925
virtual void STICKYUV(UT_Vector2R &uv, fpreal t)
void evalString(UT_String &val, int pi, int vi, fpreal t) const
OBJ_StickySharedIndex
virtual OP_ERROR cookMyObj(OP_Context &context)
void identity()
Set the matrix to identity.
Definition: UT_Matrix4.h:924
GLuint const GLchar * name
Definition: glcorearb.h:785
double fpreal
Definition: SYS_Types.h:269
void STICKYURANGE(UT_Vector2R &urange, fpreal t)
GLfloat GLfloat v1
Definition: glcorearb.h:816
bool WRAPV(fpreal t)
T & y(void)
Definition: UT_Vector2.h:286
exint evalInt(int pi, int vi, fpreal t) const
virtual int * getIndirect() 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)
OBJ_OBJECT_TYPE
Definition: OBJ_Node.h:70