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