DarkRadiant module system
From Dark Wiki
Module interface
The design of DarkRadiant is a modular one. Each module encapsulates a certain amount of functionality, such as the entity module which provides entity creation and rendering, and the model module which loads modules from ASE, LWO or MD5 files. Each module implements an interface which is defined in an "i*.h" file in the include directory (such as "imodel.h" and "ientity.h"). There is also a Radiant module whose interface is specified in "iradiant.h".
Modules access each other using inline functions defined in the interface header file, such as GlobalRadiant() or GlobalShaderCache(). These functions return a reference (or pointer) to a static instance of the corresponding module. The initialisation order of modules is important, and this is controlled via the use of a ModuleRef template, which instantiates and maintains a reference to a singleton module instance, and "Dependencies classes" which are empty classes that inherit from a number of ModuleRef templates, thus ensuring that each ModuleRef is constructed before the Dependencies class itself.
The modules
Modules can be categorised as "external", which are held in a separate shared library, and "internal", which implement a defined module interface but reside within the main binary. There are 12 external modules currently in use.
- XMLRegistry (iregistry.h) - provides a unified XPath-based registry interface for other modules to retrieve and store configuration information. Because of its importance, this module is loaded separately ahead of all other modules.
- radiant (iradiant.h) - although not a separate library, the core Radiant code is in the form of a module and exposes a number of methods to allow other modules to access important information from the main application.
- eclassmgr (ieclass.h) - the Entity Class Manager is responsible for parsing entity definitions from the def/ directory, and assembling a data structure in memory to allow entities of any known class to be created in the map.
- entity (ientity.h) - this is the Entity Creator, which creates entities of classes maintained by the Entity Class Manager and inserts them into the map
- mapdoom3 (imap.h) - the map module is responsible for loading and saving maps. It defines a MapFormat interface with methods to read and write from a map file, traversing the scene graph in the process. It is not completely segregated; much of the core Brush and Patch code contains explicit knowledge of the map format which should be encapsulated in the map module.
- model (imodel.h) - the Model Creator is responsible for parsing static model files (ASE and LWO) and creating scenegraph nodes containing the model data
- md3model (imodel.h) - a separate plugin implementing the Model Creator interface, this is responsible for animated (MD5) models.
- ShaderSystem (ishaders.h) - the Shader System module is responsible for managing Doom 3 shaders, making them available on demand and loading the necessary image data
- vfspk3 (ifilesystem.h) - this module allows seamless loading of assets from with PK4 archives, as well as from relevant directories on the local filesystem
- image (iimage.h) - provides core image loading functionality from bitmap formats in the VFS
- archivezip (iarchive.h) - provides ZIP file loading functionality for the VFS module
- filters (ifilter.h) - encapsulates the Filter System, which is responsible for hiding and showing selected classes of object
- EventManager (ieventmanager.h) - this is the module where all the keyboard events are coming in. It also provides methods to interpret mouse clicks (orthoview, camera).
- UIManager (iuimanager.h) - provides interfaces to add UI elements like menu items. Is not fully fleshed, but the MenuManager subclass is up and running.
Dark Mod-specific plugins: These register themselves upon startup and add their menu items single-handedly when instantiated by the plugin system, hence they need no interface defined in the includes/ folder.
- dm.objectives The Objectives Editor plugin used to create objectives entities and their spawnargs.
- dm.stimresponse The Stim/Response Editor plugin which can be used to conveniently set the S/R of the selected entities.
