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 
63  // Parameter access functions:
64  GU_Detail *getGdp() const { return myGdp; }
65  bool getSmooth(GA_Index pt) const { return myPtSmooth[pt]; }
66  float getWidth(GA_Index pt) const { return myPtWidths[pt]; }
67  float getMaxScale(GA_Index pt) const { return myJointScale[pt]; }
68  int getSegments(GA_Index pt1, GA_Index pt2) const;
69  void getV(GA_Index pt1, GA_Index pt2, float &v1,
70  float &v2) const;
71  void getU(GA_Index pt1, GA_Index pt2, float &uoff,
72  float &u1, float &u2) const;
73  void getSegScales(GA_Index pt1, GA_Index pt2,
74  float &segscale1, float &segscale2) const;
75  int getDivisions(GA_Index pt) const { return myDivs[pt]; }
76  UT_Vector3 getUpVector(GA_Index pt) const { return myUpVectors[pt]; }
77  bool doJointCorrection() const { return myJointCorrection; }
78  bool doTextures() const { return myDoTextures; }
79  bool useUpVector() const { return myUseUpVector; }
80 
81  // Deal with the texture value cache:
82  float getPtOffTexU(GA_Offset ptoff);
83  void setPtOffTexU(GA_Offset ptoff, float val);
84  float getPtOffTexV(GA_Offset ptoff);
85  void setPtOffTexV(GA_Offset ptoff, float val);
86  float getGlbPtOffTexU(GA_Offset ptoff);
87  bool hasGlbPtOffTexU(GA_Offset ptoff) const;
88  void setGlbPtOffTexU(GA_Offset ptoff, float val);
89 
90  // This uses the built-in circle caches to get the position
91  // on the x/y circle of the required point...
92  // Valid numbers are from 0..(myDiv-1)
93  UT_Vector3 getCirclePos(int idx, int div)
94  { buildCircleCache(div);
95  return (*myCircleCache(div))(idx); }
96 
97  // Builds all the wires:
98  void buildWire();
99 
100  GA_Offset getJunctionPtOff(const UT_Vector3 &stdpos,
101  const UT_Vector3 &center, float scale);
102  // Calculates realworld coordinates of the point
103  void evaluateJunctionPoints(const UT_Vector3 &center,
104  float scale, GA_Offset cptoff);
105  void clearJunctionPoints();
106 
107  // Go through a poly list and texture clamp all the polys...
108  void textureClampPolys(const UT_Array<GEO_PrimPoly *>
109  &polylist,
110  float ubase, float uwidth);
111 
112  GA_ElementWranglerCache *getWranglers() { return myWranglers; }
113 
114 
115 protected:
117  {
118  public:
121  float scaletotal; // Total scale factors
122  GA_Size numpts; // Number of points who've grabbed this.
123  };
124 
125  void buildCircleCache(int div);
126 
127  // These are effectively attributes, but a bit cheaper.
128  // Widths is the radius of the wires at each point, smooth
129  // is a boolean value of whether to do smooth joining or just
130  // connect them.
131  // Segs and divs are how to split up tubes that enter this point.
132  float *myPtWidths;
133  float *myJointScale;
134  bool *myPtSmooth;
135  int *myDivs;
140  // For each point, what it's "u" value is.
143  // These ones are fixed!
145 
146  // Cached circle poses cause I really hate sins and coses...
147  // You might argue that the cost of sin & cos is buried by the
148  // creation of and interpolation of points and attributes. You
149  // might even be right.
151 
152  // What to act on:
153  GU_Detail *const myGdp;
155 
156  // Our connection graph:
157  gu_ConnectionGraph *myGraph;
158 
159  // Our edge hash table:
161 
162  // Our junction point list:
164 
165  // Our hash table values:
167 
169 };
170 
171 #endif
172 
UT_Vector3 getCirclePos(int idx, int div)
Definition: GU_PolyWire.h:93
GA_API const UT_StringHolder div
float getWidth(GA_Index pt) const
Definition: GU_PolyWire.h:66
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:150
float * myPtWidths
Definition: GU_PolyWire.h:132
bool myDoTextures
Definition: GU_PolyWire.h:138
UT_FloatArray myTexU
Definition: GU_PolyWire.h:141
void setUseUpVector(bool up)
Definition: GU_PolyWire.h:60
bool doTextures() const
Definition: GU_PolyWire.h:78
void setDivisions(int *div)
Definition: GU_PolyWire.h:51
bool myUseUpVector
Definition: GU_PolyWire.h:139
bool myJointCorrection
Definition: GU_PolyWire.h:137
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
The edge data.
Definition: GU_PolyWire.h:36
GU_Detail * getGdp() const
Definition: GU_PolyWire.h:64
bool doJointCorrection() const
Definition: GU_PolyWire.h:77
GA_Size GA_Offset
Definition: GA_Types.h:617
GA_API const UT_StringHolder scale
void setJointCorrection(bool jc)
Definition: GU_PolyWire.h:58
GA_ElementWranglerCache * getWranglers()
Definition: GU_PolyWire.h:112
void setUpVectors(UT_Vector3 *up)
Definition: GU_PolyWire.h:61
bool * myPtSmooth
Definition: GU_PolyWire.h:134
bool useUpVector() const
Definition: GU_PolyWire.h:79
gu_ConnectionGraph * myGraph
Definition: GU_PolyWire.h:157
int * myDivs
Definition: GU_PolyWire.h:135
#define GU_API
Definition: GU_API.h:12
UT_Vector3 getUpVector(GA_Index pt) const
Definition: GU_PolyWire.h:76
GLboolean * data
Definition: glcorearb.h:130
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
GA_EdgeMap< EdgeData * > myEdgeHash
Definition: GU_PolyWire.h:160
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
void setPtSmooth(bool *smooth)
Definition: GU_PolyWire.h:50
float getMaxScale(GA_Index pt) const
Definition: GU_PolyWire.h:67
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:65
UT_Array< gu_JunctionPoint > myJunctionPoints
Definition: GU_PolyWire.h:163
GA_ElementWranglerCache * myWranglers
Definition: GU_PolyWire.h:168
UT_FloatArray myTexV
Definition: GU_PolyWire.h:142
float * myJointScale
Definition: GU_PolyWire.h:133
GLfloat GLfloat v1
Definition: glcorearb.h:816
GLuint GLfloat * val
Definition: glcorearb.h:1607
UT_FloatArray myGlbTexU
Definition: GU_PolyWire.h:144
UT_Vector3 * myUpVectors
Definition: GU_PolyWire.h:136
GU_Detail *const myGdp
Definition: GU_PolyWire.h:153
UT_Array< EdgeData * > myEdgeHashEntries
Definition: GU_PolyWire.h:166
int getDivisions(GA_Index pt) const
Definition: GU_PolyWire.h:75
GA_PrimitiveGroup * myPrimGroup
Definition: GU_PolyWire.h:154