3D First Person Demo (2016)

INFO

Synopsis

A 3D First Person demo made in OpenGL for a school assignment. Made by Lim Ngian Xin Terry and Chua Teck Lee.


Features

Base Framework (Using Entity-Component-System)

Scene Graph

Spatial Partitioning

Level-Of-Detail

Collision Detection

Physics


Thoughts

For this assignment, I’ve learnt a tremendous amount out of it. Firstly, instead of using the framework provided by the school, I decided to completely overhaul and pretty much rebuilt it from scratch. The first major difference was that I designed the framework based on the Entity-Component-Systems method. Where rather than having objects inherit each other, there was only 1 GameObject class, and to by giving the GameObjects various components, we were able to produce different behaviors. The components would only contain data, and it was up to the various systems to interpret and use that data. It is even possible to add and remove components during runtime. My main inspiration was by trying to emulate how Unity did it. I would see how Unity did certain things, and try to see if I could find a way to replicate it.


Secondly, having completed the Scene Graph, it is much easier to handle the GameObjects when multiple objects are related, and allows for many things, such as destroying parent objects causes the child to be destroyed as well, but when destroying the child object the parent does not get destroyed. This means that in the future it would be allot easier to make modular enemies that can get different damage based on where in their body they were hit.


Thirdly, for the Level of Details, simply using distance to determine what detail level to present caused a major problem. If the player was far away from the object, and zoomed in with say, a sniper rifle, the object would still look low-poly and low-res. To solve that issue, we made a rough estimation of the size of the object on the screen, and change the level of detail based on that.


Lastly, we were able to optimise collision detection due to the Spatial Partitioning. It allowed us to skip unnecessary checks and keep performance loss to a minimum. We opted to make the spatial partition 3D as well, rather than 2D, to further cut down on unnecessary checks.

Spatial Partitioning

SceneGraph (Setting Parent)

SceneGraph (Destroying parent destroys all children.)

Level of Detail