1Greg HumphreysCS445: Intro GraphicsUniversity of Virginia, Fall 2003ParametricCurves & SurfacesGreg HumphreysUniversity of VirginiaCS 445, Spring 2002Curved Surfaces• MotivationD Exact boundary representation for some objectsD More concise representation than polygonal meshH&B Figure 10.46Curved Surfaces• What makes a good surface representation?D AccurateD ConciseD Intuitive specificationD Local supportD Affine invariantD Arbitrary topologyD Guaranteed continuity D Natural parameterizationD Efficient displayD Efficient intersectionsParametric Surfaces• Boundary defined by parametric functions:D x = fx(u,v)D y = fy(u,v)D z = fz(u,v)• Example: ellipsoidH&B Figure 10.10φθφθφsinsincoscoscoszyxrzryrx===2Surface 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!3Parametric 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,() ()()∑∑===MiNkNkMikivBuBpvup00,,4Parametric Bicubic PatchesPoint Q(u,v) on any patch is defined by combining control points with polynomial blending functions:TTVMUM=4,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.)[]123uuu=U[]123vvv=VBezier PatchesVMUMTBezierBezier=4,43,42,41,44,33,32,31,34,23,22,21,24,13,12,11,1),(PPPPPPPPPPPPPPPPvuQFvDFH Figure 11.42−−−−=0001003303631331BezierMB-Spline PatchesVMUMTSplineBSplineB−−=4,43,42,41,44,33,32,31,34,23,22,21,24,13,12,11,1),(PPPPPPPPPPPPPPPPvuQWatt Figure 6.28−−−−=−061326102102102112161212161SplineBMBezier Patches • Properties:D Interpolates four corner points D Convex hullD Local controlWatt Figure 6.225Bezier Surfaces• Continuity constraints are similar to the contraints for Bezier splinesFvDFH Figure 11.43Bezier Surfaces•C0continuity requires aligning boundary curvesWatt Figure 6.26aBezier Surfaces•C1continuity requires aligning boundary curves andderivatives (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(...);}}}Watt Figure 6.326Drawing 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);}}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 )D targetspecifies what OpenGL command will be executed when this mesh is evaluated, and what’s in the control mesh. For drawing, usually use GL_MAP2_VERTEX3D u1,u2,v1,v2 define a mapping from values passed toglEvalCoord to (0,1), the domain of the Bézier functionsD ustride, vstride indicate how the data is packed in the arrayD uorder, vorder define the dimensions of the point arrayD points 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 )D un, vn define the number of partitions at which to evaluate the surfaceD u1,u2, v1,v2 define the range of grid variables• glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0);7Drawing the Mesh• We can draw the whole mesh at once with glEvalMesh• glEvalMesh2(mode, i1, i2, j1, j2 )D mode specifies points, lines, or polygonsD i1,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 these cracks by adding extra vertices and triangulatingquadrilaterals whose neighbors are subdivided to a finer level.CrackWatt Figure 6.33Parametric Surfaces• Advantages:D Easy to enumerate points on surfaceD Possible to describe complex shapes• Disadvantages:D Control mesh must be quadrilateralsD Continuity constraints difficult to maintainD Hard to find intersections Next Time• Subdivision Surfaces8Blender
View Full Document