How to approach Game Engine Development

A couple of weeks ago I was assembling a new piece of furniture for my apartment. As I was putting all the pieces together, I made sure not to tighten the screws until all the parts were in place. Such workflow reminded me of the process I took to develop the Untold Engine.

If you have been reading this blog for a while, you would know that when I started developing the game engine, I knew very little about Computer Graphics. Moreover, my C++ programming skills were weak.

Keeping into account my technical weaknesses and my desire to learn, I approached the engine's development the same way you would assemble a new piece of furniture. That is, I made sure not to tighten the screws until the end.

What do I mean with this phrase? I didn't focus on Perfection. I didn't write each piece of code to the highest standard possible. Instead, I focused on writing code that was Good Enough.

For example, the Collision Detection System is the most complex component you will have to implement. This system requires you to implement several algorithms such as the GJK, BVH, Sutherland-Hodgman, etc. My initial implementation of the GJK was very crude. However, instead of making it Perfect, I decided to move on and implement the Sutherland-Hodgman algorithm. Again, my implementation was crude, but it was Good Enough. Finally, I implemented the BVH algorithm.

I had all the major components working. Their implementations were crude, but they were Good Enough to detect a collision. I had in my hands a crude Collision Detection System, but I had learned a ton in the process. I learned how all these algorithms worked together to detect a collision.

After I understood how these algorithms worked together, I went back and re-read several chapters on Collision Detection and several articles on the algorithms mentioned above. Armed with new knowledge and experience, I was able to improve the Collision Detection System. I think I was able to do so because I saw the system from a holistic point of view. I understood the system weaknesses and strengths. I was able to see the whole picture.

Developing a Game Engine is tough. There is a lot to learn, and you will make tons of mistakes. In the beginning, avoid Perfection. Once you have a good grasp of what you are doing, go back and improve your code. Just like assembling a piece of furniture, do not tighten the screws until the end.

Languages required to develop a game engine

A while ago I responded to a question on Quora regarding which languages are required to develop a game engine. In this post, I want to expand on my answer.

The one thing to keep in mind while developing a game engine is EFFICIENCY. And it was the closeness of C++ to the bare metal that finalized my decision to use it as the primary language of Untold Engine. The other motive was my desires to learn C++ at a deeper level.

Collision Detection is the most expensive operation in a game engine. A proper Collision Detection System must detect a collision, compute the where the collision occurred between two convex entities and compute the collision responses. Furthermore, to efficiently detect collision among several entities, a game engine should parse the scene and divided the detection between two stages: Broad and Narrow Phase stages.

 
collisiondetectionphase.png
 

Such operations require the implementations of a Boundary Volume Hierarchy algorithm and a GJK algorithm. These are expensive operations, and they must be computed within a fraction of a game-tick.

Therefore, whatever primary language you decide to use in your engine, make sure that it is a fast and efficient language. The last thing you want is for your game engine to waste valuable time in the collision detection due to the inefficiency of the language.

Aside from the game engine, you must also develop an application that acts as a bridge between your engine and 3D modeling software, such as Blender 3D. The primary purpose of this application is to export rendering data of a 3D model from Blender and make it accessible for the engine to use. To develop such an application, you need to learn Python-Blender scripting.

castledae.png

During the development of the Untold Engine, I had to develop this application, which I call Digital Asset Exporter (DAE). The DAE not only exports rendering information but also 3D animation data which the engine can use.

daedata.png

Depending on the 3D Modeling tool which you decide to use, you may have to learn a different second language such as javascript. For example, if you choose to use Cheetah3D, you will need to develop the DAE using Javascript.

Well, I hope this helps.

Managing your schedule to develop a game engine

A while back I received an email from a reader asking me how did I manage my schedule to develop a game engine. I feel that his question is a common question among most of us.

So how did I do it?

The development of my game engine can be divided into two periods: "Prior the development of the Basic Framework' and "After the development of the Basic Framework" of the engine. By "Basic Framework," I'm referring to a game engine that has the four primary components implemented. Such as Math Engine, Rendering Engine, Physics Engine, and Collision Detection System.

Time Management Prior the Basic Framework

When I started the development of the engine, not a single free hour was wasted. I had only one goal in mind, and nobody or nothing was going to stop me. My schedule was very extreme:

  • Wake up early in the morning, usually at 5 am and work until 7:00 am or so.
  • Head to work
  • I tried to eat lunch at my cubicle as I worked, and used my lunch hour to go to Starbucks (or Coffee Bean) and worked on the engine
  • Go back to work
  • At around 6 pm, I would head to the Gym or play soccer for about an hour and come back home
  • Work on the engine from 7 pm to 1 am or so
  • Repeat

