RTS Game Engine
Project Stats:
Name: | RTS game engine |
Project type: | Student project |
Production Time: | 8 weeks |
Date: | 2017/09-2017/11 |
Engine/language: | C++ |
Platforms: | PC |
Tools: | Visual Studio, Perforce, Jira |
Team members: | 4 programming students |
Project Description
Creating an RTS game engine.
My contributions
- Model manager
- Loading models using Assimp
- Making it possible to pick a model in the editor
- Editor
- Imgui window base class
- Saving the state of Imgui windows
- Entity editor window using Imgui
- View entities in the scene by clicking its associated button in the editor
- Ray casting for selecting entities in the editor
- Drawing a box around a selected object
- Camera movement in de editor
- Fmod
- Implementing a soundmanager with Fmod
- Soundmanager editor window using Imgui
Model manager
The model manager is a data-driven system responsible for loading models. It stores data for loading models and textures in an XML file using cereal.
In the video, the window on the left is the entity editor and the window on the right is the model manager.
The model manager enables you to edit the model and texture paths and load them the next time the editor starts.
Editor
On the right you can see a screenshot of 5 Imgui windows that I worked on. The camera window, raycast system window, sound manager window, step timer window, and the entity editor window.
Entity editor window
the entity editor window. It can change the scale rotation and position of an entity.
Some more features of the entity editor window:
- Selecting multiple objects
- Editing the model/textures of an object
- Drawing a box around selected entities
- Highlighting the selected model in the editor
Ray AABB intersection
I started with a per triangle intersection to select models in the editor and in the game. This was way too slow so it needed optimizations. Because of time constraints, I scraped it. Instead of optimizing the triangle ray casting I implemented a simple ray box intersection.
This is the code I use for ray box casting:
Code snippets - BoxRayCast function
This is the code I used to create a ray:
Code snippets - ScreenPointToRay function
Bar and windows
To make accessing windows more efficient in the editor I added an EditorBar class. It takes care of handling the open/closed state of windows and saving the open/closed state.
Code from Engine.cpp that adds windows to the editor bar.
// add windows to editor bar
editorBar.AddWindow(&level);
editorBar.AddWindow(&entityEditor);
editorBar.AddWindow(m_camera);
editorBar.AddWindow(&m_Timer);
editorBar.AddWindow(&m_rayCastSystem);
editorBar.AddWindow(m_game);
Code from EditorBar.h
class EditorBar : public EditorWindow
{
public:
EditorBar();
~EditorBar();
void AddWindow(EditorWindow* a_window);
virtual std::string WindowName() override;
virtual void DisplayWindow() override;
void LoadWindowsState();
private:
void DisplayAttachedWindows();
void SaveWindowsState();
EntityManager *m_entityManager;
std::vector<EditorWindow*> m_windows;
};
This is Code from EditorWindow.h. It is a pure virtual base class for editor windows that makes it easy to make anything an editor window and add it to the EditorBar.
class EditorWindow
{
public:
EditorWindow();
~EditorWindow();
virtual bool* IsOpen();
void IsOpen(bool a_IsOpen);
virtual std::string WindowName() = 0;
virtual void DisplayWindow() = 0;
protected:
bool m_windowOpen;
};
Loading and saving window states
Fmod
SoundManager editor
I implemented fmod and used it to create a sound manager. The sound manager window can create a list of sounds and adjust the pitches and volumes of the sounds. When the save state button is pressed the list of sounds gets saved.