Game Development Reference
In-Depth Information
one of the four neighbors is acceptable. One of the neighbors of B is the vertex we just came from, A, and
it can't be reached again because the bike can't turn 180 degrees on its axis.
Knowing where neighbor A is, we can start going clockwise around B and find the vertex that we will turn
to if the user turns to the left. Going clockwise again, we find the vertex to go to if the bike just continues
forward. Going a third time clockwise around B brings us to the vertex we'll choose if we want to make a
right turn (see Figure 8-15). With the proper pre-processing performed on the mesh data, selecting the
next vertex with this procedure consists of just a few array lookups and doesn't require multiple vector
math operations like subtraction and dot products. This optimization may seem redundant when we need
to find the next vertex for only two to six bikes, but it becomes significant for the artificial intelligence
module that often looks 20 or 30 steps ahead before making the decision to turn the bike.
Figure 8-15. Selecting the next vertex to move to from B when there are only four neighboring vertices is done by going
clock-wise around B from neighbor to neighbor, starting with neighbor A.
Speed and measurements
An issue that I've yet to address is units of measurement. What are the units for distance and velocity in a
3D scene? Are we dealing with meters? Inches? Pixels? It doesn't really matter because everything is
relative. We can think of the numbers we pass around the application in whatever measurement system
we want. The only thing that does matter is the relationships between sizes in the scene. The ratio
between the grid size, bike size, and bike speed, for instance, should remain constant. Otherwise, the bike
may appear disproportionate to the grid and it may travel slower or faster than what the level designer
intended. Say the grid is a cube with a total length, depth, and height equal to 50 units (meters, inches—
doesn't matter) and the vertices of the grid are 2.5 units apart. If that is the case, I'd like the bike to
measure 10 units of length and the speed to be 3.75 units per second.
 
Search WWH ::




Custom Search