I have waited some time to release the source for the flight simulator. The main reason is that it needs cleaning up. My SDK is not completely commented and/or cleaned up either. But I have started to get requests for the source, and therefore release it as it is.
You may download it and modify it as you wish, play around if you can, but it will be on your own risk. I do require you to keep a reference to me as the original author in the code. You can see my header in all the cpp files. Some of the files also contain references to others. Donít remove these references too. There are two reasons for this. One is to keep them (and me) in respect, but mainly to provide the ones who in the future read your code to be able to track down the source in order to get additional information.
The SDK is an OpenGL engine I have build. It is mostly build from scratch and I will not comment or explain the OpenGL parts. For an complete OpenGL tutorial please visit the NeHe site as that have been my main source for understanding the basic OpenGL.
Why do I release the source code?
Most of my understanding of coding has come from studying other peopleís code. This may be examples, tutorials or real application/demo code. I have surfed the Internet for bits and pieces to solve the issues I have faced during my own projects. In respect for those who have provided me with their bits and pieces (and they are too many to be listed), I release my own code Ė hopefully to be inspiration for others.
Please note that the code is still under development! I make new releases as I make process on the project and/or improve the code. I will also try to write some pages explaining how the files in the flight simulator and my SDK work. So check in here once in a while to find new stuff...
FligtSim - HowTo
I have written an article about how the flight simulator works and is build. Read it befor you start to work on the code, as you need to have an overwiev of the concept and methods I have used.
Overview of the code:
FligthSim release 1.2 source (zipped)
(Require the SDK below!!!).
|Globals.hpp:||The globals to be used in the system. Please note that some of these are required by the SDK (like the glWindow).|
|Main:||This is the main part of the program. Input/output event handlers are placed here in side the main program loop.|
|Terrain:||This is the flight simulator! The simulation is in reality a heavy terrain generator nothing more. It contains routines to generate and draw the terrain (ground, water, trees, clouds and models). Itís a complex piece of code I hopefully will get time to explain in detail later. Otherwise I donít think you will have any chance at all to do anything with it.|
OpenGL SDK release 1.0 source (zipped)
(You need to change the project properties in order to allow the compiler to include the directories containtg these files. In Dev-c++, itís in Project options/Directories/Include directories.)
|Matrix4x4:||As the name say. Everything to handle a 4x4 matrix. I wont take credit for this, as it is mostly pieces I have found on the Internet. But I rarely use it anyway...|
|Plane3d:||This file contain 3 classes at the moment. I may split it up later. The 3 classes are: Point3d, Line3d and Plane3d. I have build them my self but they still need some additional routines. I mostly use them for detecting intersections between the frustum planes and lines, and similar issues. In time I will probably replace my vector3d with the point3d routines.|
|Position:||This contain two classes Position and Movement. In a way this is my camera class as it can be used to set the camera position, but it may also be used to do translation of positions and objects etc. I mostly used the movement class (this is an extension of the position class) as it can hold the speeds of the object. Both in regards to movement, but also turning, tilting etc. Please note that these classes were originally build to support a Space game and is therefore based on quaternion mathematics (for orientation), so handling a horizon require some additional thought.|
|Quaternion:||What would 3d be without it? This is how you handle the orientation in a 3d world. Needless to say that this is used by the position and movement classes.|
|Vector3d:||Just like the quaternion handles orientation, the vector3d handles the position.|
|Model:||This is a huge file handling my model elements. I build my own format for two reasons. The first was to get complete control of the models and their rendering, the other was to learn how things work as I coded it my self. The format is plain ASCII text, easy to understand and handle. I have a small Delphi 3d editor I have made to handle the editing of the file, a little buggy but quite nice. Download the editor here. The model container handles all the loading, allocation and drawing of models.|
|GLWindow:||I have put all the OpenGL stuff into this file. It opens the window, handles the frustum and fonts for printing.|
|Image:||An image loader. Can read TGA, BMP and RAW files.|
|Texture:||A dynamic texture handler. Allocates and loads texture for use by the program.|
|FileProcs:||This is a lib I made some time ago. It works as a front-end for loading files. It has an easy interface to peek and read strings, integers, floats, tags (like in XML) etcÖ from the file. It can also throw an error and dump an error code with the exact position of the error in the file.|
|Log:||Nothing much to tell here. The log maintains the log file. It can reset or write to it.|
|Macros.hpp:||This is a header file containing some useful macros. Some have been picked up on the Internet, others have I made myself. Any good C++ programmer should have his/her own collection of useful macros.|