Popular contentToday's:All time:NavigationUser login |
Controling Papervision 3D with Ninitendo Wiimote in Flii
Theres been a lot of action occurring in Flash / Wiimote integration while I was away on holiday. A couple of other projects have sprung up. Firstly WiiFlash Seems to be a collaboration between Joa and Thibault Imbert of ByteArray.Org. Ive been following the crazy experiments coming out of byteArray, and Joa's work on the Imageprocessing Library, is very impressive, so i'm very much looking forwards to seeing what these two produce.
Secondly we have FWiidom.org Setup by Adam of Dusty Pixels. Hopefully myself and Adam will be merging our systems together over the next few weeks, and producing a cross platform solution. so this should be the final version of Flii.
Converting the Focus example to FliiTo get the current papervision Focus example working with Flii is pretty simple, requiring only two changes to the existing code. Firstly, all key handling code is removed from driveCar. The new version is simply,
private function driveCar():void
{
speed -= ( speed - topSpeed ) / 10;
steer -= ( steer - topSteer ) / 2;
}
Then two Flii handlers are written. Here we want to translate movement with the nunchuck joystick to movement of the car, while wiimote position will alter camera angle. Our handlers are,
//flii handlers
private function onAC(e:FliiEvent):void {
if (e.data["type"] == 0) {
smoothX +=e.data["x"];
smoothY +=e.data["y"];
smoothCount++;
if (smoothCount == 5) {
smoothX /= 5;
smoothY /= 5;
camera.z += (128 - smoothX) *4;
camera.y += (128 - smoothY) *4;
smoothX = 0;
smoothY = 0;
smoothCount = 0;
}
}
}
private function onJOY(e:FliiEvent):void {
topSpeed = e.data["y"]-128;
topSteer = e.data["x"]-128;
//Flii.fliiData(topSteer.toString());
}
onAC is fired when Acceleration data is received, both the nunchuck and wiimote transmit this data, so a type variable is transmitted, which s checked first to ensure only the wiimote is processed. Here the data is also smoothed by averaging 5 values, this works very well, and will be moved out of the AS code in the next version, and into the driver code.
onJOY, receives events from the nunchuck joystick position. Here X and Y values are translated directly into forwards/backwards motion (y) and steering (x).
Finally we grab an instance of flii, and add our event handlers:
flii = Flii.getInstance();
flii.addEventListener("onAC",onAC);
flii.addEventListener("onJOY",onJOY);
Heres a little video demo of the modified file in action. You can also see the current flii framework, which consists of FLEX based app, and some wiimote monitoring panels. If any body is interested in playing with this Mac only version drop me a mail for copy.
|
copy of flii
I'm very interested in a copy of the current flii framework! Starting April 2007 I'll be teaching at the Brunswick School of Art in northern Germany (Design Dept. Institute for Media Research) and I'd love to utilize the flii framework in my students courses and share the results.