HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimitiveBuilder.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: GT_PrimitiveBuilder.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_PrimitiveBuilder__
12 #define __GT_PrimitiveBuilder__
13 
14 #include "GT_API.h"
15 #include "GT_Handles.h"
16 #include "GT_Types.h"
17 #include "GT_Primitive.h"
18 #include "GT_Transform.h"
19 #include "GT_AttributeBuilder.h"
20 
21 class GT_TrimNuCurves;
22 
23 /// @brief Create specific primitives by building from existing arrays
24 ///
25 /// These methods construct GT primitives based on the attribute parsing style
26 /// defined in GT_AttributeBuilder.
27 ///
28 /// Each builder function specifies a number of fixed arguments describing the
29 /// topology of the primitive. The function also takes variadic arguments
30 /// which are passed through to the GT_AttributeBuilder function.
31 ///
32 /// A simple example creating a simple point mesh
33 /// @code
34 /// // Build a point mesh
35 /// #define NPOINTS 4
36 /// UT_Vector3 P[NPOINTS];
37 /// fpreal32 width[NPOINTS];
38 /// initialize(P, w);
39 /// prim = GT_PrimitiveBuilder::pointMesh(err, NPOINTS,
40 /// "vertex point32 P", P,
41 /// "vertex real32 width", width,
42 /// NULL);
43 /// @endcode
44 /// A simple example creating a curve mesh that has deformation motion blur
45 /// @code
46 /// #define NCURVES 3
47 /// #define PTS_PER_CURVE 3
48 /// UT_Vector3 P0[NCURVES*PTS_PER_CURVE];
49 /// UT_Vector3 P1[NCURVES*PTS_PER_CURVE];
50 /// UT_Vector3 Cd[NCURVES*PTS_PER_CURVE];
51 ///
52 /// int points_per_curve[NCURVES];
53 /// for (int i = 0; i < ncurves; ++i)
54 /// {
55 /// initCurveP(i, P0+i*PTS_PER_CURVE, time=0);
56 /// initCurveP(i, P1+i*PTS_PER_CURVE, time=1);
57 /// initCurveColor(i, Cd + i*PTS_PER_CURVE);
58 /// points_per_curve[i] = PTS_PER_CURVE;
59 /// }
60 /// prim = GT_PrimitiveBuilder::curveMesh(err, GT_BEZIER_BASIS,
61 /// NCURVES, points_per_curve, false,
62 /// "vertex point32 P", P0, // P for first segment
63 /// "vertex point32 P", P1, // P for next segment
64 /// "vertex color32 Cd", Cd, // Color for curves
65 /// NULL);
66 /// @endcode
67 ///
69 {
70 public:
71  /// Construct a point mesh
72  /// - varying[npoints]
73  /// - vertex[npoints]
74  /// - primitive[1]
75  /// - detail[1]
76  static GT_PrimitiveHandle pointMesh(GT_BuilderStatus &err,
77  int npoints,
79 
80  /// Construct a single polygon
81  /// - varying[npoints]
82  /// - vertex[npoints]
83  /// - primitive[1]
84  /// - detail[1]
85  static GT_PrimitiveHandle polygon(GT_BuilderStatus &err,
86  int npoints,
88 
89  /// Construct a mesh of @c npolys polygons. @n
90  /// The @c counts array specifies the number of vertices for each polygon.
91  /// The @c vtxlist array contains an index for each vertex. The @b varying
92  /// attributes are indexed using these indices. There should be @c
93  /// sum(counts) entries in the @c vtxlist array.
94  /// - varying[] @n
95  /// These values can be shared between polygons and are referenced using
96  /// the @c vtxlist array. The array should have at least
97  /// @c max(vtxlist)+1 entries.
98  /// - vertex[] @n
99  /// These values specify unique values for each vertex of each polygon.
100  /// There should be @c sum(counts) entries in each of these arrays.
101  /// - primitive[npolys] @n
102  /// The primitive attributes are specified with a single value per face.
103  /// - detail[1]
104  static GT_PrimitiveHandle polygonMesh(GT_BuilderStatus &err,
105  int npolys, const int *counts,
106  const int *vtxlist,
108 
109  /// Construct a subdivision mesh of @c nfaces faces. @n
110  /// The @c counts array specifies the number of vertices for each face.
111  /// The @c vtxlist array contains an index for each vertex. The @b varying
112  /// attributes are indexed using these indices. There should be @c
113  /// sum(counts) entries in the @c vtxlist array.
114  /// - varying[] @n
115  /// These values can be shared between faces and are referenced using
116  /// the @c vtxlist array. The array should have at least
117  /// @c max(vtxlist)+1 entries.
118  /// - vertex[] @n
119  /// These values specify unique values for each vertex of each face.
120  /// There should be @c sum(counts) entries in each of these arrays.
121  /// - primitive[npolys] @n
122  /// The primitive attributes are specified with a single value per face.
123  /// - detail[1]
124  static GT_PrimitiveHandle subdivisionMesh(GT_BuilderStatus &err,
125  GT_Scheme scheme,
126  int npolys, const int *counts,
127  const int *vtxlist,
129 
130  /// Construct a single open curve. @n
131  /// The @c counts array specifies the number of vertices for the curve.
132  /// - varying[], vertex[] @n
133  /// There are values for each vertex of the curve. Each array
134  /// should have @c npoints entries.
135  /// - primitive/detail[1] @n
136  static GT_PrimitiveHandle curve(GT_BuilderStatus &err,
137  GT_Basis basis, int npoints, bool wrap,
139  /// Construct a mesh of @c ncurves open curves. @n
140  /// The curves are constructed using the @c basis given.
141  /// The @c counts array specifies the number of vertices for each curve.
142  /// The @c vtxlist array contains an index for each vertex. The @b varying
143  /// attributes are indexed using these indices. There should be @c
144  /// sum(counts) entries in the @c vtxlist array.
145  /// - varying[], vertex[] @n
146  /// There are distinct values for each vertex of each curve. Each array
147  /// should have @c sum(counts) entries.
148  /// - primitive[ncurves] @n
149  /// The primitive attributes are specified with a single value per curve.
150  /// - detail[1]
151  static GT_PrimitiveHandle curveMesh(GT_BuilderStatus &err,
152  GT_Basis basis, int ncurves,
153  const int *counts, bool wrap,
155 
156  /// Construct a patch @n
157  /// The patch is constructed using the given @c basis. When the @c
158  /// uwrap or @c vwrap flags are set, the patch will be wrapped (or
159  /// periodic) in the given direction. The @c nu and @c nv values must
160  /// match the periodicity and basis.
161  ///
162  /// - varying[], vertex[] @n
163  /// There are distinct values for each vertex of the patch. Each array
164  /// should have @c nu*nv entries.
165  /// - primitive[npatches] @n
166  /// The primitive attributes are specified per sub-patch. The number of
167  /// sub-patches is determined by the basis and periodicity.
168  /// - detail[1]
169  static GT_PrimitiveHandle patch(GT_BuilderStatus &err,
170  GT_Basis basis,
171  int nu, bool uwrap, int nv, bool vwrap,
173 
174  /// Construct a patch mesh @n
175  /// A patch mesh is a collection of patches (all with the same basis)
176  /// - @c nu, @c nv @n
177  /// Arrays which should have @c npatches entries. These are the number
178  /// of vertices in the u and v directions for each individual patch.
179  /// - @c uwrap, @c vwrap @n
180  /// Arrays which should have @c npatches entries. These indicate whether
181  /// each individual patch is wrapped (periodic) in each direction.
182  /// - varying[], vertex[] @n
183  /// Distinct values for each vertex of every patch. Each array should be
184  /// sum(nu[i]*nv[i]) entries.
185  /// - uniform[] @n
186  /// Distinct values for each face of each patch. This value is
187  /// determined by the wrapped flags and the basis type.
188  /// - detail[1]
189  static GT_PrimitiveHandle patchMesh(GT_BuilderStatus &err,
190  int npatches,
191  GT_Basis basis,
192  const int *nu, const bool *uwrap,
193  const int *nv, const bool *vwrap,
195 
196  /// Construct a mesh of NURBS curves @n
197  /// NURBS curves are defined by a hulls of control vertices.
198  /// - @c ncurves - The number of individual curves in the mesh
199  /// - @c counts - The number of vertices in each curve
200  /// - @c orders - The order of each curve
201  /// - @c knots - Each curve should have @c counts[i]+orders[i] knots
202  /// - @c tmin, @c tmax - The parametric range for the curve. @c tmin
203  /// should be >= to the first knot for the curve. @c tmax should be >=
204  /// tmin and <= the last knot for the curve.
205  /// - varying[], vertex[] attributes @n
206  /// Distinct values for each vertex on the patch. Each array should be
207  /// nu*nv entries.
208  /// - uniform[] attributes @n
209  /// Distinct values for each curve. Arrays should have ncurves entries.
210  /// - detail[1] @n
211  /// Detail attributes are constant across the curve mesh.
212  /// Please note that for a cubic NURBS curve, the order is 4.
213  static GT_PrimitiveHandle nucurves(GT_BuilderStatus &err,
214  int ncurves,
215  const int *counts,
216  const int *orders,
217  const fpreal *knots,
218  const fpreal *tmin,
219  const fpreal *tmax,
221 
222 
223  /// Construct a NURBS patch @n
224  /// A NURBS patch is defined by a hull of control vertices.
225  /// The number of elements in the uknots array should be @c nu+uorder. The
226  /// number of elements in the vknots array should be @c nv+vorder.
227  /// - varying[], vertex[] attributes @n
228  /// Distinct values for each vertex on the patch. Each array should be
229  /// nu*nv entries.
230  /// - uniform[1], detail[1] @n
231  /// Uniform and detail attributes are uniform across the patch.
232  /// Please note that for a cubic NURBS curve, the order is 4.
233  static GT_PrimitiveHandle nupatch(GT_BuilderStatus &err,
234  int nu, int uorder, const fpreal *uknots,
235  int nv, int vorder, const fpreal *vknots,
237 
238  /// Build geometry for the given bounding box.
239  /// - varying[8]
240  /// Varying attributes are defined for each shared point of the box. You
241  /// should @b not give a "P" attribute since that's built for you
242  /// automatically.
243  /// - vertex[24]
244  /// Vertex attributes are defined per-vertex of each face
245  /// - uniform[6]
246  /// Uniform attributes are defined per face
247  /// - detail[1] @n
248  /// Detail attributes are uniform over all faces of the geometry
249  static GT_PrimitiveHandle box(GT_BuilderStatus &err,
250  const UT_BoundingBox &box,
252  /// Build a curve mesh for the given bounding box.
253  /// - At the current time, vertex/varying attributes are not supported and
254  /// are interpreted as uniform/detail attributes. In the future, they
255  /// may be defined differently.
256  /// - uniform[1]/detail[1] @n
257  /// Detail & uniform attributes are uniform over all faces of the geometry
258  static GT_PrimitiveHandle wireBox(GT_BuilderStatus &err,
259  const UT_BoundingBox &box,
261 
262  /// Build a sphere.
263  /// - varying[1], vertex[1], primitive[1], detail[1]
264  /// All storage classes should have a single entry
265  static GT_PrimitiveHandle sphere(GT_BuilderStatus &err,
268  /// Build a circle.
269  /// - varying[1], vertex[1], primitive[1], detail[1]
270  /// All storage classes should have a single entry
271  static GT_PrimitiveHandle circle(GT_BuilderStatus &err,
272  const GT_TransformHandle &transform,
274  /// Build a tube.
275  /// - varying[1], vertex[1], primitive[1], detail[1]
276  /// All storage classes should have a single entry
277  static GT_PrimitiveHandle tube(GT_BuilderStatus &err,
278  const GT_TransformHandle &transform,
279  fpreal taper,
280  bool caps,
282  /// Build a hyperboloid sheet
283  /// - varying[1], vertex[1], primitive[1], detail[1]
284  /// All storage classes should have a single entry
285  static GT_PrimitiveHandle hyperboloid(GT_BuilderStatus &err,
286  const GT_TransformHandle &transform,
287  const UT_Vector3D &p0,
288  const UT_Vector3D &p1,
290 
291  /// Build trim curves.
292  /// - The @c curves_per_loop array should be nloops long. The number of
293  /// curves (@c ncurves) is the sum of the entries in this array.
294  /// - The @c points_per_curve array should be @c ncurves long (i.e. one
295  /// entry for each individual curve)
296  /// - The @c curve_orders array should be @c ncurves long
297  /// - The @c knots array should have
298  /// <tt>sum(points_per_curve) + sum(curve_orders)</tt> entries
299  /// - The @c min and @c max arrays should be @c ncurves long
300  /// - The @c uvw array should be @c sum(points_per_curve) entries long
301  static GT_TrimNuCurves *trimcurves(GT_BuilderStatus &err,
302  int nloops,
303  const int *curves_per_loop,
304  const int *points_per_curve,
305  const int *curve_orders,
306  const fpreal *knots,
307  const fpreal *min,
308  const fpreal *max,
309  const UT_Vector3D *uvw);
310 };
311 
312 #endif
Create specific primitives by building from existing arrays.
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint vorder
Definition: glad.h:2682
#define GT_API
Definition: GT_API.h:13
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
UT_VariadicT< GT_Attribute > GT_VariadicAttributes
GT_Scheme
Subdivision schemes.
Definition: GT_Types.h:81
GA_API const UT_StringHolder transform
fpreal64 fpreal
Definition: SYS_Types.h:278
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GT_Basis
Definition: GT_Types.h:55
Return the status of primitive creation from GT_PrimitiveBuilder.
Trim loops specified by a number of individual NURBS curves.
GLdouble GLdouble GLint GLint uorder
Definition: glad.h:2682