Mustang goes into augmented reality
Augmented Reality (AR) generated so much buzz in the community in the last few weeks that I had to give it a try!
I suppose most of you know what AR is, however just in case you don’t, here’s some basic facts from an Actionscript developer perspective: augmented reality uses pattern recognition to render 3D graphics on top of a video display. A pattern, also called marker, is a rectangular shape that you need to print and position in front of your camera. The stream from the camera is analyzed and the marker is used to determine the coordinate system of the world captured by the camera. This coordinate system is passed to a 3D engine which renders objects on top of the video image. Pretty simple, huh?
As far as Flash is concerned, the API for augmented reality is called FLARToolkit, which is an AS3 port of library written in Java and C done by Saqoosha. If you want to know more about this project, here’s a great intro to the subject written by Mikko Haapoja.
In most of the cool AR projects I have seen so far [1] [2] the user is supposed to hold the marker and move it around in front of the camera and the 3d object follows the marker. I had a slightly different idea: why not just leave the marker and the camera in one place and use your keyboard to move around the 3d objects?
Some time ago I posted a demo featuring a Mustang that you could drive around a desert scenery. I thought it would be cool if I could now drive it around my bedroom floor. I was very surprised how easy it was to integrate my model with FLARToolkit and Papervision3D. All I had to do was to scale and rotate the model a bit and that’s it!
The above video shows a recording of the experiment. If you have a webcam you can try it yourself. To do this, follow this instructions:
- Print the marker (You can alternatively display it on your iPhone)
- Click on this link, and choose “Allow” from the security dialog
- Point your webcam so that the marker is fully visible
- When the car is loaded (~250kb) it will appear on top of it
- Use cursor keys to drive the car and CTRL key to apply hand brake
- Have fun!
If you want to dig further here’s the source code. The whole magic is in the FlarMustang.as class. The rest of the classes are an adaptation from the FLARToolkit basic example and some classes I used for the Mustang demo.
Unrelated note. In case you are reading this post in your RSS reader, you might not have noticed that I redesigned the blog. It’s good to change from time to time! Among other stuff, there’s a new list of previous 3D experiments and new links in the blogroll, so take a look.




[...] http://www.everydayflash.com/blog/index.php/2009/03/26/mustang-augmented-reality/ [...]
Outstanding.
Great Experiment and really nice blog redesign!
Not sure you explained what augmented reality is correctly…
http://en.wikipedia.org/wiki/Augmented_reality
Awesome experiments though!
@AJ You are right. Rather than giving a general definition of AR I tried to describe what it is from a Flash developer perspective. I corrected the text to make that clear. Thanks!
Very cool experiment. Also, good job with the redesign, it looks nice.
[...] with a Mustang). It’s much more dynamic that most cases where it just shows a static 3D object. Just like the creator notes: “In most of the cool AR projects I have seen so far [1] [2] the user is supposed to hold the [...]
[...] Drozdz在其博客上科普了增强现实这个概念: [...]
[...] a aplicação:http://www.everydayflash.com/blog/index.php/2009/03/26/mustang-augmented-reality/ [...]
Was wondering were you’re hiding com.everydayflash.math.Vector2? I wanted to try some experiments with the source and would like to know what happening there. Thanks.
Hi! Fantastic post!! It looks awesome and I’m totally impressed by the physics of the Mustang! I’m building a top view race game and your physics would fit perfectly! Did you you do these physics yourself? (Math and all?) Or do you use some sort of engine? (I played around with your papervision3D Mustang… It feels great! Any tips on the physics part would be awesome!
Thanks anyway for the great inspiration! (Almost makes me want to build a 3D race game instead of 2D top view…)
John
@John – I did the physics myself, because with Papervision & FLARToolkit there’s not much computing power left for a full blown simulation. So what I did is very simple and rather not very accurate.
Thanks for coming back to me that quick, Bartek! I can imagine what that stuff does to your cpu(‘s) indeed… ;-)
For my game it doesn’t have to be like a simulation. More of an arcade kind of style, so your physics will fit just fine! Any recommendations for understanding / learning this kind of math / physics? It’s very interesting, but kind of hard for me to grasp…
Thanks again for sharing this with us!
That is a very cool effect. I’ve gotta try it. Thanks!
Hi i was wondering if you had any tutorials to show me how to use the mustang files i have downloaded?
Thanks
@Glyyn I don’t have any tutorial as such – I only published the source code. Please also check the other post about the mustang: http://www.everydayflash.com/blog/index.php/2009/02/13/car-simulation-with-maya-papervision3d/ There are some additional details of how it works.