Parametric Curves & SurfacesCurved SurfacesSlide 3Parametric SurfacesSurface of revolutionSwept surfaceSlide 7Piecewise Parametric SurfacesParametric PatchesSlide 10Let the Control Points MoveBézier PatchesParametric Bicubic PatchesBezier PatchesB-Spline PatchesBezier PatchesBezier SurfacesSlide 18Slide 19Drawing Bezier SurfacesSlide 21Bézier Curves in OpenGLDefining the Control PointsDefining the Mesh ParametersDrawing the MeshSlide 26Slide 27Next TimeBlender (www.blender.nl)Greg HumphreysCS445: Intro GraphicsUniversity of Virginia, Fall 2003ParametricCurves & SurfacesGreg HumphreysUniversity of VirginiaCS 445, Spring 2002Curved Surfaces•MotivationExact boundary representation for some objectsMore concise representation than polygonal meshH&B Figure 10.46Curved Surfaces•What makes a good surface representation?AccurateConciseIntuitive specificationLocal supportAffine invariantArbitrary topologyGuaranteed continuity Natural parameterizationEfficient displayEfficient intersectionsParametric Surfaces•Boundary defined by parametric functions:x = fx(u,v)y = fy(u,v)z = fz(u,v)•Example: ellipsoidH&B Figure 10.10sinsincoscoscoszyxrzryrxSurface of revolution•Idea: take a curve and rotate it about an axisDemetri TerzopoulosSwept surfaceIdea: sweep one curve along path of another curveDemetri TerzopoulosParametric SurfacesAdvantage: easy to enumerate points on surface.Disadvantage: need piecewise-parametric surface to describe complex shape.uvFvDFH Figure 11.42Piecewise Parametric SurfacesSurface is partitioned into parametric patches:Watt Figure 6.25Same ideas as parametric splines!Parametric Patches•Each patch is defined by blending control pointsSame ideas as parametric curves!FvDFH Figure 11.44Parametric Patches•Point Q(u,v) on the patch is the tensor product of parametric curves defined by the control pointsWatt Figure 6.21Q(u,v)Q(0,0)Q(1,0)Q(0,1)Q(1,1)Let the Control Points Move•Call the Bézier parameter v, and let the N+1 control points depend on some other parameter u:•Each “u-contour” is a normal Bézier curve, but at different u values, the control points are at different positions•Think of the surface as a changing Bézier curve sweeping through space•How do the control points change? NkNkkvBupvup0,Bézier Patches•Let’s allow the control points to move along their own Bézier curves:•Putting this together with our original definition of our surface, we get the tensor product form for the Bézier patch: NiNikikuBpup0, MiNkNkMikivBuBpvup0 0,,Parametric Bicubic PatchesPoint Q(u,v) on any patch is defined by combining control points with polynomial blending functions:TTVMUM4,43,42,41,44,33,32,31,34,23,22,21,24,13,12,11,1),(PPPPPPPPPPPPPPPPvuQWhere M is a matrix describing the blending functionsfor a parametric cubic curve (e.g., Bezier, B-spline, etc.) 123uuuU 123vvvVBezier PatchesVMUMTBezierBezier4,43,42,41,44,33,32,31,34,23,22,21,24,13,12,11,1),(PPPPPPPPPPPPPPPPvuQFvDFH Figure 11.420001003303631331Be zierMB-Spline PatchesVMUMTSplineBSplineB 4,43,42,41,44,33,32,31,34,23,22,21,24,13,12,11,1),(PPPPPPPPPPPPPPPPvuQWatt Figure 6.28061326102102102112161212161SplineBMBezier Patches •Properties:Interpolates four corner points Convex hullLocal controlWatt Figure 6.22Bezier Surfaces•Continuity constraints are similar to the contraints for Bezier splinesFvDFH Figure 11.43Bezier Surfaces•C0 continuity requires aligning boundary curvesWatt Figure 6.26aBezier Surfaces•C1 continuity requires aligning boundary curves and derivatives (a reason to prefer subdiv. surf.)Watt Figure 6.26bDrawing Bezier Surfaces•Simple approach is to loop through uniformly spaced increments of u and vDrawSurface(void) {for (int i = 0; i < imax; i++) {float u = umin + i * ustep;for (int j = 0; j < jmax; j++) {float v = vmin + j * vstep;DrawQuadrilateral(...);}}}DrawSurface(void) {for (int i = 0; i < imax; i++) {float u = umin + i * ustep;for (int j = 0; j < jmax; j++) {float v = vmin + j * vstep;DrawQuadrilateral(...);}}}Watt Figure 6.32Drawing Bezier Surfaces•Better approach is to use adaptive subdivision:DrawSurface(surface) {if Flat (surface, epsilon) {DrawQuadrilateral(surface);}else {SubdivideSurface(surface, ...);DrawSurface(surfaceLL);DrawSurface(surfaceLR);DrawSurface(surfaceRL);DrawSurface(surfaceRR);}}DrawSurface(surface) {if Flat (surface, epsilon) {DrawQuadrilateral(surface);}else {SubdivideSurface(surface, ...);DrawSurface(surfaceLL);DrawSurface(surfaceLR);DrawSurface(surfaceRL);DrawSurface(surfaceRR);}}Uniform subdivisionAdaptive subdivisionWatt Figure 6.32Bézier Curves in OpenGL•Use evaluators•glMap defines the set of control points•glMapGrid defines how finely to evaluate the surface•glEvalCoord/glEvalMesh cause the mesh to be drawnDefining the Control Points•glMap2 [df](target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points ) target specifies what OpenGL command will be executed when this mesh is evaluated, and what’s in the control mesh. For drawing, usually use GL_MAP2_VERTEX3u1,u2,v1,v2 define a mapping from values passed to glEvalCoord to (0,1), the domain of the Bézier functionsustride, vstride indicate how the data is packed in the arrayuorder, vorder define the dimensions of the point arraypoints is the actual data•glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlpoints1[0][0][0]);Defining the Mesh Parameters•glMapGrid specifies how the mesh will be evaluated based on the control points•glMapGrid2[df](un, u1, u2, vn, v1, v2 )un, vn define the number of partitions at which to evaluate the surfaceu1,u2, v1,v2 define the range of grid variables•glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0);Drawing the Mesh•We can draw the whole mesh at once with glEvalMesh•glEvalMesh2(mode, i1, i2, j1, j2 )mode specifies points, lines, or polygonsi1,i2,j1,j2 define the range over which to evaluate the mesh•glEvalMesh2(GL_LINE, 0, 20, 0, 20);Drawing Bezier Surfaces•One problem with adaptive subdivision is avoiding cracks at boundaries between patches at different subdivision levelsAvoid
View Full Document