Sunday, July 1, 2012

Motion Controlled 3D Flight Simulator

I came across this today while going through my PC's hard drive. This is an exhibit we made back in 2010 for exhibition "Exmo" held in University of Moratuwa. It was also exhibited in Techno, Infotel and Deyata Kirula Exhibitions. This kind of things may be quite common these days. However I'm happy that this was an original idea at that time.


Since we had a limited amount of time, we had to reuse some of the segments. 3d world is mostly based on Riemer's tutorials. A 2D array is used to create the buildings of the city. Heightmap technique is used to model the terrain. It looked quite good with mixed textures, flare and water effects.



The program processes webcam feed frame by frame. We used blob counter technique along with several filters to locate an area of predefined color, with the help of AForge. The rectangle covering that area is considered and its center point is calculated. The displacement of this point relative to center of the captured screen is used to maneuver the aircraft in the game. 

Source Code


Written in C#. XNA is used as the gaming framework. AForge is used as the image processing library. I'm sharing the source hoping someone may find it useful, though its quality and readability is not very high.
Install XNA 3.1 and AForge 2.1. You should use Visual Studio 2008.


Get the source code here:
https://github.com/amilamanoj/FlightSim

Dependencies


You need Windows and following installed for this to work

  • .NET Framework 3.5
  • XNA 3.1
  • AForge 2.1

Installers 


I've made an installer with above dependencies. XNA and AForge are embedded in the installer. .NET Framework isn't embedded due to its size. It will be automatically downloaded and installed. You can get the installer here. (~50MB)


If you have these components already installed or prefer to install them manually, use this installer (~17MB)

Playing


Aircraft can be controlled using mouse, keyboard or movement of an object (or your hands with gloves).
Default controller is mouse. You can switch between controllers using Tab during gameplay. Press Q to quit during gameplay.
You can select the webcam and configure the color in options screen. Default color is red. For example, you can use a red colored plastic ball.
If you haven't played a flight simulator before, you should try playing with mouse or keyboard before trying with motion.

2 comments:

Timon berg said...

Thanks to share these details it’s truly nice.
proflightsimulator

John Cena said...

Wow this blog is wonderful i like reading your articles. Stay up thhe great work! You realize, lots of persons are looking around foor ths info, you could aid them greatly. Motion Simulator