What Is a Curve?

text only
 
progress indicator progress indicator progress indicator progress indicator

Swept Surfaces

Swept surfaces could also be called extruded surfaces or loft surfaces. A swept surface is created when you sweep a shape along a path. Unlike a surface of revolution, the cross-section of a swept surface remains constant as you sweep along the path . This is analogous to pasta or any other material that is extruded with a constant cross-section. Figures 10.6 and 10.7 show how a shape and cross-section result in a swept surface.


Figure 10.6: The path and cross-section of a swept surface.

Figure 10.7: The resulting surface.

Mathematically, these surfaces are exactly the same as every NURBS surface you've seen, but I've set up the control net differently. Instead of a 2D grid of control points, swept surfaces are defined by two distinct curves. One curve is the cross section and the other is the path, as shown in Figure 10.6.

Note 

I just finished making the point that the general NURBS patch was more flexible than a specialized representation. Now, I am introducing a special representation. Once I explain the basic idea, I will address this inconsistency and tell you how to formulate a more general approach.

In this example, I have set up the control points such that the cross section is defined by the u parameter and the path is defined by v. The vertex is also set up differently. The number of control points is now the sum of the u and v points instead of the product.

 #define NUM_TOTAL_VERTICES (NUM_U_POINTS + NUM_V_POINTS +                             NUM_PATCH_VERTICES * NUM_PATCH_VERTICES) 

FillPatchBuffer also operates differently. For each value of u and v, the code now finds the position of each vertex as defined by the cross section shape and then adds that to the position as defined by the path. The fact that the cross section is always the same, allows you to rearrange calculations to be more efficient. Look at the source code for Chapter10, Swept Surfaces, to see how I rearranged the code. Other optimizations are available, but I kept changes minimal. The following is a small snippet of the code.

 pVertices[Current].x += (NumeratorU * pVertices[ControlIndexU].x / DenominatorU)                         + (NumeratorV * pVertices[ControlIndexV].x /                            DenominatorV); pVertices[Current].y += (NumeratorU * pVertices[ControlIndexU].y / DenominatorU)                         + (NumeratorV * pVertices[ControlIndexV].y /                            DenominatorV); pVertices[Current].z += (NumeratorU * pVertices[ControlIndexU].z / DenominatorU)                          + (NumeratorV * pVertices[ControlIndexV].z /                             DenominatorV); 

In effect, this is shifting the cross section shape along the path curve. Figure 10.7 shows a simple cylinder. The cross section curve is the same at every point along the path, but it is shifted upward along the path. If the path were bent, the circular cross section would also be moved horizontally as shown in Figure 10.8.


Figure 10.8: Swept surface along a curved path.

Figure 10.8 reveals a potential weakness of a swept surface. If the path is bent, you might want the shape to be bent as well. In that case, you really want a skinned surface.

progress indicator progress indicator progress indicator progress indicator


Focus on Curves and Surfaces
Focus On Curves and Surfaces (Focus on Game Development)
ISBN: 159200007X
EAN: 2147483647
Year: 2003
Pages: 104
Authors: Kelly Dempski

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net