HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PolyWire.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_PolyWire.h ( GU Library, C++)
7  *
8  * COMMENTS: This constructs a series of wires for each edge
9  * of a polygon group.
10  */
11 
12 #ifndef __GU_PolyWire__
13 #define __GU_PolyWire__
14 
15 #include "GU_API.h"
16 #include <UT/UT_Array.h>
17 #include <UT/UT_Vector3Array.h>
18 #include <GA/GA_Edge.h>
19 #include <GA/GA_EdgeMap.h>
20 
21 class GU_Detail;
22 class GA_PrimitiveGroup;
24 class gu_ConnectionGraph;
25 
27 {
28 public:
29  /// Even setting the edge data requires access to the gdp,
30  /// and it doesn't make any sense to change the gdp, so
31  /// it should be passed in the constructor.
32  GU_PolyWire(GU_Detail *gdp);
33  virtual ~GU_PolyWire();
34 
35  /// The edge data
36  class EdgeData
37  {
38  public:
39  int nsegments;
40  float uoff;
41  float u1, u2;
42  float v1, v2;
43  float segscale1, segscale2;
44  };
45 
46  /// Parameter Setting:
47  /// This does NOT claim ownership of these:
48  void setPtWidths(float *widths) { myPtWidths = widths; }
49  void setJointScale(float *scale) { myJointScale = scale; }
50  void setPtSmooth(bool *smooth) { myPtSmooth = smooth; }
51  void setDivisions(int *div) { myDivs = div; }
52  /// NOTE: This makes its own copy of the EdgeData to store in
53  /// myEdgeHashEntries.
54  void setEdgeData(GA_Edge edge, const EdgeData &data);
55  const EdgeData *getEdgeData(GA_Edge edge) const;
56 
57  void setGrp(GA_PrimitiveGroup *grp) { myPrimGroup = grp; }
58  void setJointCorrection(bool jc) { myJointCorrection = jc; }
59  void setDoTextures(bool dotext) { myDoTextures = dotext; }
60  void setUseUpVector(bool up) { myUseUpVector = up; }
61  void setUpVectors(UT_Vector3 *up) { myUpVectors = up; }
62  void setMaxValence(int maxvalence) { myMaxValence = maxvalence; }
63  int getMaxValence() const { return myMaxValence; }
64 
65  // Parameter access functions:
66  GU_Detail *getGdp() const { return myGdp; }
67  bool getSmooth(GA_Index pt) const { return myPtSmooth[pt]; }
68  float getWidth(GA_Index pt) const { return myPtWidths[pt]; }
69  float getMaxScale(GA_Index pt) const { return myJointScale[pt]; }
70  int getSegments(GA_Index pt1, GA_Index pt2) const;
71  void getV(GA_Index pt1, GA_Index pt2, float &v1,
72  float &v2) const;
73  void getU(GA_Index pt1, GA_Index pt2, float &uoff,
74  float &u1, float &u2) const;
75  void getSegScales(GA_Index pt1, GA_Index pt2,
76  float &segscale1, float &segscale2) const;
77  int getDivisions(GA_Index pt) const { return myDivs[pt]; }
78  UT_Vector3 getUpVector(GA_Index pt) const { return myUpVectors[pt]; }
79  bool doJointCorrection() const { return myJointCorrection; }
80  bool doTextures() const { return myDoTextures; }
81  bool useUpVector() const { return myUseUpVector; }
82 
83  // Deal with the texture value cache:
84  float getPtOffTexU(GA_Offset ptoff);
85  void setPtOffTexU(GA_Offset ptoff, float val);
86  float getPtOffTexV(GA_Offset ptoff);
87  void setPtOffTexV(GA_Offset ptoff, float val);
88  float getGlbPtOffTexU(GA_Offset ptoff);
89  bool hasGlbPtOffTexU(GA_Offset ptoff) const;
90  void setGlbPtOffTexU(GA_Offset ptoff, float val);
91 
92  // This uses the built-in circle caches to get the position
93  // on the x/y circle of the required point...
94  // Valid numbers are from 0..(myDiv-1)
95  UT_Vector3 getCirclePos(int idx, int div)
96  { buildCircleCache(div);
97  return (*myCircleCache(div))(idx); }
98 
99  // Builds all the wires:
100  void buildWire();
101 
102  GA_Offset getJunctionPtOff(const UT_Vector3 &stdpos,
103  const UT_Vector3 &center, float scale);
104  // Calculates realworld coordinates of the point
105  void evaluateJunctionPoints(const UT_Vector3 &center,
106  float scale, GA_Offset cptoff);
107  void clearJunctionPoints();
108 
109  // Go through a poly list and texture clamp all the polys...
110  void textureClampPolys(const UT_Array<GEO_PrimPoly *>
111  &polylist,
112  float ubase, float uwidth);
113 
114  GA_ElementWranglerCache *getWranglers() { return myWranglers; }
115 
116 
117 protected:
119  {
120  public:
123  float scaletotal; // Total scale factors
124  GA_Size numpts; // Number of points who've grabbed this.
125  };
126 
127  void buildCircleCache(int div);
128 
129  // These are effectively attributes, but a bit cheaper.
130  // Widths is the radius of the wires at each point, smooth
131  // is a boolean value of whether to do smooth joining or just
132  // connect them.
133  // Segs and divs are how to split up tubes that enter this point.
134  float *myPtWidths;
135  float *myJointScale;
136  bool *myPtSmooth;
137  int *myDivs;
143  // For each point, what it's "u" value is.
146  // These ones are fixed!
148 
149  // Cached circle poses cause I really hate sins and coses...
150  // You might argue that the cost of sin & cos is buried by the
151  // creation of and interpolation of points and attributes. You
152  // might even be right.
154 
155  // What to act on:
156  GU_Detail *const myGdp;
158 
159  // Our connection graph:
160  gu_ConnectionGraph *myGraph;
161 
162  // Our edge hash table:
164 
165  // Our junction point list:
167 
168  // Our hash table values:
170 
172 };
173 
174 #endif
175 
UT_Vector3 getCirclePos(int idx, int div)
Definition: GU_PolyWire.h:95
GA_API const UT_StringHolder div
float getWidth(GA_Index pt) const
Definition: GU_PolyWire.h:68
void setGrp(GA_PrimitiveGroup *grp)
Definition: GU_PolyWire.h:57
void setPtWidths(float *widths)
Definition: GU_PolyWire.h:48
UT_Array< UT_Vector3Array * > myCircleCache
Definition: GU_PolyWire.h:153
float * myPtWidths
Definition: GU_PolyWire.h:134
bool myDoTextures
Definition: GU_PolyWire.h:140
UT_FloatArray myTexU
Definition: GU_PolyWire.h:144
int getMaxValence() const
Definition: GU_PolyWire.h:63
void setUseUpVector(bool up)
Definition: GU_PolyWire.h:60
bool doTextures() const
Definition: GU_PolyWire.h:80
void setDivisions(int *div)
Definition: GU_PolyWire.h:51
bool myUseUpVector
Definition: GU_PolyWire.h:141
bool myJointCorrection
Definition: GU_PolyWire.h:139
void setMaxValence(int maxvalence)
Definition: GU_PolyWire.h:62
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
GLdouble u1
Definition: glad.h:2676
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:235
The edge data.
Definition: GU_PolyWire.h:36
GU_Detail * getGdp() const
Definition: GU_PolyWire.h:66
bool doJointCorrection() const
Definition: GU_PolyWire.h:79
GA_Size GA_Offset
Definition: GA_Types.h:641
GA_API const UT_StringHolder scale
void setJointCorrection(bool jc)
Definition: GU_PolyWire.h:58
GA_ElementWranglerCache * getWranglers()
Definition: GU_PolyWire.h:114
void setUpVectors(UT_Vector3 *up)
Definition: GU_PolyWire.h:61
bool * myPtSmooth
Definition: GU_PolyWire.h:136
bool useUpVector() const
Definition: GU_PolyWire.h:81
gu_ConnectionGraph * myGraph
Definition: GU_PolyWire.h:160
int * myDivs
Definition: GU_PolyWire.h:137
#define GU_API
Definition: GU_API.h:14
UT_Vector3 getUpVector(GA_Index pt) const
Definition: GU_PolyWire.h:78
GLdouble GLdouble u2
Definition: glad.h:2676
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:635
GA_EdgeMap< EdgeData * > myEdgeHash
Definition: GU_PolyWire.h:163
virtual bool smooth(GA_AttributeOperand &d, GA_AttributeOperand &min, GA_AttributeOperand &max, GA_AttributeOperand &t) const
d = SYSsmooth(min, max, t);
void setDoTextures(bool dotext)
Definition: GU_PolyWire.h:59
int myMaxValence
Definition: GU_PolyWire.h:142
void setPtSmooth(bool *smooth)
Definition: GU_PolyWire.h:50
float getMaxScale(GA_Index pt) const
Definition: GU_PolyWire.h:69
void setJointScale(float *scale)
Definition: GU_PolyWire.h:49
GA_API const UT_StringHolder up
bool getSmooth(GA_Index pt) const
Definition: GU_PolyWire.h:67
UT_Array< gu_JunctionPoint > myJunctionPoints
Definition: GU_PolyWire.h:166
GA_ElementWranglerCache * myWranglers
Definition: GU_PolyWire.h:171
UT_FloatArray myTexV
Definition: GU_PolyWire.h:145
float * myJointScale
Definition: GU_PolyWire.h:135
GLfloat GLfloat v1
Definition: glcorearb.h:817
GLuint GLfloat * val
Definition: glcorearb.h:1608
UT_FloatArray myGlbTexU
Definition: GU_PolyWire.h:147
UT_Vector3 * myUpVectors
Definition: GU_PolyWire.h:138
GU_Detail *const myGdp
Definition: GU_PolyWire.h:156
UT_Array< EdgeData * > myEdgeHashEntries
Definition: GU_PolyWire.h:169
int getDivisions(GA_Index pt) const
Definition: GU_PolyWire.h:77
GA_PrimitiveGroup * myPrimGroup
Definition: GU_PolyWire.h:157
Definition: format.h:895