Game Development Reference
In-Depth Information
Defining these sorts of relationships between measurements can become tricky, so it's useful to establish
a common basis for measurement that expresses every measurement. In CycleBlob, the common basis
for all length- and size-related measurements is the average distance between two adjacent vertices of the
grid. This distance, call it Dv, gives a good estimate of the scale of the grid model and is useful for
measuring other objects.
The bike should be approximately 4*Dv
The height of the wall left behind the bike should be 2*Dv units and its width 0.2*Dv
The speed of the bike should be 1.5*Dv per second
Part of the pre-processing stage for a grid model is measuring Dv and setting an absolute value to all
these constants.
Animation timing
We now know that the bike speed is given as units of length per second. However, the T parameter
discussed earlier is a unitless number between 0 and 1. To determine the amount needed to advance T,
we need to know:
The distance between vertices A and B on the grid. This is easy to compute using the grid mesh.
We'll call this d(A,B)
The amount of time that has passed since the last update. We'll call this ∆t (delta-t).
The amount we need to increase T is determined by:
∆T = (speed * ∆t) / d(A,B)
(speed * ∆t) gives the distance the bike travels in ∆t divided by d(A,B) we get the distance normalized to
the range of [0,1]. If we sort out the units of the elements in this assignment, we see that indeed, ∆T is a
unitless measure, like T itself. Notice that there are two “delta tees” here. ∆t is the amount of time that
passed while ∆T is the difference in the animation T parameter.
The ∆T formula takes into consideration the exact amount of time that passed and the exact distance
traveled since the last update. Taking these variables into consideration is essential for achieving smooth
animation in which the bike looks like it is traveling at a constant speed. A simpler approach that was used
in an early version of the game was to just set ∆T to a constant value, say 0.5. This basically means that in
every update, the bike traverses half of the edge it is currently on. The simplicity of this approach,
however, creates two problems:
A variation exists in the edges lengths across the grid. For instance, in the cube model, the edges
at the center of the cube faces are longer than those at the corners of the cube. Setting ∆T to a
constant 0.5 means that it takes two updates to traverse any edge, no matter where it is. This
makes the bike move faster on a long edge and slower on a short edge. This becomes most
noticeable when two bikes ride parallel to one another, one in the center of the cube and one on
the side of the cube. The bike in the center looks like it travels faster. Another effect of this issue
is that the player's bike looks like it changes its velocity as the length of the edges changes.
When it reaches longer edges, the speed seems to increase, and on shorter edges, decrease.
 
Search WWH ::




Custom Search