User:Callahanp/Flightgear and Simgear Files

From FlightGear wiki
Jump to navigation Jump to search
WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.

Source Code Notes

Review the Flightgear and Sourcecode source folders to get a sense of what each directory contains. Together Simgear and Flightgear source code contain a total of about 2200 files. Many of these are matching .cxx and .hxx files. If you just look at .cxx, .cpp and .c files, Flightgear has under 650, Simgear under 400.

So there are over 1000 things in flightgear and simgear that someone thought belonged in a separate module. Where do you start? I usually take the approach of just reading through the file names to get a sense of what words and phrases are used, googling or looking at the flightgear wiki, any that seem the least bit unfamiliar.

Getting data on source code files

Create a directory 'sources' with links to the flightgear and simgear source code in next

flightgear -> ../next/flightgear/src
simgear -> ../next/simgear/simgear

Run this bash script to count files in each linked directory.

for d in $(find -L . -maxdepth 2 -type d)
  echo $d: $(find -L  $d -name \*.c\* -type f|wc|awk -F ' ' '{print $1}') .c** Files
for d in $(find -L . -type d)
  echo $d: $(find -L $d -name \*.c\* -type f|wc|awk -F ' ' '{print $1}') .cxx Files
  echo $d: $(find -L $d -name \*.h\* -type f|wc|awk -F ' ' '{print $1}') .hxx Files
  echo $d: $(find -L $d -name \*.xml -type f|wc|awk -F ' ' '{print $1}') .xml Files
  echo $d: $(find -L $d -name \*.txt -type f|wc|awk -F ' ' '{print $1}') .txt Files
  echo $d: $(find -L $d -name \*gitignore -type f|wc|awk -F ' ' '{print $1}') .gitignore Files
  echo $d: $(find -L $d -name  README -type f|wc|awk -F ' ' '{print $1}') README Files
  echo $d: $(find -L $d -type f|wc|awk -F ' ' '{print $1}') Total Files

The results in detail

Flightgear: 1473 Files

  • 637 .c, cpp or .cxx
  • 644 .hxx
  • 1 .xml
  • 34 .txt
  • 14 .gitignore
  • 8 README

and a few others.

Simgear: 880 Total

  • 380 .c, cpp or .cxx
  • 413 .h or .hxx
  • 16 .xml
  • 40 .txt
  • 2 README

Although there are .c, .cpp and .cxx source files, I'll refer to them all as .cxx files.


637 .cxx files


We'll start with flightgear/src/main. It has 19 .cxx files. main is of course where everything starts. Main does a lot, and I've written about it in detail in From Command Line to Holding Short. This is the short version.


  • parses command line arguments
  • reads a configuration file
  • processes options read from the command line and the configuration file
  • starts either the Launcher or directly starts the simulator fgfs.exe
  • configures communication ports
  • initializes the property tree and globals
  • initializes scenery and airports
  • establishes the locale and initializes translations using the xliff standard
  • initializes the metar weather
  • starts a logger
  • disables the screensaver
  • initializes the position of the aircraft
  • initializes the subsystems using subsystemFactory.cxx (there are quite a number of these)

Embedded Resources

1 cxx file and an xml file. This one is small but probably important. According to text within the cxx file, it's related to efficient handling of large resources needed to run the simulation. This is an unfamiliar area so I'm not going to say much about it yet.

Four Large Flightgear Sub-Directories: FDM, GUI, Instrumentation & Network

The four largest flightgear sub directories account for about a third of the 1000 c or c++ files in flightgear. FDM - 249 files, GUI - 64, Instrumentation - 58 and Network - 42.

FDM stands for Flight Dynamics Model - There are several different models. Each aircraft uses one of them to determine the attitude, and velocity during flight. JSBSim, LaRCsim, UIUCModel, YaSim are the major ones, used by most aircraft. There are also special purpose models: ACMS, ADA, AISim, Baloon and Magic Carpet.

GUI, the Graphical User Interface directory has some code using the QT library, some using plib and some using canvas. There is ongoing disussion on the mailing list and on the Wiki about what is the best approach for the GUI needs of Flightgear.

Instrumentation has code for the "Heads Up Display" the KLN89 GPS Navigation system, various radio systems. Code is being migrated from Cockpit folder (23 files) Currently there appear to be manager modules in both Instrumentation and Cockpit.

Network has 98 files supporting Http and DNS clients, Telnet and Socket server, IGC and AV400 (garmin) protocols, protocols used by Flight Dynamics Models, Flightgear's Multiplayer feature, FGCom and support for an ATC display. Network support for the High Level Architecture (HLA) and federation is also found here.

Model, AI Model and Traffic Subdirectories

Take a close look at Model, with just 9 files Model contains code for loading, positioning, orienting, and animating 3D models. The main class is in model.cxx. It represents any 3D model in flightgear. acModel.cxx manages the 3D Model of the aircraft, loaded from .ac files. modelmgr.cxx manages all 3D models except for the aircraft.

The AIModel directory contains 40 files with code covering a number of features of aircraft that fly themselves in the simulation. AIBase.cxx has the main class from which AI Entities are derived. There's code to cover modeling of Aircraft, Ships, Ground Vehicles, and Tankers. In addition, there's support for a database of performance data related to these craft. AIBallistic.cxx and submodel.cxx cover models that can be detached from the aircraft. Wingman is derived from AI Ballistic, and I'm guessing that the external fuel tanks on the space shuttle are as well. You'll also find in this directory code for some aspects of weather: Storms and Thermals.

Traffic's 7 files include TraficMgr.cxx which manages schedules for the AI entities. Read this file for more information on recent and possibly planned changes in this area.

