archive: Rapid prototyping for the Wiimote using Blender|
Posted on Saturday, March 03 @ 23:16:43 CET by julian
While here at Georgia Tech I'm giving a class on the development of 'expressive games', and for the purpose I chose Nintendo Wiimotes as the control context for class designs. The final projects will be produced in Blender, using the Blender game engine.
To get them started I've developed a couple of basic interfaces between the Wiimote and Blender. They're intended to be used as skeleton files for building up rich Wiimote aware content in Blender quickly.
Read on for more including code and Blender files:
Only having Windows machines at my disposal at Georgia Tech, I developed a basic Python script that receives acceleromoter data and button events sent from GlovePIE using Open Sound Control (which is natively supported by that application), into Blender. I decided to go this way rather that create a bluetooth interface inside Blender for two reasons: GlovePIE is a great environment for building useful control models from raw input, it supports the network capable protocol OSC and I wanted to keep input-server like code out of Blender (for reasons you'd understand if you used Python in Blender).
The Blender file I created will receive all button events, force and tilt data. The IR stuff should be fairly easily plugged in but hasn't yet been tested. Here's a script written by the author of GlovePIE that's known to work.
Getting started with the Wiimote and Blender on Windows:
Grab a Bluetooth dongle and ideally the BlueSoleil BT stack as the default Windows stack is basically broken, especially with the Wiimote. You'd need to find two files on Windows however in order to ensure the Windows stack isn't going to get in the way:
bth.pnf and rename them or (re)move them. Reboot.
Download GlovePIE and unpack.
Make a new directory and download this Blender file into that directory.
Download Wiretap's Python OSC implementation and unpack it into the same directory as above.
Download this GlovePIE script into the same directory.
Start up BlueSoleil and ensure the Wiimote is connected using the BlueSoleil interface.
Start up GlovePIE, load in the script and hit 'Start'. You should see values changing in a field at the top right of GlovePIE.
Start up Blender and load in the file wiimote_glovePIE.blend. Hit the 'P' key to play. If you get errors, or Blender freezes, it's because either OSC isn't being found or GlovePIE isn't sending data.
I like to work in a Linux environment wherever possible, so wasn't happy with not having a Wiimote 'driver' on Linux that sent OSC data. I looked into various options for getting control data from a few different drivers out over OSC and into Blender. Preferring to work in Python, I tried WMD but found it too awkward to develop with, although it is nothing short of comprehensive. I finally settled on the very neatly written (Linux only) libwiimote and wrote a simple little application in C to provide what I need. Here are the steps to getting up and running in Linux:
Ensure you have support for Bluetooth on your system. I use Bluez. Plug in a BT dongle (or enable on your laptop) to check. Most modern Linux distributions support the popular BT dongles out-of-the-box.
Download Wiretap's Python OSC implementation and unpack it into Python2.4's 'site-packages' directory (or into the same directory containing the Blender file you download (see below)) on the machine your game's running on. This is usually the same machine but doesn't have to be.
Download wiiOSC, an little application I wrote that simply turns Wiimote data into OSC data and sends it to a specified computer, whether that be the same computer you're using the Wiimote on or a computer on the Internet.
Note the MAC addr of your wiimote (use
Invoke wiiOSC as follows:
wiiOSC MAC remote_host port
For instance, to send wiimote data to a machine with the IP 192.168.1.102 on port 4950, I:
wiiOSC 00:19:1D:2C:31:E1 192.168.1.102 4950
To send wiimote data to the same machine I'm using the Wiimote on, I'd:
wiiOSC 00:19:1D:2C:31:E1 localhost 4950
Start up Blender on the machine your game's on, load in this file and hit 'P' to play.
I'll update the Linux Blender file in the next couple of days to demonstrate how IR can be used in Blender.