For graphics programming at my school, we used a game engine custom-built for this course. This engine had no built-in features for creating levels/scenes, making it hard to create a level as the level layout could only be hardcoded. That is why I created my own level editor that allows to create objects, add scripts, add properties, and more.

Features:

  • IMGUI for editor UI
  • Creating, editing, saving, and loading scenes/levels
  • Game objects and updating their components and parameters.
  • Creating prefabs from game objects.
  • Creating materials from shaders that each have different properties.
  • Importing of fonts models and sprites.
  • Reflection in C++ to register parameters and components.
  • saving and loading using RapidJSON

Editor

The editor itself is the most important part of the game engine editor. This editor is written in the Overlord engine which is an engine that combines C++, PhysX for physics and DirectX 11 for graphics. The editor is built by using IMGUI, which is an immediate mode graphic user interface which allows for adding and removing elements from the editor and real time changes to the elments in the UI, making it perfect for a game engine editor.

Using IMGUI, I was able to create menus with multiple functions, including the loading, saving, and creation of scenes, it’s also possible to create and destroy game objects or add and remove scripts to those objects. The Editor also allows the creation of custom windows.
In the first window, I was able to show all the game objects, select objects and attach children and parent objects to each other and view all those objects in the scene.
The second window is only visible when an object has been selected, this window shows all the parameters and all the components that are available to be changed. In this window, it is also possible to change the object name, the tag, and whether it is active or not. In this window, it is also possible to drag and drop values from 1 field to another which makes it very easy to connect 2 components or to drag and drop a material, font, sound or model.

Reflection

To make it easier for myself and not having to create a custom editor class for each component and material, I created a separate program that I used for reflection. This program reads all the classes in the project and tries to find components, materials and variables inside the components/materials.

  • It starts off by reading each header file and looking for a macro with the name COMPONENT, MATERIAL or POST_PROCESS. These macros indicate that an object is either a component or a material.
  • If it finds one of those macros, it stores the file in a list per type, if it doesn’t find the macro, the file is discarded.
  • In the next step, the parser checks if it can find variables in the header file by looking for the PERSISTENT_VARIABLE macro, if this macro is found, the next variable is stored and the type and name are stored as well.
  • Finally, when all the variables in the file are found, a new file is generated that has access to the variables in the original file. The generated class contains the GUI code to draw the parameters to the GUI. The generated class also contains the code for saving and loading the registered variables.

Editor Tools

Prefabs

As the reflection system already contained everything I needed for saving objects, it was really easy to save 1 or multiple game objects to a prefab. Those prefabs could then quickly be loaded at runtime using the same process as the loading of the scene. An extra window was also created where I could quickly link to the locations of the prefabs.

Material Editor

Just like the normal game object editor, materials can be edited inside the editor in the material panel. In this panel, it is not only possible to change the textures and names of the materials, but all other types of variables that are available in the normal editor are also available to the material editor. In this editor, a material can be created based on multiple different shaders and each material can have different properties for the same shader.

Resource Loaders

The resource loaders are rather simple, they only contain a name an the location where the resource can be found, but they make it easy to add resources to a parameter as you can just start dragging from the resource loader window and drop it in the resource parameter field of a component. When the location of an object is changed, the location only has to be changed in the resource loader and it updates automatically in the referencing parameters.