Canvas and Viewer

What exactly is Canvas anyway? Is it 2D or 3D, Is it just a camera? It includes the GUI manager. Is it a 2D GUI rendered with a camera? Is canvas the whole scene, or just a 2D overlay on top of it?

./flightgear/Canvas: 7 files

./flightgear/Viewer: 26 files

./flightgear/Time: 7 files

In the Aircraft

  • Scripting: 30 files
  • Input: 30 files
  • Aircraft: 13 files
  • Autopilot: 28 files
  • Systems: 12 files - Systems in the context of this directory refers only to the systems present in an aircraft: Electrical, Pitot, Static, and Vacuum. The system responsible for propulsion, is covered in FDM.
  • Radio: 6 files
  • Sound: 23 files

Outside the Aircraft

Scenery, Airports and Navaids

These directories cover what you see in flightgear

  • Airports: 34 files
  • Navaids: 42 files
  • Scenery: 19 files
  • Environment: 33 files
  • ATC: 17 files

Other Flightgear Directories

  • MultiPlayer: 8 files
  • Add-ons: 17 files


880 files; 380 .cxx Files

Subsystem Manager and programming patterns

  • structure: 18 .c** This appears to be glue to hold flightgear together. It includes subsystem_mgr.cxx and a number of items that adapt common programming idioms for use in simgear.
  • std: 2 .c** Files integer sequences & type traits. see: [ - Types]
  • xml: 2 .c** Files A static xml parser implemented using "easyxml", itself a simgear specific implementation of the easyxml interface. The original easyxml is in Java.


  • scene: 97 .c** Files. The scene files are contained in sub-directories:
    • dem (digital elevation model and triangular meshes)
    • material (Effects, material classes, parser for OSG blend functions, pass - derived from osg::StateSet, A class to validate that a technique is valid at a particular state.
    • model - Various Animations, Visitors, Model Registration, particles perspectives, placement, various transformations, primitive collector, manager for text in the scene graph, shadanim: non fixed Opengl pipeline rendering,
    • sky - cloud, cloudField, CloudShaderGeometry, dome, moon, oursun, sky, sphere, stars.
    • tgdb - airport signs, Bucket Box, ground light manager, obj: scenery loading, readers & writers for BTG, SPT, STG, buildings, Tiles, directional light, SGLightBin, SGModelBin, SGTexturedTriangleBin, SGVertexArrayBin, TreeBin, SGNodeTriangles, SGOceanTile, VasiDrawable, ShaderGeometry, userdata - classes for populating ssg user data slots in association with our implemenation of random surface objects.
    • tsync - Terrasync
    • util
      • Color, Copy, Primitives, VectorArrayAdapter, project, QuadTreeBuilder, SGSceneFeatures
      • Deletion Manager
      • OSG: Math, Singleton, Debug
      • Visitors: SGUPdate, Splicing, Node and Drawable, SGStateAttribute, SGTextureStateAttibute
      • Callbacks: SGPick, UpdateOnce, SGDebugDraw, OptionsReadFile, OSGDebug
      • SGEnlargeBoundingBox
      • SGNodeMasks
      • SGSceneUserData
      • StateAttributeFactory
      • Noise, OSGDebug, Options, Quad Tree, Render Constants, Scene Features, Reader/Writer options,

Bounding Volume Hierarchy

  • bvh: 17 .c** Files - - Related to the processing of graphics data. Creates Bounding Volume Hierarchies and Groups, provides visitors for bounding boxes, Nearest Points, Line and Line Segments, Motion Transforms, BVH Paging, a sub-tree collector and other functions [[ | Wikipedia Article:

Bounding Volume Hierarchy]]


  • math: 7 .cxx Files 29 .hxx files
    • bezier curve
    • SGBox
    • interpolation
    • least squares
    • Geometry - Box, Sphere, Ray, Line Segment, Plane, Triangle, Intersection tests
    • Math - limits, geodes, vectors, geodetic and geocentric location, quaternions & matrices


Where we are and what's around us

  • magvar: 3 .c** Files. compute local magnetic variation given position, altitude, and date. also a magnetic variation wrapper class.
  • ephemeris: 12 .c** Celestial Bodies, Stars, Planets, the Moon, the Sun
  • environment: 5 .c** support for decoding metar strings and managing weather artifacts: lightning, clouds, precipitation
  • timing: 5 .c** adapts low level time functions for use in a simulation that crosses time zones. provides classes representing a timestamp, conversions to siderial time etc.


  • io: 39 .c** Files. iostreams, file i/o, an Abstract IO class, decoding for binary files of various types, DNS & HTTP clients, raw sockets, network channels and buffers, untar, tcp client and server, chat


  • package: 11 .c** support for downloading Aircraft
  • embedded_resources: 4 .c** Support for compressed data, data embedded within files. Need a good explanation of what an embedded resource is and how these are used
  • bucket: 1 .c** Files. Container for scenery Processing
  • screen: 3 .c** What is a "TR"? What is a GL Extension? Why is colors.hxx in this directory?
  • canvas: 40 .c** Flightgear Wiki Article: Canvas


  • nasal: 28 .c** Nasal seems to be in C. Is that why there's a cppbind?


  • serial: 2 .c** Unix serial I/O support
  • hla: 32 .c** Files
  • misc: 23 .c** Files
  • threads: 1 .c** Files
  • debug: 3 .c** Files Special Handling for certain error messages and capture of OSG log output
  • sound: 11 .c** Files. soundmgr, xmlsound, readwav, sample, aeonwave support, sound filters, 3 jet wav files.