Progress Update: Game Engine Beta v0.0.10

Back in Sept 2017, I decided to port the engine from using OpenGL to Metal (Apple's Graphics Library). In all seriousness, it took me several months to finally make a decision. Part of it is that I still felt like I knew little about Game Engine Development and I didn't want to expand the scope of my project.

I was aware that Metal allows you to code once and run the same code on different devices, such as iOS, Macs, and Apple TV. But I was still on the fence. However, when I saw several games using Metal+AR (Augmented Reality) features, I was convinced that I had to port the engine to Metal.

Well, today I want to share with you the tenth beta-version of the engine, but running on a Mac:

 
 

One of the things I've always dreamed about was to be able to play a game on my Mac, with the engine I developed with a controller. I know, it may sound weird, but I've wanted to do so for a while.

The video shown below does not have the best lighting, but it shows me moving the character around using the Steelseries Nimbus controller, which I also added support in the engine:

 
 

Here is a picture of the controller if you are interested in knowing which one I used:

IMG_3264.JPG

So what's the deal with AR support? That is on my To-Do list, but I will not address it anytime soon. There are other issues I want to fix and implement. One of them is the camera.

Well, thanks for reading.

What tools do I need to develop a game engine?

In a previous post, I gave you a comprehensive list of books required to develop a game engine. I figure that you may also be interested in the tools I use to build a game engine. So I wrote this post to share with you the tools I use.

Xcode

From the start, I decided to develop a game engine compatible with Apple devices. Thus, the IDE (Integrated Development Environment) I use is Xcode.

 
Screen Shot 2018-02-04 at 10.34.49 AM.png
 

I love Xcode. I've never had any complaints about it. I've heard several people who hate this tool, but I can't relate.

Git (Terminal and GUI)

A project as complex as a game engine requires a Version Control system. My tool of choice is Git. It is simple to use, yet powerful.

I'm embarrassed to share this story, but it is true. When I started development of the game engine, back in 2013, I used Dropbox as my Version Control System. Yep, you read that right. Moreover, when I started using Git, I made the mistake of committing all changes directly into the Master branch. I never made use of Git's branching feature.

But that is the past. I learned from my mistakes. I evolved as a developer :).

 
Screen Shot 2018-02-04 at 10.32.07 AM.png
 

You can interact with Git through the terminal or the GUI. I tend to use both methods. Although using the Git GUI is a lot easier, I do recommend to learn to use Git through the terminal; It will force you to understand Git better.

Should you use the Git terminal or GUI?

BeeApp

I enjoy a minimalist lifestyle. And the BeeApp suits me perfectly. BeeApp keeps track of your Git issues. It allows you to add an Issue to Git, change its tags and add comments right from the GUI. The app sorts your Issues and assigns them to a particular list depending on their labels.

Here is a screenshot of my issues sorted in Bee.

 
Screen Shot 2018-02-04 at 10.42.57 AM.png
 

I don't have to log into my Github account every time I want to update the progress of an issue or lose track of which item to work on next. I love this app. It combines the beauty of Todoist and Git Issues.

Sublime Text

Oh, Sublime Text, what a beauty you are.

To export 3D models into a game engine requires the development of a Digital Asset Loader (DAL). The DAL's primary duty is to read the attributes of the 3D model (vertices, Normal vectors, UVs, etc.) and export it into a file. The game engine then reads this file and renders the 3D model.

 
Screen Shot 2018-02-04 at 10.30.00 AM.png
 

A Blender-Python script is used to read and export the model's attribute. And Sublime Text's beautiful aesthetics makes writing the DAL a pleasure.

Before Sublime Text, I used Eclipse, PyCharm and Blender's script editor, but none compare to Sublime Text.

Blender

Believe it or not, game engine development does not mean you spend 100% of your time coding; there is some artwork involved. 75% of my time is spent coding in C++. The other 25% is spent modeling 3D characters and writing Blender-Python scripts in Blender. If you are curious about this fact, read the following article.

The tool I use to model 3D characters is Blender 3D. Blender 3D is a modeling software used by game artists.

1456325938285.png

There are other modeling 3D tools on the market. However, Blender is free, open-sourced, and there is a massive community around it. Moreover, there are plenty of youtube tutorials; which is very helpful when you are starting out.

