|
It's always been my dream to write my own flight simulator from scratch. Nowadays you have OpenGL, but back when I first started coding, there weren't any publicly accessible 3D graphics engines (or they were difficult to find). Anyways, it took me several tries over 6 years (I was 15 when I first tried...gimme a break), but I got a basic 3D graphics library working this year (2001). The renderer is only capable of flat shades with basic lighting (no texture maps, shadows, or anything fancy like that), and is dog slow...and probably pretty much useless. It's also kind of messed up because I decided to reverse the Z-axis so that moving away from the camera (or point of view) increases the Z value (normally, it goes into the negative). One thing I did do, however, is to add some basic object handling routines to make it easier to use the library. The basic element, of course, is a vertex. Then you have "faces" (defined as an array of verteces), and then "things". A "thing" is basically a collection of faces. Then there are "structures" which are made of "things". The idea is that, for example, if you had an airplane, you want the whole thing to be one object, but you also want certain parts to move (or break off, as the case may be). So it seemed to make sense to break things into "things" (i.e. wings, flaps) and "structures" (the whole plane). Now, if I were smarter, I would've arranged it into a tree or nested structure so that any ojbect can be made up of any other object and so on. Each "thing" and "structure" is also given a unique ID, so you can simply pass ID's around to manipulate them (e.g. rotate or move). This, also, isn't as smart as it sounds because, when you think about it, there really isn't much of a difference between passing an int around and passing a pointer around. In fact, if you had a pointer to the damn thing, you might be able to do more with it. The bottom line is, it's a pretty crappy/wanky graphics engine. But at least I can claim to have written one from scratch! Here are some screen shots. I'm not going to bother posting the code because it's crappy and there are much better alternatives out there. Besides, I don't want some crazy kid to think trying to write a 3D graphics engine would be a good idea (because it really isn't).
|