During the weekends, I would work on the engine for about eight hours each day.

Looking back, I think that I was taking my desires to develop a game engine a bit to the extreme. I should have relaxed a bit more. However, back then I felt that it was the cost of doing what I wanted to do.

Time Management After the Basic Framework

There is something about Game Engine Development that you should know. Once you implement the Basic Framework of the engine, everything gets easier. Developing the Basic Framework is the hardest part of a game engine. Trust me.

My schedule during this period is more relaxed. I no longer put an inordinate number of hours on the engine. I work on the game engine for about 2-3 hours each weekday. During the weekends, I may work 5-6 hours total.

Looking back, I realize that I was able to do all this because I have no other obligations aside from my full-time job (I work as an engineer). I am not married, I have no kids, and I'm out of college. So, I have a lot of free time. I understand that many of you may not be in my same situation.

So, back to the original question: "How can you manage your time to develop a game engine?"

I can't tell you how to manage your schedule. My situation is different than yours. However, the one tip I can share with you to make the best use of your time is this:

Do not code right away. I have realized that after I learned a new concept, and try to implement it in code right away, I would end up wasting a lot of time fixing bugs. Instead, try to internalize the newly learned concept. Visualize the implementation as you are heading to work or school, while watching Netflix, while eating, etc. Think about it as long as is necessary. Think about how it will affect the architecture as a whole. Try to foresee what bugs will arise and how other components in the engine will be affected. Once you have a clear idea of how to implement the new feature, then open up your laptop and start coding.

You will realize that the time spent visualizing the implementation leads to less time being wasted fixing bugs.

So, do not code right away, instead try to visualize it first.

Hope this tip helps.

The Art of Game Engine Development

I've written several articles explaining how a game engine works. However, I feel that I left out an important concept.

Over the years, my view on Game Engine development has evolved. It has changed from "This is how you develop a game engine" to "There is no one way to develop a game engine."

When I started, I spent hundreds and hundreds of hours pouring over technical books; learning, deciphering code snippets and trying to implement the same ideas I learned on my game engine.

There is nothing wrong with the approach mentioned above. But over the years, I realized that Game Engine development is not only science, but it is also an ART.

There was a point in the development of the engine when I stopped treating the implementations provided in technical books as "Gospel." Instead, I would make an effort to truly understand the "concept" and then go on and implement it my way.

When I did this, I started to fall in love with Game Engine Development. That was the moment that I felt that I was genuinely doing Engineering.

To develop a game engine, focus on understanding the primary role of each component, but implement the internals of each component, not as mentioned in a book, but as YOU think is the best way.

In other words, let your creativity flow through your game engine. Game Engine Development is science mixed with "technical" art.

Documenting the Untold Engine

Here is a tip I would like to share:

Approach documenting your project, as a project itself.

I started documenting the engine months before I released it. I was hoping to have the documentation ready by the Release Date. However, that never happened. Documenting a project is a lot, a lot of work and you should treat it as a project itself. Overall, it has taken me over eight months to document the Untold Engine.

 
In version beta v0.0.11, I implemented several camera behaviors such as First Person Camera and Third Person Camera. The particle system was also improved. Moreover, the camera culling was also improved.
 

Trust me; I've been working on the documentation daily.

So what type of documentation is currently available in the engine. Well here is what I have done.

The Documentation is divided into the following sections:

  • Labs & Tutorials
  • API Usage
  • Digital Asset Exporter
  • Architecture
  • Modules

The Labs & Tutorials section provides several labs that will help you get started with the engine. You will have a chance to learn how to render a game character, how to add collision detection, etc. It is an excellent way to get started using the engine.

The API Usage section helps you understand how to use the Untold Engine's API. This section is geared to users who have gone through the Labs & Tutorials section and are ready to start playing around developing their games. You will learn how to render 3D objects, skyboxes, text, etc. using the engine's API. You will also learn how to use the Physics Engine, Callbacks, etc.

The Digitial Asset Exported section is a critical section to read. This section will explain how to import a 3D object/animation from Blender and use it in the Untold Engine.

The Architecture section is not complete yet. This is the section that requires a lot more work. My goal is to provide dozens of articles explaining the entire architecture of the Untold Engine. This will be massive work, and I hope to complete it in about six months or so.

When I released the engine, I was fully aware that the Documentation was lacking and I have put a lot of work on writing these articles. I hope you find them useful.

Thanks for reading.