Part One: Focus on Basics

text only
 
 
progress indicator progress indicator progress indicator progress indicator

Extending the Basic Application to 3D

The previous chapters featured 2D curves drawn in a 2D environment. Now that I have moved onto 3D surfaces, I need to rework the application to be able to show these surfaces. Like most of the basic concepts in this chapter, this framework is not specific to Bezier surfaces and will remain the same for all surface examples.

The parent class for each of the surface examples is CPatchApplication , which replaces the 2D CCurveApplication used in previous chapters.

It sets up the World, View, and Projection matrices needed for 3D rendering and extends the grid to a full 3D box. Figure 7.8 shows a screenshot of the basic environment. The dimensions of the box were arbitrarily chosen to be 500 units on a side.


Figure 7.8: The basic application environment.

This class also has some basic controls for changing the viewpoint. The camera is always pointed at the center of the cube, but the left and right arrows rotate around the center. The up and down arrows increase and decrease the camera's height. I have tried to set up the application framework in a way that allows you to totally ignore the intricacies of the 3D environment (matrices, and so on), but you might want to experiment with different viewpoints or controls. Also, I have chosen movement values that work well on my system. If you find that the viewpoint changes too slow or too fast, you can alter the speed by changing the following values in PatchApplication.cpp in any of the surface projects.

 #define HEIGHT_DELTA 20.0f #define ORBIT_DELTA 0.1f 

I have not included a full discussion of the code in the interest of space. If you are comfortable with 3D rendering in general, you will find that the code is very straightforward. If you are not comfortable, you can ignore the framework entirely and focus on rendering the 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