Hope this helps

Progress Update: Game Engine Beta v0.0.9

The last update I gave on the game engine was back in Nov 2017. A lot of improvement has occurred since then. I fixed over 15 bugs and enhanced the Collision Detection System and the Digital Asset Loader. Below is a video showing beta-version v0.0.9 of the game engine.

 
 

Improving the GJK

I have mentioned before that the collision detection system is the most complicated aspect of a game engine. Interestingly, the algorithm is quite simple. However, the complication arises from the several boundary conditions that you need to account.

The Collision Detection system worked fine between objects of similar size. For disproportionate size objects, i.e., terrain and a cube, the collision algorithm would fail 50% of the time.

There were instances where detection happened way too early or too late. Other cases were even weirder. For example, merely changing the location of the cube would cause the detection to fail. I recall an instance where changing the orientation of the cube would cause a failure.

I recall spending most of my Thanksgiving and Christmas holiday working on the issue stated above. It took me over two months to improve the collision detection between disproportionate objects. It is not perfect, but it works within constraints.

What I learned from these two months working on improving the engine, is that the GJK algorithm has several boundary conditions that your code needs to account. In the previous version of the engine, I was not considering these boundary conditions; thus the reason for the early or late detections.

If you find yourself in this situation, I recommed to take a look at these books:

Improving the Digital Asset Loader

I also improved the Digital Asset Loader (DAL). If you don't know what a DAL is, it is merely a script that loads 3D models into the engine. Previously, the script would output rendering data directly to a terminal. I would copy and paste this data into an engine file.

I improved the script to write directly to the engine file. Not only that, but you can now choose what you want to import. i.e., just 3D models, 3D animations, light, or a combination of 3D models with animations.

Books I had to read to develop a game engine

If you have decided to develop your game engine, you may be wondering where to start, what books to start reading, etc. If you are in this situation, I recommend getting a copy of the following books:

Books to get started

Math Engine

  1. 3D Math Primer For Graphics and Game Development

Rendering Engine

  1. OpenGL Superbible: Comprehensive Tutorial and Reference
  2. Graphics Shaders: Theory and Practice, Second Edition

Physics Engine

  1. Physics for Game Developers: Science, math, and code for realistic effects
  2. Game Physics Engine Development: How to Build a Robust Commercial-Grade Physics Engine for your Game
  3. Real-Time Collision Detection

Out of all the books I've read, they are the best of the best, so I strongly recommend them.

Now, if you want a comprehensive list, the list below should help you.

Books to develop the Math Engine

  1. Mathematics for 3D Game Programming and Computer Graphics
  2. Quaternions and Rotation Sequences: A Primer with Applications to Orbits, Aerospace and Virtual Reality
  3. Quaternions for Computer Graphics
  4. 3D Math Primer For Graphics and Game Development
  5. Practical Linear Algebra: A Geometry Toolbox
  6. Visualizing Quaternions
  7. Curves and Surfaces for Computer Graphics
  8. Essential Mathematics for Games and Interactive Applications: A Programmer's Guide

Books to develop the Rendering Engine

  1. OpenGL 4.0 Shading Language Cookbook
  2. OpenGL Insights
  3. Real-Time Rendering, Third Edition
  4. OpenGL Shading Language
  5. Foundations of 3D Computer Graphics
  6. Texturing and Modeling, Second Edition: A Procedural Approach
  7. OpenGL Superbible: Comprehensive Tutorial and Reference
  8. Graphics Shaders: Theory and Practice, Second Edition
  9. Graphics Programming Methods
  10. Real-Time Shadows

Books to develop the Physics Engine

  1. Physics for Game Developers: Science, math, and code for realistic effects
  2. Numerical Methods for Scientists and Engineers
  3. A Student's Guide to Vectors and Tensors
  4. Real-Time Collision Detection
  5. Game Physics Engine Development: How to Build a Robust Commercial-Grade Physics Engine for your Game
  6. Computational Geometry: Algorithms and Applications
  7. Game Physics Pearls
  8. Geometry for Computer Graphics: Formulae, Examples and Proofs
  9. Geometric Tools for Computer Graphics
  10. Computational Geometry in C
  11. Collision Detection in Interactive 3D Environments
  12. Game Physics

