HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBJ_UVCache.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_UVCache.h (Custom Library, C++)
7  *
8  * COMMENTS: An object used to calculate world coordinates from UV coordinates.
9  *
10  */
11 
12 #include <UT/UT_String.h>
13 #include <UT/UT_IntArray.h>
14 
15 class GEO_PrimPoly;
16 class GEO_Hull;
17 class GA_ROAttributeRef;
18 class GEO_Primitive;
19 class GU_Detail;
20 
21 void obj_getHullIndexFromUV(int &r, int &c, float &fracu, float &fracv,
22  const GEO_Hull *hull, float u, float v);
23 
25 {
26 public:
27  OBJ_UVCache(const GU_Detail *gdp, const char *uvname,
28  bool wrapu, float minu, float maxu,
29  bool wrapv, float minv, float maxv);
30  ~OBJ_UVCache();
31 
32  bool isCacheValid(const GU_Detail *gdp,
33  const char *uvname,
34  bool assumeuvconstant,
35  bool wrapu, float minu, float maxu,
36  bool wrapv, float minv, float maxv) const;
37 
38  void addPrimitive(const GEO_Primitive *prim,
39  const GA_ROAttributeRef &uvoff,
40  bool isvertex);
41 
42  void wrapUV(float &newu, float &newv,
43  float oldu, float oldv);
44  bool getCell(float u, float v, int &cu, int &cv);
45 
46  // This returns the primitive number and the parametric u/v
47  // of the point on that primitive. The parametric u/v are sent
48  // out through pu, pv. The incoming u/v should be texture uv.
49  int getPrimitive(const GU_Detail *gdp,
50  float u, float v, float &pu, float &pv);
51 
52  // This returns whether the given polygon contains the given
53  // u/v value. It fills out pu & pv with the relevant parametric
54  // coordinates.
55  bool testPolygon(const GEO_PrimPoly *poly,
56  const GA_ROAttributeRef &uvoff, bool isvertex,
57  float u, float v,
58  float &pu, float &pv);
59 
60  // Same as testPolygon, but for meshes.
61  bool testHull(const GEO_Hull *hull,
62  const GA_ROAttributeRef &uvoff, bool isvertex,
63  float u, float v,
64  float &pu, float &pv);
65 
66 protected:
68  int myNumPoly;
69  float myMinU, myMaxU;
70  float myMinV, myMaxV;
72  int myResU, myResV;
73  // Accessed myPrimTable[vcell][ucell]
74  // Each entry is a list of the primitive Ids that lie within
75  // that range.
77 
79 };
80 
OBJ_UVCache(const GU_Detail *gdp, const char *uvname, bool wrapu, float minu, float maxu, bool wrapv, float minv, float maxv)
void obj_getHullIndexFromUV(int &r, int &c, float &fracu, float &fracv, const GEO_Hull *hull, float u, float v)
const GLdouble * v
Definition: glcorearb.h:836
void addPrimitive(const GEO_Primitive *prim, const GA_ROAttributeRef &uvoff, bool isvertex)
bool getCell(float u, float v, int &cu, int &cv)
bool myWrapU
Definition: OBJ_UVCache.h:71
bool myWrapV
Definition: OBJ_UVCache.h:71
bool isCacheValid(const GU_Detail *gdp, const char *uvname, bool assumeuvconstant, bool wrapu, float minu, float maxu, bool wrapv, float minv, float maxv) const
UT_IntArray *** myPrimTable
Definition: OBJ_UVCache.h:76
void wrapUV(float &newu, float &newv, float oldu, float oldv)
float myMaxV
Definition: OBJ_UVCache.h:70
int myGdpMetaCount
Definition: OBJ_UVCache.h:78
int getPrimitive(const GU_Detail *gdp, float u, float v, float &pu, float &pv)
This class provides a way to manage a reference to an attribute permitting Read-Only access...
float myMinV
Definition: OBJ_UVCache.h:70
bool testPolygon(const GEO_PrimPoly *poly, const GA_ROAttributeRef &uvoff, bool isvertex, float u, float v, float &pu, float &pv)
float myMaxU
Definition: OBJ_UVCache.h:69
float myMinU
Definition: OBJ_UVCache.h:69
bool testHull(const GEO_Hull *hull, const GA_ROAttributeRef &uvoff, bool isvertex, float u, float v, float &pu, float &pv)
GLboolean r
Definition: glcorearb.h:1221
UT_String myUVName
Definition: OBJ_UVCache.h:67