Sunday, December 30, 2007

The target flight model

Being an aerospace engineer, I will be interested in reproducing some very faithful flight models for the aircraft in this simulation. One of the things I hate about some simulators I have seen is how artificial their flying has been. A good way to see this is on takeoffs or landings, where, more often than not, a plane will basically switch game states from "plane.state(runningDownTheRunway)" to "plane.state(liftOff)" to "plane.state(climb)". This works fine, but the visual result is the plane snapping from being straight and level, accelerating down the runway, to 10 or so degrees of nose-up, to suddenly climbing out. There's no transition in between, so it looks fake.

My aim is to actually have a somewhat detailed flight model for each aircraft, which is something the guys at Eagle Dynamics did for Lock On: Modern Air Combat. Their AI traffic actually uses a slightly dumbed down version of the highly detaild flight model the user aircraft has. That means takeoffs, landings, and every other phase of flight look very real (they even improved on this in Flaming Cliffs by pretty much using the detailed flight model from LOMAC for AI, and going even deeper for the user aircraft).

A good simulation of flight models that is out there is X-Plane. Here's how Austin Meyer describes the process:

X-Plane reads in the geometric shape of any aircraft and then figures out how that aircraft will fly. It does this by an engineering process called "blade element theory", which involves breaking the aircraft down into many small elements and then finding the forces on each little element many times per second. These forces are then converted into accelerations which are then integrated to velocities and positions... of course, all of this technical theory is completely transparent to you... you just fly! It's fun!

X-Plane goes through the following steps to propagate the flight:

1: Element Break-Down
Done only once during initialization, X-Plane breaks the wing(s), horizontal stabilizer, vertical stabilizer(s), and propeller(s) (if equipped) down into a finite number of elements. The number of elements is decided by the user in Plane-Maker. Ten elements per side per wing or stabilizer is the maximum, and studies have shown that this provides roll rates and accelerations that are very close to the values that would be found with a much larger number of elements.

2: Velocity Determination
This is done twice per cycle. The aircraft linear and angular velocities, along with the longitudinal, lateral, and vertical arms of each element are considered to find the velocity vector of each element. Downwash, propwash, and induced angle of attack from lift-augmentation devices are all considered when finding the velocity vector of each element.
Propwash is found by looking at the area of each propeller disk, and the thrust of each propeller. Using local air density, X-Plane determines the propwash required for momentum to be conserved.
Downwash is found by looking at the aspect ratio, taper ratio, and sweep of the wing, and the horizontal and vertical distance of the "washed surface" (normally the horizontal stabilizer) from the "washing surface" (normally the wing), and then going to an empirical look-up table to get the degrees of downwash generated per coefficient of lift.

3: Coefficient Determination
The airfoil data entered in Part-Maker is 2-dimensional, so X-Plane applies finite wing lift-slope reduction, finite-wing CLmax reduction, finite-wing induced drag, and finite-wing moment reduction appropriate to the aspect ratio, taper ratio, and sweep of the wing, horizontal stabilizer, vertical stabilizer, or propeller blade in question. Compressible flow effects are considered using Prandtl-Glauert, but transonic effects are not simulated other than an empirical mach-divergent drag increase. In supersonic flight, the airfoil is considered to be a diamond shape with the appropriate thickness ratio... pressures behind the shock waves are found on each of the plates in the diamond-shaped airfoil and summed to give the total pressures on the foil element.

4: Force Build-Up
Using the coefficients just determined in step 3, areas determined during step 1, and dynamic pressures (determined separately for each element based on aircraft speed, altitude, temperature, propwash and wing sweep), the forces are found and summed for the entire aircraft. Forces are then divided by the aircraft mass for linear accelerations, and moments of inertia for angular accelerations.

5: Get Back to Work
Go back to step 2 and do the whole thing over again at least 15 times per second. Aren't computers great?

This is pretty much the approach I am planning on implementing.

XNA beta is not the same as XNA final

Doh! I was trying to run two very interesting samples found at the XNA Creators Club and was having problems. The build was, for some reason, not building the Content, and this was straight out of the .ZIP. Strange. So I posted on the Creators Club forum, and Shawn came to the rescue, as well as a couple of other people, including Neil Pryde and Machaira (otherwise known as Jim Perry).

Turns out no one had heard of such a problem. Shawn posted a very helpful, step-by-step troubleshooting that lead to some textual output from Visual C# Express, which he was going to look through, but as I sat at the Appleton Airport and worried about the weather, lightning struck: I was still using XNA 2.0 Beta. Could it be? So I paid $7 for a day's access to their WiFi (when will we have free WiFi like we have free drinking water?), downloaded the final release, uninstalled beta, installed final, restart, F5, and....VOILA! It worked!

I feel embarrassed I didn't think of this before. So if you are out there, having the same problem, that's the solution. I am still not clear what the culprit was inside the beta, but I have decided to move on and continue learning XNA.

Friday, December 28, 2007

My legs are fine!

Hard to believe, but I have survived both downhill as well as cross country ski without getting hurt! That's not to say my body doesn't hurt.

I am going back home today, getting back in the swing of things. I got up really early this morning and spent a couple of hours getting to know Shawn. I am really impressed with his background, but even more impressed by the amount of posts he has written, as well as samples in the XNA Creators Club. His expertise is incredible (he's of MotoGP fame), but even better, it seems he writes exactly about the things I want to know of. I think I have become addicted to his blog.

I heard of Shawn when he responded (in less than 15 minutes) to my first post in the XNA Creator's Club forum. I am having issues running some of the samples posted there, and Shawn is trying to help.

It will be nice to get back home and start doing a little more coding and modelling. I am also going to start planning exactly what road the development will take, with target milestones, not as much as dates, but as acomplishments.

I am liking XNA more and more.

Tuesday, December 25, 2007

Bah, Humbug!

Merry Christmas, Happy Kwanza, Happy Hanukka, so overall Happy Holidays to all. Here's where I am for the season, skiing for the first time. Wish my legs good luck!

The book I was using to learn XNA was written for XNA 1.0. I have switched to 2.0, which came out not long ago, and am re-learning some of the basics, since even some of the infastructure setup automatically when you create a Windows Game project has changed. Big ups to the guys behind XNA Game Studio, the help files are very well written. I know how hard it is to write documentation to go along with your development, so congrats on a job well done!

I have also been spending time learnign 3DS Max, as I am going to create all of my 3D models myself. The textures are still an unkown at this time, but we'll see.

Season greetnigs,

Sunday, December 9, 2007

I am now a librarian

That's because I have now started to move some helper game components to a library (DLL) and use it as a resource in the game project. Things like user input, cameras, a framerate counter are all in there, and I'll keep adding. Pretty cool, and very effective, as well as organized.

Monday, December 3, 2007

Sunday, December 2, 2007

Visiting the capital (and Capitol)

I am in Washington, DC this weekend, for the first time. My parents came in to visit and we took a trip down. Today my Dad and I went to the National Air & Space museum. Wow. They even have SpaceShipOne hanging above the main entrance. I will upload pictures to Flickr and post a link here. Phenomenal stuff.