Revolutionary: Going Through the Motions

Every Tuesday, Mike Sylvester brings you REVOLUTIONARY, a look at the wide world of Wii possibilities.

I was going to jump right into writing another script with you this week, but as development progressed, I remembered how much time I wasted on my first scripts because I didn't have a handle on exactly what motions were triggering the responses I was after. I figured I'd be doing you a disservice if I didn't take time out to get you primed on the nomenclature of all the motions and get you started in thinking in 3 dimensions.

Last week we wrote a simple script that didn't use the Wiimote's motion detecting functionality. Some might say that defeats the purpose of using the Wiimote, but is that really what the Wiimote is about? The different input options are there to give the developer choices. Sometimes the developer will throw in lots of alternatives and pass the choice on to the gamer. Taking every feature of the controller and slapping it onto a game isn't going to assure a fun time. More than likely, you'll wind up making something repellent that people will call "gimmicky." It's best to have an understanding of the control options available, and be selective in applying or omitting ones from your project.

The accelerometer in the Remote and Nunchuk, oddly enough, measures acceleration. Moving up and down, in and out, or side-to-side registers a change in Gs (gravitational units), which the Remote or Nunchuk can use to determine which direction it is moving. The accelerometer can detect 5 variables of motion – X, Y, and Z for acceleration, and Pitch and Roll for rotation. Going on the accelerometer functionality alone, we could tear a page from Sony's book on product naming and call it a FIVEAXIS. Calling it that would be a gross oversight of the added functionality of the IR sensor, but we'll talk more about that later.

The ranges of force the accelerometer can detect is so acute that it can even pick up the pull of the earth's gravity, so gravity plays a significant role in the working and use of it. Since there isn't much of a gaming market in outer space, developers and scripters can count on a constant reference to be under their feet, telling their controllers which way is down. Tilting the controller changes the balance and makes earth's pull stronger on one side and lighter on the other. The more that balance shifts, the more the controller knows it's being tilted.

X, Y, and Z accelerations are often used like digital buttons to trigger a response when a certain amount of force is exerted, but variable levels of force can be made to trigger different responses. In an orchestra simulation, it would be possible to detect a gentle waving of the Remote to conduct for the strings section, and put some violent emphasis into your movements when you want to bring the drums into the piece.

Controlling the amount of force put into a motion is really hard to do if you're trying to get an exact response. You won't see a lot of developers or scripters assigning 3 or more responses to any direction, because it's far less infuriating to differentiate between just "light" and "hard." When greater degrees of precision are needed, we can use the rotational axes of pitch and roll. It's very easy to judge whether you're tilting the Remote a little, a lot, or any degree in between. Likewise, it's easy to assign an analog response to rotational input. Rotation can also have digital responses at specific degrees. In a driving sim, you could start up the car by turning the "keymote" all the way forward, or just power on the radio by turning it a notch backward.

The labeling for accelerometer directions and axes is based on the Remote being held flat, with the IR sensor pointed at screen, the expansion port toward your body, and the A button facing the ceiling. Looking down at the Remote should give you the proper perspective to understand how the software perceives its motions. The accelerometer chip is mounted in on a board inside of the Remote, just slightly to the left of the A button. The pivot point would be in your wrist, so having the accelerometer so far away from there lets subtler movements be effectively amplified into a wider range of numbers. Wiimote motion detection can be extremely precise.

X-axis
Left and right acceleration of the controller on the X-axis is detected in GlovePIE using the variables RawForceX, RawAccX, RelAccX, or GX appended after the controller name variable. For example, if you wanted to simulate the excitement of pushing a lawnmower, you could use "(Wiimote.GX > 1) = var.RunOverGnome" and forever put an end to the pudgy plaster pee-wee's roaming. Motions like sword slashing and parrying, or tossing a Frisbee would register stronger responses on the X-axis.


Y-axis
Up and down motions are represented on the Y-axis. Poking or stabbing gestures would provoke a response here, and I bet the Manhunt 2 team got a lot of use out of this one. GlovePIE scripters can use RawForceY, RawAccY, RelAccY, or GY to turn Wiimotes into cue sticks for virtual billiards (but the X or Z axes would be more effective in capturing swings of the cue stick in bludgeoning simulations).



Z-axis
Holding the Remote like a roll of quarters in an unfair fist fight would have the in and out motions of your punches picked up on the Z-axis. (Can't Wii all get just along?) Moving out of the Fight Club and into the kitchen, Z-axis could also be used to chop veggies and flip omelets. RawForceZ, RawAccZ, RelAccZ, and GZ are for Z-axis detection in GlovePIE.




Pitch
Pitch is the upward or downward tilting of the controller. Twilight Princess uses it to register subtle movements in fishing. It could be combined with Z acceleration when you quickly jerk the line out of the water. In a flight sim, we could use pitch to point the nose of the plane up or down. However, holding the controller vertically like a flight stick orients the accelerometer perpendicular to the ground, and the values GlovePIE receives with using Pitch or SmoothPitch can jump from a high number to a low number, making it anything but smooth. For situations like those, we must look at other axes to get our bearings.



Roll
Side-to-side rotation is known as roll. Doing a barrel roll in an Arwing fighter or turning a doorknob would be suitable situations for using it. GlovePIE reads it with Roll and SmoothRoll.



Yaw
There's a sixth axis that aero-geeks (and PS3 Fanboys) are familiar with, but the Wii's accelerometers can't detect. Yaw is a rotational axis like pitch and roll, but because it runs parallel to the earth, it can't be measured by monitoring changes in the pull of earth's gravity. If there was an unlockable school bus in Excite Truck, we'd want to grow a mullet and use yaw for steering, to get the most authentic school bus driver feeling. Although there's no yaw detection through the accelerometers, it can be faked by using the IR sensor . Tracking X-axis IR motion, and assuming the person holding the Remote isn't running around the room, yaw rotation can be approximated by the clever scripter or developer. The trouble with that is it wouldn't work for the Nunchuk, and the Remote would have to be pointed directly at the Sensor Bar during play (so don't expect to see that school bus in Excite Truck 2). In absence of IR sensing, roll can sometimes fill in as a suitable substitute for yaw. Side-to-side movement of hand usually involves some amount of rolling at the wrist, so it can be made to feel natural detecting roll where yaw should be.

Stringing together sequences of rotations and/or accelerations makes a gesture. Detection of gestures requires the accumulation of motions over time, but that's speaking 4th-dimensionally, so we'll save that discussion for later.

This article was originally published on Joystiq.