Learning 3D Modeling tools (Blender)

If you are wondering why you need to learn Blender, read the following article.

  1. Blender Master Class: A Hands-On Guide to Modeling, Sculpting, Materials, and Rendering
  2. Blender Foundations: The Essential Guide to Learning Blender 2.6
  3. Learning Blender: A Hands-On Guide to Creating 3D Animated Characters
  4. Python 3 Object Oriented Programming- Blender provides an API which allows you to extract 3D modeling information. To use the API, you need to know a bit of Python.
  5. Digital Modeling

Game Engine Architecture

  1. Head First Design Patterns
  2. Game Programming Gems
  3. Best of Game Programming Gems
  4. 3D Game Engine Architecture
  5. 3D Game Engine Design: A Practical Approach
  6. C++ Common Knowledge: Essential Intermediate Programming
  7. C++ Pointers and Dynamic Memory Management
  8. Effective C++: 55 Specific Ways to Improve Your Programs and Designs
  9. C++ Templates: The Complete Guide
  10. Design Patterns: Elements of Reusable Object-Oriented Software
  11. The C++ Standard Library: A Tutorial and Reference
  12. Thinking in C++, Vol. 1: Introduction to Standard C++, 2nd Edition
  13. Thinking in C++, Volume 2: Practical Programming
  14. Game Programming Algorithms and Techniques
  15. API Design for C++
  16. Game Programming Patterns

Hope it helps.

The mistake I made as a game engine developer

I have made several mistakes as a game engine developer. However, there is a significant mistake I did in 2017 which I want to share with you.

At the start of 2017, I decided to put the game engine (Beta v0.0.4) to the test by developing a soccer video game. I wanted to test the limits of the engine, and a soccer game allowed me to do so. For instance, a soccer video game makes use of 3D animations, collision detection, rendering efficiency, etc.

At first, developing the game was fun. I learned about Artificial Intelligence, Graph Theory, how to develop a messaging system among the players, Dijkstra's algorithm, etc.

Here are some videos that show the evolution of the game:

First I learned how to control the armature of a 3D model as it is animated. In this case, managing the kick animation as it is about to kick the ball. If you are interested how I did this, read this article.

 
 

Then I learned how to enable communication among the players. That is, I implemented an AI messaging system:

 
 

I then improved the AI to analyze defending strategies:

 
 

Improved the AI to take into account all 22 players on the field:

 
 

I also cleaned up the AI architecture:

 
 

Finally implemented a pathfinder algorithm:

 
 

Implementing a video soccer game was fun but also time-consuming. In particular, creating the dozens of animations required for smooth gameplay. For example, you need to create a kick, passing, running, defending, halting animations, etc.

Developing the AI for the game took a lot of time. The AI is by far the most complicated aspect of a soccer game, and I spent a lot of time implementing it.

However, six months after I started working on the game, I stopped. I stopped development once I realized that I had lost focus. My goal has always been to develop a 3D game engine. I thought that developing a soccer game will help the engine. However, it didn't. Instead, I lost six months of development.

I learned a valuable lesson:

Do not test the engine with games that require complicated Artificial Intelligence. Instead, develop simple games that strategically test the engine's efficiency and response.

If you want to test the limits of your engine through complicated games, go ahead. But if you are an indie-developer like me, keep in mind that you have limited resources and that you have to be strategic about your time.

Ever since then, I've been focused on the engine again.

In version Beta-v0.0.5, I ported the engine to use the Metal API. (Since I already had the soccer game, it seemed convenient to use it for testing.)

 
 

I improved the rendering efficiency of the engine by implementing Frustum culling with a BVH tree algorithm (Beta-v0.0.6).

 
 

In version Beta-v0.0.7, I implemented a particle system, which can generate smoke, explosions and other particle types.

 
 

In version Beta v0.0.8, I fixed memory leakages and improved the rendering-ordering algorithm.

 
 

In the upcoming version, which I hope to share with you in a couple of weeks, I significantly improved the collision detection system of the engine.

As indie developers, we have limited resources and its crucial that you are strategic about them. I lost six months of development for not analyzing the impact a complicated AI game will have on the engine. I hope you don't make the same mistake as I did.

Thanks for reading.