Game Engine Beta v0.0.3

The last time I showed the progress of the engine was back in August where I showcased the first demo of the game engine. Since then I have been working on implementing new features and fixing several issues with the engine. Here is a video showing the progress of the engine:

 
In this beta version v0.0.3 of the engine, animations and collision detection can work simultaneously. The BHV algorithm was improved helping the engine make better decisions when pairing up 3D models for collision detection. The MVC (Model-View-Controller) flow of information was also improved.
 

Improvements

The beta version v0.0.3 of the engine can handle animations and collision simultaneously. The game engine can run an animation on a character and at the same time detect a collision. Furthermore, the engine allows a developer to apply action at any keyframe during the animation. For example, the engine allows you to apply an upward force during the second keyframe of an animation. You have direct control over the animation and which action to apply.

In this new version, I improved the flow of information between the Controller and the Model class. In previous versions, I had kept the flow of information in the MVC (Model-View-Controller) simplistic. In this new version, the model receives any actions on buttons and relays the information to the appropriate game character.

This version also improves the BVH algorithm. In the previous version, the BVH paired up incorrect models. This issue led several instances of missed collision detections. In this new version, all models are correctly paired up.

Issues

There is a major issue with the Convex Hull algorithm. For the most part, it works well with simple game characters. However, as soon as you model a character with complex modeling techniques, the algorithm fails. The problem is not a bug in the algorithm, but that it requires clean geometry to compute the hull.

It makes no sense to put a restriction on how to model a character. So, instead, I'm going to develop an external plugin to remove any restrictions. It will allow collision on any 3D character regardless of the modeling techniques used.

Thanks for reading.

How 3D animations work in a game engine? An overview

One of the hardest features to implement in a game engine is the animation of 3D characters. Unlike animation in 2D games, which consists of sprites played sequentially over a period, animation in 3D games consists of an armature influencing the vertices of a 3D model.

3D mesh and a bone armature

3D mesh and a bone armature

To animate a 3D model, the 3D model requires an armature. An armature is a set of 3D bones. Connecting the armature to the 3D model produces a parent to child linkage. In this instance, the armature is the parent, and the 3D model is the child.

Armature linked to the 3D mesh

Armature linked to the 3D mesh

Bones influence the space coordinates of nearby vertices. For example, rotating the forearm bone, transform the space coordinate of all forearm vertices in the 3D mesh. How much influence a bone has on a vertex is known as a Vertex Weight.

Rotating a bone affects nearby vertices

Rotating a bone affects nearby vertices

3D animations are composed of several keyframes. A keyframe stores the rotation and translation of every bone. As keyframes are played, the influence of bones on nearby vertices deforms the 3D model creating the illusion of an animation.

Animation with keyframes

Animation with keyframes

The data stored in keyframes and vertex weights are exported to the game engine using a Digital Asset Exporter (DAE). When a game engine runs an animation, it sends keyframe data to the GPU.

As the GPU receives the keyframe data, the bone's vertex weight and bone's space deforms the 3D model recreating the animation.

Game engine running an animation

Game engine running an animation

However, rendering only the keyframes received by the DAE may produce choppy animations. The game engine smoothes out the animation by interpolating the data in each keyframe. That is, it interpolates the bones' coordinate space between each keyframe.

Thus, even though a game artist may have produced only four keyframes, the game engine creates additional keyframes. So, instead of only sending four keyframes to the GPU, the game engine sends sixteen keyframes.

Hope this helps

Which language should I use to develop a game engine?

It depends on the type of games you want the game engine to support.

For example, the game engine I'm developing is designed to work on iOS mobile devices. Therefore, I had two choices for a programming language: Objective-C or C++. I opted for C++ for educational reasons.

Since my game engine supports mobile games, I had only two options for a rendering API: OpenGL ES 2.x or OpenGL ES 3.x.

I started development using OpenGL ES 2.x. Once OpenGL ES 3.x became available, I made the necessary changes to the engine to support OpenGL ES 3.x.

The game engine is also capable of rendering 3D characters modeled in Blender 3D, a Modeling Software used by game artists. Therefore, I used Python to develop a Digital Asset Exporter, a tool which retrieves character data in Blender. The Blender API is written in Python.

If I had designed the game engine to work on Android devices, then I would have used Java. If I wanted to use Cheetah 3D instead of Blender 3D, I would have developed the Digital Asset Exporter in Javascript. If I wanted to support PC games, then I could have used OpenGL 4.x (or even the new OpenGL generation, Vulkan).

So, before deciding if you want to develop your game engine in C++, Objective-C or Java, ask yourself what type of game engine you want to develop? Do you want it to support mobile games? PC games? What character modeling tools do you want it to interface? etc.

Remember, people don't care what language you used to develop an app. What they care is what the app can and can't do.

Hope this helps

Keep your APIs simple short and clean

Keep your APIs simple so that anyone can use it.

Keep your APIs short so that anyone can remember it.

Keep your APIs clean so that anyone can understand it (without reading the full documentation).

Hope this is helpful

How do you load data into a game engine?

If you are thinking of developing a game engine, or are in the process of it, you may wonder "How do you load data into a game engine?" One answer is to provide it manually. Although it may seem inefficient, it works perfectly for simple shapes and in early stages of development. However, as your engine improves, the best way to load data into a game engine is to develop a Digital Asset Exporter and a Digital Asset Loader.

Game engine development requires the development of an external plug-in that extracts geometrical data from a 3D character. This plug-in is known as a Digital Asset Exporter (DAE), and it interfaces with modeling tools like Blender 3D.

The DAE extracts data from Blender ( A 3D modeling tool)

The DAE extracts data from Blender ( A 3D modeling tool)

The DAE is part of a bridge between Blender and the engine. Whereas Blender helps with the creation of a game character, the DAE extracts data required by the engine.

The DAE extracts character's data in raw format

The DAE extracts character's data in raw format

At its most basic, the DAE extracts the following information from a character's mesh:

  • Vertices
  • Normal vectors
  • UV coordinates
  • Texture image

The Digital Asset Exporter is only part of the equation. Once the raw data is available, a Digital Asset Loader (DAL) loads the raw data into the engine's data structures. However, the DAE must provide the raw data to the DAL in an XML-format which the DAL can parse.

The Digital Asset Loader reads data (in XML format) from the DAE

The Digital Asset Loader reads data (in XML format) from the DAE

Once the data is in the engine's data structures, the rendering manager sends this data to the GPU for rendering.

The DAL loads data into the engine. The engine sends it to the GPU

The DAL loads data into the engine. The engine sends it to the GPU

Unlike the DAE which I developed using Python and resides outside the engine, the DAL was developed using C++ and is part of the engine.

In my experience, the most complicated part of developing a DAE was understanding the Blender API, getting acquainted with 3D modeling terminology and using Blender itself.

I am not an artist. So I had to learn Game Character Modeling before I was able to develop the DAE.

The DAL is straightforward to implement. I ended up using the TinyXML API which parses XML-format documents.

Hope this helps.