Game Development Reference
In-Depth Information
This coordinate system is arbitrary. If the board isn't a perfect square, such as with the
Wii board, then the coordinates of the load cells must be changed accordingly. Now that
we have defined the location of the center of the board and the position of the load cells,
we can use a weighted average to compute the location of the user's center of gravity.
The weight that we give each value will depend on how much of the user's weight is on
each of the four corners. That weight will “pull” the center of gravity toward the location
of the load cells as defined in our coordinate system. How much each load cell mathe‐
matically pulls the center of gravity will be based on the weight supported at that location.
This is most easily determined via two tables, one for the x coordinate ( Table 23-1 ) and
one for the y coordinate ( Table 23-2 ).
Table 23-1. x coordinate weighted average
Weight
Arm
Weight × Arm
(1,1)
30
1
30
(−1,1)
15
−1
−15
(−1,−1)
20
−1
−20
(1,−1)
35
1
35
Total:
100
30
Average:
30/100 = 0.30
Table 23-1 takes the weight in each corner and multiplies that value by the value of its
x coordinate. This is equivalent to a moment. Taking the sum of those moments (30)
and dividing by the total weight gives the average value of 0.30, or .3 units to the right
in our coordinate system. The y-axis is treated similarly.
Table 23-2. y coordinate weighted average
Weight
Arm
Weight × Arm
(1,1)
30
1
30
(−1,1)
15
1
15
(−1,−1)
20
−1
−20
(1,−1)
35
−1
−35
Total:
100
−10
Average:
−10/100 = −0.10
Using a similar weighted average as shown in Table 23-2 , we see that the user's center
of gravity is −0.10, or 0.1 units behind the center. If we were using this to control an
onscreen sprite, we could define a 2D direction vector based on this information.
In addition to just determining the center of gravity, you can use this information to
make educated guesses on what else the user is doing to cause the load distributions.
After computing the center of gravity, the Wii uses what Nintendo calls a motion-
identifying condition table to guess what movements the user is making. The table cor‐