HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_PolyFrame.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: GU_PolyFrame.h (Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GU_PolyFrame__
12 #define __GU_PolyFrame__
13 
14 #include "GU_API.h"
15 
16 #include <UT/UT_Vector3.h>
17 #include <GA/GA_Handle.h>
18 #include <string.h>
19 
20 // GU_PolyFrame::theMinVertices[] depends on the ordering of this enumeration.
22 {
29 };
30 
32 {
36 };
37 
39 {
45 };
46 
48 {
49 public:
52  , which(GU_POLYFRAME_NORMAL)
53  , orthogonal(false)
54  , left_handed(false)
55  , uv_name(0)
56  {
57  ::memset(names, 0, sizeof(const char *) * 3);
58  }
59 
60  GU_PolyFrameStyle style; // Specifies how the frame vectors are
61  // to be calculated.
62 
63  int which; // A bit mask that specifies which basis
64  // vectors are to be evaluated. Bits
65  // can be set using members of the
66  // GU_PolyFrameVector enumeration.
67 
68  bool orthogonal; // Indicates that the frame vectors
69  // must be made orthogonal.
70 
71  bool left_handed; // When false (default), it produces a
72  // right-handed frame, else left-handed.
73  // This only applies when orthogonal is
74  // true.
75 
76  const char *names[3]; // Specifies the names of the frame
77  // vector attributes that are being
78  // computed. names[0] points to the
79  // name of the tangent vector. names[1]
80  // points to the name of the bitangent
81  // vector. names[2] points to the name
82  // of the normal. names[0] and/or
83  // names[1] will be ignored if the
84  // corresponding bit in 'which' is not
85  // set.
86 
87  const char *uv_name; // Optionally overrides the texture
88  // attribute name used when style is
89  // GU_POLYFRAME_TEXTURE_COORDS
90 };
91 
92 class GA_PointGroup;
93 class GA_PrimitiveGroup;
94 class GEO_Hull;
95 class GEO_Face;
96 class GU_Detail;
97 class UT_BitArray;
98 class UT_String;
99 
101 {
102 public:
103  GU_PolyFrame(GU_Detail *gdp);
104  virtual ~GU_PolyFrame();
105 
106  GU_Detail *getDetail() const { return myGdp; }
107  void setDetail(GU_Detail *gdp) { myGdp = gdp; }
108 
109  GU_PolyFrameError computeFrames(const GU_PolyFrameParms &parms,
110  const GA_PointGroup *point_group = NULL,
111  const GA_PrimitiveGroup *prim_group
112  = NULL);
113 
114 private:
115  void computeFrames(GEO_Face *prim,
116  UT_BitArray *uncomputed,
117  GA_Size &nleft);
118 
119  // The following two methods are called once per detail and once per
120  // polygon, respectively. They give you a chance to compute values that
121  // will be reused by several polygons and vertices, respectively.
122  GU_PolyFrameError detailHook();
123  void primitiveHook();
124 
125  void setFrame();
126 
127  // Frame computation methods for each style in GU_PolyFrameStyle.
128  void computeFirstEdgeFrame();
129  void computeTwoEdgesFrame();
130  void computeCentroidFrame();
131  void computeTexCoordsFrame();
132  void computeTexFramePrim(GA_Offset primoff);
133  void computeTexFrame();
134  void computeDefaultFrame();
135 
136  // Utility methods.
137  static void computeMeshCentroid(const GEO_Hull *hull,
138  GA_Size vertex_no,
139  UT_Vector3 &centroid);
140  static void createPointNormals(GU_Detail *gdp,
141  const GA_RWHandleV3 &offset,
142  const GA_Attribute *normalattrbefore);
143  static GA_RWHandleV3 findOrAddAttrib(GU_Detail *gdp,
144  const char *name,
145  bool per_vertex,
146  bool &created,
147  GA_TypeInfo type);
148  static const char *getLayeredAttribName(const GU_Detail *gdp,
149  const char *name);
150  static bool isStylePerVertex(GU_PolyFrameStyle style);
151  static void makeOrthogonal(UT_Vector3 *frame, bool left_handed);
152 
153  static int theMinVertices[];
154  GU_Detail *myGdp;
155  const GU_PolyFrameParms *myParms;
156  const GA_PointGroup *myPointGroup;
157  const GA_PrimitiveGroup *myPrimGroup;
158  GEO_Face *myCurPrim;
159  GA_Size myCurVertexNo;
160  GA_Index myCurPointNo;
161  UT_Vector3 myFrame[3];
162 
163  // Values computed by detailHook() and polygonHook().
164  UT_Vector3 myCentroid;
165  GA_RWHandleV3 myHandles[3];
166  GA_ROHandleV2 myUvHandle;
167  bool myPerVertex;
168  bool myUvPerVertex;
169  bool myAttribsCreated[3];
170 };
171 
172 #endif
173 
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
Vec orthogonal(const Vec &s, const Vec &t)
Definition: ImathVecAlgo.h:104
3D Vector class.
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GA_Size GA_Offset
Definition: GA_Types.h:617
GU_PolyFrameStyle
Definition: GU_PolyFrame.h:21
GLintptr offset
Definition: glcorearb.h:664
const char * uv_name
Definition: GU_PolyFrame.h:87
#define GU_API
Definition: GU_API.h:11
GLuint const GLchar * name
Definition: glcorearb.h:785
GU_PolyFrameVector
Definition: GU_PolyFrame.h:31
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
GU_Detail * getDetail() const
Definition: GU_PolyFrame.h:106
GA_TypeInfo
Definition: GA_Types.h:80
GU_PolyFrameError
Definition: GU_PolyFrame.h:38
GU_PolyFrameStyle style
Definition: GU_PolyFrame.h:60
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
void setDetail(GU_Detail *gdp)
Definition: GU_PolyFrame.h:107