# Using The SDK This section of the SDK documentation is designed to give you an insight into the different tools available to you as well as other important information about how to use the SDK to create your Microsoft Flight Simulator 2024 add-ons. As such it is really a continuation of the [SDK Overview](../sdk-overview/) page and, if you haven't read that yet, then we suggest you do that now then come back to this page and continue. ### Projects, Packages and Asset Groups Add-ons for Microsoft Flight Simulator 2024 are developed in the form of **Projects**, and a single project will have one or more independent **packages** within it. A package can contain any type of content supported by the simulation, for example aircraft, scenery or missions and these are defined by adding one or more **Asset Groups** to the package. Asset groups contain the base assets that are used to create the content, like models, or visual effects or combinations of different things. When a package has been built it needs to be added to the simulation, and so it needs to be placed into a specific folder for it to be detected and used. The location that these packages are installed to is set upon installation of Microsoft Flight Simulator 2024, and is actually split over *two* locations: - **Official** (for packages downloaded by the game) - **Community** (where you can install your own packages) In reality, you only need to worry about the Community folder, as that's where *all* user-created Add-On packages will be placed, including any that you make yourself. {{< callout context="note" title="NOTE" icon="outline/bulb" >}} Finding the Community folder is explained in the section on The Community Folder on the SDK Overview page. {{< /callout >}} The "package" itself is a single unit of redistributable content. It consists of a directory containing the [asset groups](../../devmode/editors/project-editor/asset-types/) compiled and ready for direct consumption by the simulator in various formats, plus some special files at the top level: - `layout.json`: This file contains a list of all the other files present in the package - `manifest.json`: This file contains meta-data about the package (e.g: the package name and version number). The packages concept relies on a system called the [Virtual File System](../../devmode/menus/tools_info/virtual-file-system/virtual-file-system-information/) (or {{< glossterm >}}vfs{{< /glossterm >}} for short). In the {{< glossterm >}}vfs{{< /glossterm >}}, a package has to be *mounted* to be accessible to the game - in which case all files present in the package become accessible and can be referenced by files present in other packages. In the case where 2 packages feature file sharing - ie: they have the same *relative* path inside the package - the **version of the file in the package mounted last will take precedence**. For example: ``` codeblock Packages +-- package-01 | |-- manifest.json | |-- layout.json | +-- MyDirectory | |-- myfile.cfg +-- package-02 | |-- manifest.json | |-- layout.json | +-- MyDirectory | |-- myfile.cfg ``` In this example, the path `MyDirectory\myfile.cfg` will refer to `package-01\MyDirectory\myfile.cfg` if *package-01* was mounted last, or to `package-02\MyDirectory\myfile.cfg` in the case *package-02* was mounted last. Note that files present in a package mounted in the {{< glossterm >}}vfs{{< /glossterm >}} can *also be referenced by files that are present in other packages*. ### Creating Your First Package If you are starting a new project from scratch you will need to make your own package and supply the contents that go within it. For that the general workflow would be as follows: - Open the [Project Editor](../../devmode/editors/project-editor/the-project-editor/). - Select *Project* > *New Project* - Click the `Add Package` button at the bottom - Select which kind of package you want to make, either an **Airport** or a **Custom** package: {{< image-center src="images/2_DevMode/project_editor/editor/projed_2_addpackage.png" alt="The Add Package Window In The Project Editor" >}} - The window will update based on your selection and you can then fill in the details for the new package: {{< image-center src="images/2_DevMode/project_editor/editor/projed_3_custom.png" alt="Adding A Custom Package" >}} - Once you have filled in the required data and selected the package type you would click on the {{< button "Create" />}} button. - Next you will be prompted to add the first **Asset Group** to the package. Each package will require one or more asset group to be a valid package. For example, an Aircraft may have several asset groups: {{< anchor-link id="simobject" text="SimObject" page="../devmode/editors/project-editor/asset-types/" >}}, {{< anchor-link id="modellib" text="ModelLib" page="../devmode/editors/project-editor/asset-types/" >}}, and {{< anchor-link id="materiallib" text="MaterialLib" page="../devmode/editors/project-editor/asset-types/" >}}. So, you should fill in the required details and select an asset group type then click on {{< button "Create" />}}: {{< image-center src="images/1_Introduction/add_asset_group.png" alt="Adding An Asset Group To A Package" >}} - In the Project Editor you will now see the Package listed and under the package the asset group that you've just added. Here you would select the asset group and then in the Inspector window click the {{< button "Load In Editor" />}} button (if available for the selected asset group).   Your new package has been created, and you can start to edit the contents of the asset group it contains, either using the built in editor, or browsing to the `PackageSources` location and adding the required files.   For a more in-depth explanation of creating packages and asset groups, please see the page on [The Project Editor](../../devmode/editors/project-editor/the-project-editor/). #### General Package Folder Structure When you are creating your add-ons, it's good practice to get into the habit of maintaining a strict and organised folder hierarchy for each asset. The formatting for the various folders that your package will require is as follows: ``` + + PackageDefinitions (for package meta-data) + PackageSources (for the different package source files + data + scenery + vegetation + etc... + Sources (for code and/or art resources) ```   Other folders will be created within this hierarchy by the SDK when you build the Add-on package you are creating, but the above is a good general "rule of thumb" for add-on folder structure. You can see actual working examples of this general structure by examining the different [Samples, Tutorials, and Primers](../../samples-tutorials/samples-tutorials-and-primers/) supplied with the SDK. ### Developer Tools Microsoft Flight Simulator 2024 departs from its predecessor, Microsoft Flight Simulator X (or FSX for short), in the way that the developer tools are integrated. Where FSX used to provide *separate* compilers for each type of resource (eg: `bglcompiler.exe`, `SimPropCompiler.exe` etc...), the compilers for Microsoft Flight Simulator 2024 assets are integrated into the simulator executable under the umbrella of a build automation tool called the **Package Tool** (similar in spirit to a {{< glossterm >}}makefile{{< /glossterm >}} system). Below is an illustration of the process that goes into building two packages that are part of the same project file. Note how `*.glTF` files get compiled to `*.glb`, `*.png` files get compiled to `*.ktx2` and `*.xml` files get compiled to `*.bgl`: {{< image-center src="images/1_Introduction/package_creation_process.png" alt="Package Creation Process" >}} The Package Tool is part of [The Project Editor](../../devmode/editors/project-editor/the-project-editor/) which is part of the internal Microsoft Flight Simulator 2024 tool chain. In general the tools you'll need to make Add-Ons for the sim are as follows: - **external tools**: These are tools you'll need to create some of the content you'll use, like aircraft models, and there are additional tools distributed as part of the SDK (e.g. the 3D Studio Max {{< glossterm >}}gltf{{< /glossterm >}} exporter plug-in - see the [SDK Overview](../sdk-overview/) page for more information) to help you use them. - **in-sim tools**: These are available under the [Developer Mode](../../devmode/developer-mode/) (e.g. [The Project Editor](../../devmode/editors/project-editor/the-project-editor/), [The Scenery Editor](../../devmode/editors/scenery-editor/the-scenery-editor/), [The SimObject Editor](../../devmode/editors/simobject-editor/the-simobject-editor/), etc...). ### GUIDs An important part of *many* of the assets and files that you'll be creating for Add-Ons is the use of {{< glossterm >}}guid{{< /glossterm >}}s for identifying them. For example, in the `cameras.cfg` file there is a key like this: Guid = "{195EAB58-9E4A-1E2A-A34C-A8D9D948F078}" ; Camera definition unique identifier. This GUID must be unique. As the comment for that key says, these are *unique* identifiers for each and every thing that requires it, and it's up to you to generate them. To make things a little easier, this can be done from within [Microsoft Visual Studio](https://visualstudio.microsoft.com/) using the **Create GUID** tool: {{< image-center src="images/1_Introduction/create_guid_tool.png" alt="Visual Studio Create GUID Tool" >}} This is available from the **Tools** menu in Visual Studio and will generate a GUID in multiple formats each time you click the **New GUID** button. We recommend using the **Registry Format**, as you can copy and paste that into most files without having to edit anything. ### 3D Models In Microsoft Flight Simulator 2024, 3D models, scenes and animations are stored following the `glTF` file format. `glTF` is a [Khronos](https://www.khronos.org/)-backed standard file format consisting of a `JSON` file and referencing accompanying binary files. In Microsoft Flight Simulator 2024, `glTF` support relies on custom `glTF` extensions, whose schemas can be found as part of the SDK installation in the `Schemas` subfolder. You can find more information on the creation of 3D models from the [Modeling](../../models-and-textures/modeling-technical-information/) section of this document. ### Textures And Materials Materials for 3D models are specified in ` glTF` files, and the referenced textures are in `*.png` format. The materials comply with {{< glossterm >}}pbr{{< /glossterm >}} (Physically Based Rendering). Upon compilation by the `glTF` compiler (invoked by the **Package Tool**), `*.gltf` files get compiled to `*.glb` and `*.png` files get compiled to `*.ktx2` files. The resulting `*.glb` file makes use of several `glTF` extensions, including `MSFT_texture_dds` as well as Microsoft Flight Simulator 2024 specific ones. Materials for usage in the scenery tool are edited via [The Material Editor](../../devmode/editors/material-editor/the-material-editor/), which is part of the **Developer Mode**, and are stored in `*.xml` format. The source textures are also edited in `*.png` format and converted to `*.ktx2` for direct consumption by the simulator runtime. You can find more information on the creation of textures from the [Textures](../../models-and-textures/textures/texturing-technical-information/) section of this document. #### KTX2 And KTX2P Files When a package is built from the [Project Editor](../../devmode/editors/project-editor/the-project-editor/), textures will be compiled into a `*.ktx2` file format, and there may also be `*.ktx2p` files as well. However, there are circumstances where these files are *non-standard* and use a **propriety** format, meaning they will not be editable/viewable like normal `*.ktx2` files. This happens when a project is built for ingestion into the *Marketplace* specifically. However it is worth noting that: - KTX2 textures for community packages are standard compliant (as they do not go through marketplace ingestion). - KTX2 textures from ingested packages are made standard compliant through the {{< anchor-link id="vfs-projector" text="VFS Projector" page="../devmode/menus/tools_info/the-virtual-file-system/" >}}. - During package build (both community and marketplace), pixel data is modified for consumption by the games shaders, meaning the exact pixel values **are not directly comparable to the original PNG/JPG image before package build**. When it comes to the `*.ktx2p` file format, this is used purely as an optimization for *streaming* purposes. The format packs the texture data from multiple related KTX2 files (e.g: albedo/norm/comp/emissive) such that they can be streamed from a single HTTP request when possible (i.e: no packages overwrite one of the textures). If this file is not present, the simulation will simply fallback to the "regular" KTX2 files. Note that if KTX2 files are directly modified post-build (something which is *strongly* discouraged), and the KTX2P file is still present, the simulation may choose to use the *old* texture data present in the KTX2P. To prevent that, ensure the KTX2P is removed from the package. ### SimObjects In Microsoft Flight Simulator 2024 **SimObjects** are entities which have a simulation attached. The main use case for SimObjects is in making aircraft, but they are also used for certain other things like ground vehicles. #### Structure SimObjects are comprised of several files: - meshes and textures, using the {{< glossterm >}}gltf{{< /glossterm >}} file format - configuration files, in the form of `*.cfg` and `*.xml` files - checklists, in the form of `*.xml` files {{< callout context="note" title="NOTE" icon="outline/bulb" >}} *.air files (FSX flight model configuration files) have been removed in favor of exposing all flight model parameters in plain text *.cfg files. {{< /callout >}} #### Edition SimObject configuration files can be edited through [The SimObject Editor](../../devmode/editors/simobject-editor/the-simobject-editor/), which is part of the **Developer Mode**. You can find a tutorial on how to setup the flight model for aircraft using the SimObject Editor or directly editing the `*.cfg` files [here](../../samples-tutorials/tutorials/tuning-the-flight-model/tuning-the-flight-model/). #### Model Behaviors {{< glossterm >}}gltf{{< /glossterm >}} files support animations, but those animations need to be linked to [Simulation Variables](../../programming-apis/simvars/simulation-variables/). This link is done through an `*.xml` file which is named after the name of its accompanying `*.gltf` file, and the XML has various different sectiopns defining the model behavior and - for the interior of the aircraft - the different input event interactions available. You can find more information on model behaviours and the templates available from the following section: - [Model Behaviors](../../content-configuration/models/modelbehaviors/model-behaviors/) ### Scenery And Airports Microsoft Flight Simulator 2024 add-ons can feature **scenery** as part of the package, which can be not only areas or {{< glossterm >}}poi{{< /glossterm >}} within the world, but also airports. In general these scenery packages are comprised of the following: - 3D models, stored in model libraries - materials and textures - model placement - vector data (allowing for trees placement or removal, terra-forming, biome changes...) - airports data Scenery and airports are primarily edited using [The Scenery Editor](../../devmode/editors/scenery-editor/the-scenery-editor/) and [The Material Editor](../../devmode/editors/material-editor/the-material-editor/), both of which are available as part of the **Developer Mode**. Scenery object placement and airport data are saved in `*.xml` format and vector data is saved in the form of **shapefiles** ( `*.shp`). Both are compiled to `*.bgl` files using the BGL compiler invoked by the **Package Tool** in [The Project Editor](../../devmode/editors/project-editor/the-project-editor/). {{< callout context="note" title="NOTE" icon="outline/bulb" >}} `*.xml` and shapefiles compilation to `*.bgl` files is similar to how the FSX assets pipeline worked. The file formats are similar but have been extended with new features. {{< /callout >}} ### Missions Missions are specific tasks, assignments, and challenges within the simulation, usually included as part of the user **career**, but also including other things like races, etc... Currently these *cannot* be created or edited, however you can create aircraft to be compatible with the different career missions, as explained here: [Career Activities](../../content-configuration/careers/career-activities/) ### Procedural World Generation In Microsoft Flight Simulator 2024 the world is generated using various sources of data, and the world generation supports 3 different quality levels: - **Level \#1**: Photogrammetry, where meshes are downloaded for each tile - **Level \#2**: Digital Elevation Model ({{< glossterm >}}dem{{< /glossterm >}}) + aerial imagery combination - **Level \#3**: Digital Elevation Model ({{< glossterm >}}dem{{< /glossterm >}}) + texture synthesized ground textures Level \#3 is used for the *offline* version of the world and/or in cases where the aerial image quality is judged inadequate. As a result, some data is stored locally as part of the installation of the simulator: - Building footprints (stored in `CGL` files) - Biome information (stored in `CGL` files) - Vector data (e.g: water and roads, is stored in `CGL` files) - Textures for procedural ground texture synthesis (stored in `DDS` files) - Variations for the vegetation (stored in `XML` files) - etc... At the moment this data **cannot be edited by add-ons**, but in the future it may be possible to edit `CGL` files. For more information on how the map tile data contained in `CGL` files is obtained, see the following Microsoft article: - [Bing Maps Tile System](https://docs.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system) {{< callout context="note" title="NOTE" icon="outline/bulb" >}} The Autogen technology from FSX has effectively been removed in Microsoft Flight Simulator 2024. {{< /callout >}} {{< callout context="note" title="NOTE" icon="outline/bulb" >}} `CGL` files are the Microsoft Flight Simulator 2024 equivalent of `BGL` files, only for storing imagery, elevation data, vector data and footprints. `BGL` files are still used when it comes to airport data or edited vector data (in the form of polygons). {{< /callout >}} ### Effects Visual effects can be created using [The Visual Effects Editor](../../devmode/editors/vfx-editor/the-visual-effects-editor/) while DevMode is active. This editor uses a visual coding system of "nodes" that are connected to create the required visual effect which can then be attached to a SimObject or generated using the appropriate [Model Behaviors](../../content-configuration/models/modelbehaviors/model-behaviors/). A sample project for the VFX editor is included with the SDK and you can find more information on it here: - [SimpleFX](../../samples-tutorials/samples/misc/simplefx/) For information on the XML that is generated by the VFX Editor - along with examples of each of the different VFX nodes - please see the following page: - [Visual Effects](../../content-configuration/visualeffects/visual-effects/) #### Light FX `*.fx` files are used to define the properties of the lights on your SimObjects and their use is fully explained here: - [Implementing Lights](../../content-configuration/cfg-files/system/implementing-lights/) ### Audio The audio engine used in Microsoft Flight Simulator 2024 is [Audiokinetic Wwise](https://www.audiokinetic.com/products/wwise/), which allows for easy edition of advanced sound effects by sound designers using the Wwise editor. Sound banks are packaged and distributed as part of Wwise file packages (`*.PC.PCK`). Linking Wwise Runtime Parameter Control ({{< glossterm >}}rtpc{{< /glossterm >}} for short) to [Simulation Variables](../../programming-apis/simvars/simulation-variables/) is done through a file named [`sound.xml`](../../content-configuration/sounds/sound-xml/) in the SimObject's sound folder. You can find more information on creating sound effects for the game from the following section: - [Audio](../../sound/sound/) ### UI {{< glossterm >}}ui{{< /glossterm >}} in Microsoft Flight Simulator 2024 is developed using modern HTML5 technologies (HTML, JavaScript, CSS). However, at the moment UI is *not* customisable as part of add-ons, although there are plans to make it possible to include UI elements as part of packages sometime in the future. ### Gauges / Instruments The various aircraft instruments can be created and customised as **gauges** using different techniques depending on what you want to achieve. Broadly these fall into the following two categories: - **2D gauges** - Glass cockpits are developed using HTML technologies (similar to {{< glossterm >}}ui{{< /glossterm >}}). HTML pages are referenced from the [`panel.cfg`](../../content-configuration/cfg-files/panel.cfg/) file in the panel folder of a SimObject. - **3D gauges** - These are part of the {{< glossterm >}}gltf{{< /glossterm >}} model for an aircraft and are essentially made of a mesh, textures and the accompanying animations. {{< callout context="note" title="NOTE" icon="outline/bulb" >}} the old FSX `XML` gauges system is still supported but is deprecated in favor of HTML. {{< /callout >}} {{< callout context="note" title="NOTE" icon="outline/bulb" >}} Previously, in FSX, you could use CAB files to store files - primarily used for XML gauges. However, with Microsoft Flight Simulator 2024 this is not possible and has been deprecated. CAB files are not supported on Xbox and, as such, they cannot be used for any aircraft packages for that platform. If you have a legacy aircraft that you have updated for Microsoft Flight Simulator 2024 and it still uses CAB files, then you will need to resolve this before these aircraft will be available for the Xbox. The simple solution is to simply extract the files from the CAB file into a folder with the same name as the CAB file (minus the extension). {{< /callout >}} You can find the following samples included with the SDK to show you how gauges can be created as part of an aircraft package: - [GaugeAircraft](../../samples-tutorials/samples/simobjects-aircraft/modularaircraft/gaugeaircraft/) - creating and building custom {{< glossterm >}}wasm{{< /glossterm >}} gauges, and linking them to the aircraft - [GdiplusAircraft](../../samples-tutorials/samples/simobjects-aircraft/modularaircraft/gdiplusaircraft/) - using a static library to extend the graphic capabilities via a {{< glossterm >}}gdi+{{< /glossterm >}} wrapper of the low level {{< glossterm >}}api{{< /glossterm >}} - [MapViewAircraft](../../samples-tutorials/samples/simobjects-aircraft/modularaircraft/mapviewaircraft/) - A {{< glossterm >}}wasm{{< /glossterm >}} example showing how to make glass cockpit screens showing weather/terrain. There are also tutorials available to you about JavaScript and WASM instruments: - [Setting Up For HTML/JS/CSS Instruments](../../programming-apis/javascript/js-gauge-tutorial/setting-up-for-html-js-css-instruments/) - [Creating WASM Gauges](../../programming-apis/wasm/creating-wasm-gauges/) ### C++ Support C++ support is provided in the form of {{< glossterm >}}wasm{{< /glossterm >}} modules. In particular, this can be used for implementing complex gauges and porting from legacy code. The following {{< glossterm >}}api{{< /glossterm >}}s are currently available: - [NanoVG API](../../programming-apis/wasm/low-level-api/nanovg-api/) - [Network API](../../programming-apis/wasm/network-api/network-api/) - [MapView API](../../programming-apis/wasm/mapview-api/mapview-api/) - [Gauge API](../../programming-apis/wasm/gauge-api/gauge-api/) - [SimConnect](../../programming-apis/simconnect/simconnect-sdk/) More {{< glossterm >}}api{{< /glossterm >}}s may be authored, depending on community feedback, in the future. ### DRM Digital Rights Management ({{< glossterm >}}drm{{< /glossterm >}} for short) functionality is currently applied automatically to all Marketplace packages. However it should be noted that HTML/JavaScript **can not be encrypted** and additionally, JavaScript can not read encrypted data at all (even if it's from your own package). For details on how {{< glossterm >}}wasm{{< /glossterm >}} deals with DRM, please see the following section: - {{< anchor-link id="file-access" text="File Access" page="../programming-apis/wasm/webassembly/" >}}