Implementing B-Spline Code

 
progress indicator progress indicator progress indicator progress indicator

Moving Beyond Fluttering Sheets

So far, all of the surface examples have taken the form of sheets that are stretched and deformed as the control points change. This is an easy way to demonstrate the basics; not all that many game objects can be represented as rubber sheets. As a more real-world example, I have created the shape of a space ship, as shown in Figure 9.4.


Figure 9.4: NURBS space ship.

The model is not complete (there is no bottom), but it still demonstrates all of the important points. First, it's important to note that the code is exactly the same as described earlier. The only things that have changed are the positions of the control points. The code can be found on the CD under Code\Chapter09 - NURBS Patch Model, and you can find the control point positions in the FillPatchBuffer function.

Notice that the model is no longer a wavy square shape. This is because the control points are no longer arranged in a square shape. Instead, the control points along the edge are shaped into the rough outline of the ship. Figures 9.5 and 9.6 demonstrate this. First, I started with a nonuniform grid of control points. This will allow me to put more detail and control in certain areas than in others.


Figure 9.5: Basic NURBS patch with nonuniform control grid.

Figure 9.6: Basic space ship shape.

Next, the control points are moved to create the rough shape of the ship. I have disabled the height changes in this screenshot in order to emphasize the irregular shape.

Finally, the control point heights are changed to complete the ship. Figure 9.7 is basically the same shot as Figure 9.4, only now the model is drawn in wireframe so that you can see how the mesh is laid out.


Figure 9.7: Final ship in wireframe.

The final object is much closer to something you'd actually use in a game. In a real-world situation, you probably wouldn't want to model the shape by hardcoding control point positions. Instead, you might want to create your own NURBS model format or use a NURBS modeler such as Rhino. However you choose to create the model, the NURBS representation does have some advantages.

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