Incrementally Changing the Point of View

The functions described in the previous section let us define the POV at an absolute position and orientation in 3D world space. Fastgraph includes six additional functions that let you define the POV relative to its current state. For instance, you can call fg_3Dmoveforward() to advance the POV a given amount in whatever direction the viewer is facing. These incremental POV functions are especially useful for creating 3D walkthroughs, where you'll probably want to adjust the viewer's position or orientation in response to keyboard or mouse input.

The fg_3Dmoveforward(), fg_3Dmoveright(), and fg_3Dmoveup() functions incrementally adjust the viewer's position, but not the orientation. Each function takes a single floating point parameter that specifies the number of 3D world space units to move. Passing a negative value results in movement in the opposite direction (for example, fg_3Dmoveforward(-1.0) moves backward one world space unit). It is important to note that the movement always occurs relative to the viewer's position, not relative to the world space origin. In other words, fg_3Dmoveright() doesn't necessarily move the viewer along the positive x axis. Rather, it causes everything you see to move to the left.

The fg_3Drotateright(), fg_3Drotateup(), and fg_3Droll() functions incrementally adjust the viewer's orientation, but not the position. Each function takes a single integer parameter that specifies the rotation angle in tenths of degrees (for example, 900 means 90 degrees). Passing a negative angle to fg_3Drotateright() or fg_3Drotateup() results in rotation in the opposite direction. (for example, fg_3Drotateright(-50) rotates five degrees to the left). For fg_3Droll(), a positive angle rotates what is in front of the viewer clockwise, while a negative angle rotates counterclockwise. Like the incremental movement functions, the rotation always occurs relative to the viewer's orientation, not relative to the world space origin. Note that the incremental rotation functions let you perform the rotation in any order needed, whereas fg_3Dpov() always applies the x rotation first, then the y rotation, and finally the z rotation.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.