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 public:
70  /// Construct a point mesh
71  /// - varying[npoints]
72  /// - vertex[npoints]
73  /// - primitive[1]
74  /// - detail[1]
75  static GT_PrimitiveHandle pointMesh(GT_BuilderStatus &err,
76  int npoints,
78 
79  /// Construct a single polygon
80  /// - varying[npoints]
81  /// - vertex[npoints]
82  /// - primitive[1]
83  /// - detail[1]
84  static GT_PrimitiveHandle polygon(GT_BuilderStatus &err,
85  int npoints,
87 
88  /// Construct a mesh of @c npolys polygons. @n
89  /// The @c counts array specifies the number of vertices for each polygon.
90  /// The @c vtxlist array contains an index for each vertex. The @b varying
91  /// attributes are indexed using these indices. There should be @c
92  /// sum(counts) entries in the @c vtxlist array.
93  /// - varying[] @n
94  /// These values can be shared between polygons and are referenced using
95  /// the @c vtxlist array. The array should have at least
96  /// @c max(vtxlist)+1 entries.
97  /// - vertex[] @n
98  /// These values specify unique values for each vertex of each polygon.
99  /// There should be @c sum(counts) entries in each of these arrays.
100  /// - primitive[npolys] @n
101  /// The primitive attributes are specified with a single value per face.
102  /// - detail[1]
103  static GT_PrimitiveHandle polygonMesh(GT_BuilderStatus &err,
104  int npolys, const int *counts,
105  const int *vtxlist,
107 
108  /// Construct a subdivision mesh of @c nfaces faces. @n
109  /// The @c counts array specifies the number of vertices for each face.
110  /// The @c vtxlist array contains an index for each vertex. The @b varying
111  /// attributes are indexed using these indices. There should be @c
112  /// sum(counts) entries in the @c vtxlist array.
113  /// - varying[] @n
114  /// These values can be shared between faces and are referenced using
115  /// the @c vtxlist array. The array should have at least
116  /// @c max(vtxlist)+1 entries.
117  /// - vertex[] @n
118  /// These values specify unique values for each vertex of each face.
119  /// There should be @c sum(counts) entries in each of these arrays.
120  /// - primitive[npolys] @n
121  /// The primitive attributes are specified with a single value per face.
122  /// - detail[1]
123  static GT_PrimitiveHandle subdivisionMesh(GT_BuilderStatus &err,
124  GT_Scheme scheme,
125  int npolys, const int *counts,
126  const int *vtxlist,
128 
129  /// Construct a single open curve. @n
130  /// The @c counts array specifies the number of vertices for the curve.
131  /// - varying[], vertex[] @n
132  /// There are values for each vertex of the curve. Each array
133  /// should have @c npoints entries.
134  /// - primitive/detail[1] @n
135  static GT_PrimitiveHandle curve(GT_BuilderStatus &err,
136  GT_Basis basis, int npoints, bool wrap,
138  /// Construct a mesh of @c ncurves open curves. @n
139  /// The curves are constructed using the @c basis given.
140  /// The @c counts array specifies the number of vertices for each curve.
141  /// The @c vtxlist array contains an index for each vertex. The @b varying
142  /// attributes are indexed using these indices. There should be @c
143  /// sum(counts) entries in the @c vtxlist array.
144  /// - varying[], vertex[] @n
145  /// There are distinct values for each vertex of each curve. Each array
146  /// should have @c sum(counts) entries.
147  /// - primitive[ncurves] @n
148  /// The primitive attributes are specified with a single value per curve.
149  /// - detail[1]
150  static GT_PrimitiveHandle curveMesh(GT_BuilderStatus &err,
151  GT_Basis basis, int ncurves,
152  const int *counts, bool wrap,
154 
155  /// Construct a patch @n
156  /// The patch is constructed using the given @c basis. When the @c
157  /// uwrap or @c vwrap flags are set, the patch will be wrapped (or
158  /// periodic) in the given direction. The @c nu and @c nv values must
159  /// match the periodicity and basis.
160  ///
161  /// - varying[], vertex[] @n
162  /// There are distinct values for each vertex of the patch. Each array
163  /// should have @c nu*nv entries.
164  /// - primitive[npatches] @n
165  /// The primitive attributes are specified per sub-patch. The number of
166  /// sub-patches is determined by the basis and periodicity.
167  /// - detail[1]
168  static GT_PrimitiveHandle patch(GT_BuilderStatus &err,
169  GT_Basis basis,
170  int nu, bool uwrap, int nv, bool vwrap,
172 
173  /// Construct a patch mesh @n
174  /// A patch mesh is a collection of patches (all with the same basis)
175  /// - @c nu, @c nv @n
176  /// Arrays which should have @c npatches entries. These are the number
177  /// of vertices in the u and v directions for each individual patch.
178  /// - @c uwrap, @c vwrap @n
179  /// Arrays which should have @c npatches entries. These indicate whether
180  /// each individual patch is wrapped (periodic) in each direction.
181  /// - varying[], vertex[] @n
182  /// Distinct values for each vertex of every patch. Each array should be
183  /// sum(nu[i]*nv[i]) entries.
184  /// - uniform[] @n
185  /// Distinct values for each face of each patch. This value is
186  /// determined by the wrapped flags and the basis type.
187  /// - detail[1]
188  static GT_PrimitiveHandle patchMesh(GT_BuilderStatus &err,
189  int npatches,
190  GT_Basis basis,
191  const int *nu, const bool *uwrap,
192  const int *nv, const bool *vwrap,
194 
195  /// Construct a mesh of NURBS curves @n
196  /// NURBS curves are defined by a hulls of control vertices.
197  /// - @c ncurves - The number of individual curves in the mesh
198  /// - @c counts - The number of vertices in each curve
199  /// - @c orders - The order of each curve
200  /// - @c knots - Each curve should have @c counts[i]+orders[i] knots
201  /// - @c tmin, @c tmax - The parametric range for the curve. @c tmin
202  /// should be >= to the first knot for the curve. @c tmax should be >=
203  /// tmin and <= the last knot for the curve.
204  /// - varying[], vertex[] attributes @n
205  /// Distinct values for each vertex on the patch. Each array should be
206  /// nu*nv entries.
207  /// - uniform[] attributes @n
208  /// Distinct values for each curve. Arrays should have ncurves entries.
209  /// - detail[1] @n
210  /// Detail attributes are constant across the curve mesh.
211  /// Please note that for a cubic NURBS curve, the order is 4.
212  static GT_PrimitiveHandle nucurves(GT_BuilderStatus &err,
213  int ncurves,
214  const int *counts,
215  const int *orders,
216  const fpreal *knots,
217  const fpreal *tmin,
218  const fpreal *tmax,
220 
221 
222  /// Construct a NURBS patch @n
223  /// A NURBS patch is defined by a hull of control vertices.
224  /// The number of elements in the uknots array should be @c nu+uorder. The
225  /// number of elements in the vknots array should be @c nv+vorder.
226  /// - varying[], vertex[] attributes @n
227  /// Distinct values for each vertex on the patch. Each array should be
228  /// nu*nv entries.
229  /// - uniform[1], detail[1] @n
230  /// Uniform and detail attributes are uniform across the patch.
231  /// Please note that for a cubic NURBS curve, the order is 4.
232  static GT_PrimitiveHandle nupatch(GT_BuilderStatus &err,
233  int nu, int uorder, const fpreal *uknots,
234  int nv, int vorder, const fpreal *vknots,
236 
237  /// Build geometry for the given bounding box.
238  /// - varying[8]
239  /// Varying attributes are defined for each shared point of the box. You
240  /// should @b not give a "P" attribute since that's built for you
241  /// automatically.
242  /// - vertex[24]
243  /// Vertex attributes are defined per-vertex of each face
244  /// - uniform[6]
245  /// Uniform attributes are defined per face
246  /// - detail[1] @n
247  /// Detail attributes are uniform over all faces of the geometry
248  static GT_PrimitiveHandle box(GT_BuilderStatus &err,
249  const UT_BoundingBox &box,
251  /// Build a curve mesh for the given bounding box.
252  /// - At the current time, vertex/varying attributes are not supported and
253  /// are interpreted as uniform/detail attributes. In the future, they
254  /// may be defined differently.
255  /// - uniform[1]/detail[1] @n
256  /// Detail & uniform attributes are uniform over all faces of the geometry
257  static GT_PrimitiveHandle wireBox(GT_BuilderStatus &err,
258  const UT_BoundingBox &box,
260 
261  /// Build a sphere.
262  /// - varying[1], vertex[1], primitive[1], detail[1]
263  /// All storage classes should have a single entry
264  static GT_PrimitiveHandle sphere(GT_BuilderStatus &err,
267  /// Build a circle.
268  /// - varying[1], vertex[1], primitive[1], detail[1]
269  /// All storage classes should have a single entry
270  static GT_PrimitiveHandle circle(GT_BuilderStatus &err,
271  const GT_TransformHandle &transform,
273  /// Build a tube.
274  /// - varying[1], vertex[1], primitive[1], detail[1]
275  /// All storage classes should have a single entry
276  static GT_PrimitiveHandle tube(GT_BuilderStatus &err,
277  const GT_TransformHandle &transform,
278  fpreal taper,
279  bool caps,
281  /// Build a hyperboloid sheet
282  /// - varying[1], vertex[1], primitive[1], detail[1]
283  /// All storage classes should have a single entry
284  static GT_PrimitiveHandle hyperboloid(GT_BuilderStatus &err,
285  const GT_TransformHandle &transform,
286  const UT_Vector3D &p0,
287  const UT_Vector3D &p1,
289 
290  /// Build trim curves.
291  /// - The @c curves_per_loop array should be nloops long. The number of
292  /// curves (@c ncurves) is the sum of the entries in this array.
293  /// - The @c points_per_curve array should be @c ncurves long (i.e. one
294  /// entry for each individual curve)
295  /// - The @c curve_orders array should be @c ncurves long
296  /// - The @c knots array should have
297  /// <tt>sum(points_per_curve) + sum(curve_orders)</tt> entries
298  /// - The @c min and @c max arrays should be @c ncurves long
299  /// - The @c uvw array should be @c sum(points_per_curve) entries long
300  static GT_TrimNuCurves *trimcurves(GT_BuilderStatus &err,
301  int nloops,
302  const int *curves_per_loop,
303  const int *points_per_curve,
304  const int *curve_orders,
305  const fpreal *knots,
306  const fpreal *min,
307  const fpreal *max,
308  const UT_Vector3D *uvw);
309 };
310 
311 #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:277
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