Despite the name, iRacing is not for iOS devices. Actually it’s quite the opposite — iRacing is a realistic racing simulator on PC for hardcore fans of the racing genre. The game, which has typically relied on wheel or joystick input, has been updated for tilt and touch control by Ultrabooks with built-in sensors. iRacing developer David Tucker walks us through the dev process.
While mobile game developers are quite familiar working with orientations and touch, the advent of such sensors on mainstream PCs is relatively new and comes with the wave of recentconvertibles.
David Tucker, who’s been working on iRacing for four years (and been developing much longer), breaks down his approach to enabling touch and tilt controls in a recent article over at Intel’s Software blog.
Tucker says that bringing touch controls to iRacing had an unintended bonus:
Historically, iRacing relied heavily on keyboard and joystick input and left the mouse (and touch screen) on the side. Adding touch had the added benefit of enhancing the experience for all users by providing better mouse support in the user interface.
Tucker says that iRacing can now be controlled without the user ever needing a keyboard, thanks to the touchscreen. This means Ultrabook convertible users won’t have to switch back and forth between tablet and laptop mode to play.
The tilt control scheme for iRacing maps the throttle to the forward and backward tilt and the steering to left and right tilt. The result is that the user spins the Ultrabook convertible like a steering wheel to turn one way or the other. I’m interested to know how this scheme would stack up against other inputs like a steering wheel peripheral.
There’s more to adding tilt controls than slapping in some extra code. Because of the range of hardware options, developers need to be careful about making any assumptions of orientation.
“The biggest design issue with tilt was never knowing how users are going to pick up their devices. On top of that, the orientation sensors are located in different parts of the device and at different orientations depending on if it is a tablet, laptop, or convertible. In the end, I came up with a system that worked quite well. My solution was to calibrate the system based on the initial orientation when users turned iRacing on, and provide a simple ‘zero’ button on the display to allow them to shift their grip at any time while playing. Users can twist the laptop or tablet like a steering wheel almost a full 180 degrees to the left or right and still use 90 degrees of rotation forwards and back to accommodate the throttle. The other design hurdle was that tilting the device makes it difficult to keep your eye on the display, so I discovered there’s a trade-off between increased tilt sensitivity and decreased screen visibility,” Tucker wrote.
Windows 8 brings better orientation functionality which fuses data from multiple sensors for more stable values. For the iRacing implementation, Tucker specifically needed angle values and came across the atan2() function. He provides an explanation and sample code (here) for anyone who needs to do the same thing
Here is a brief overview of how it works. You can find a detailed example of this in my sample code. If you assume x points to the right, y points away from the viewer, and z points up, then you can use the following equations to get the orientation. Roll is atan2(x, -z) and pitch is atan2(y, sqrt(x*x+z*z)). We feed in both the x and z vectors into our pitch measurement so that we can still detect pitch when there’s a significant amount of roll. If you combine this with code that rotates the y and z axes based on some initial reference orientation, you can eliminate any confusion about which way the sensor is mounted in your device.
There’s lots more technical talk where that came from — if you’re interested in reading further, check out Tucker’s full article.
This is a sponsored post brought to you by Intel and Ultrabooknews. All content written by Ultrabooknews. Subject area by Intel. We thank Intel for their support.