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.

Monday, November 26, 2007

Which he then guided

OK, this is getting cooler and cooler, after a 30-minute session of watching another tutorial and then studying the code a bit so I understood it, I was able to give the model some speed and control it's direction in the XZ plane. Very cool! XNA is growing on me, and I can definitely see how you bypass a bunch of low-level coding by having a lot of helper classes already done. Of course these will add to the overhead, but I am not aiming to make the visuals as complex as Crysis or Far Cry, so I should be OK. "Should" is the key word here.

And on the second day, he made a model rotate

My investigation into XNA is going well. I found out some good video tutorials at the XNA Creators Club. The first one showed me how to get a model in your app and rotate it. The shot to the left is of a free Ferrari model I got from Turbo Squid rotating around it's Y axis and rendering at 60 frames per second. Not too shabby, considering it took me all of three minutes to get this done, from the moment I opened Visual Studio C# Express. Now, to the next tutorial... Oh, by the way, the frame counter on the top left is Fraps.

Sunday, November 25, 2007

And yet another programming twist

I spent the day yesterday reading about the possibility MS is going to release a managed API for DirectX10. Although that is not looking very promising (even though some inside the DirectX team state they are indeed working on it), I found out that XNA support and development seems to be on the rise. XNA is Microsoft's new API for creating games for Windows and the XBOX. The fact it includes the XBOX made me think this might not be a really good platform for a tower simulator which will run in Windows, but upon further reading, it seems that there's a lot I can benefit from this API. Several things you need for creating games, such as timers, access to graphics, audio, and input hardware, networking, etc., have been standardized and made available through XNA. It looks interesting enough that I am taking a look at it today. Oh, and what impressed me quite a bit was a short video of games made with XNA that I found in Michael Klucher's blog. Michael is one of the team members at XNA Game Studio. Time to roll my sleeves up and dig in...

Saturday, November 24, 2007

Reading material

So my language of choice will be C#. I am not 100% sure this will work as far as I can tell, but I like managed code a lot and feel it deserves a go at it. The graphics API of choice is DirectX. I have worked with OpenGL a little in the past, and chose DirectX simply to try and learn something new. Since I don't really know anything about this API, I am reading a couple of books that cover both C# and DirectX. One is Beginning C# Game Programming, a book written with humor, which I appreciate, and that covers the very basics of C# and then moves into DirectX. Another is Managed DirectX 9 Kick Start. Both use DirectX in its managed API, which is still non-existent in DirectX 10. I am not sure if Microsoft will publish a managed API for the latest version of DirectX, but once again, I am trying to stick with managed code. If it doesn't work, no worries, we move on to unmanaged DirectX. The dice are rolled, let's hope it's not snake eyes!

Testing posting from my email

Cool, apparently this works well.  This should allow me to post from mobile phones, in case I become obsessed to that point...

Welcome one and all!

Well, this is it! I have decided to bite the bullet and commit to creating a tower simulator. As a pilot and former Microsoft Flight Simulator user and add-on developer, I have always felt the lack of a good ATC Tower sim since the good old BAO Tower. Couple that with my interest in programming and here we are. I don't really know what else to say, since this is my first blog, but from reading other blogs I have learned one thing: I am not going to say "I'll try to update this as frequently as possible", as that seems to be pretty much an assurance that it won't happen. So, without making any promises, check back when you can and see if there's anything new.