This project helped me experiment with a technic to emulate how enemies are drawn in old shooters such as Wolfenstein and Doom. In these, enemies are represented by several sprites, one for each point of view. The engine decides which sprite to draw depending on the orientation of the enemy relative to the player camera. This give the illusion that the enemy is in 3D. The algorithm that I used is heavily inspired by an article by Ryan Brucks on UE4 impostors.
In Doom, enemies only have 8 possible view angles but I wanted to be able to observe an enemy from any angle, including from the top or the bottom and also I wanted to increase the number of view angles. This would considerably increase the number of sprites. So I needed to automate the process as much as possible.
To generate the sprites, I start from a 3D model in Blender. A create a Python script which builds a sphere around the model, and from each vertex, makes a render from the position of that vertex. This gives me a list of sprites.
From that list I build a spritesheet using TexturePacker so I can use it in BabylonJS. I build a sphere ingame using a similar algorithm as the Python script (the order of the vertices is important). To determinate which sprite to draw, I cast a ray from the camera to the sphere. At the impact point, I look for the closest vertex. Its index matches the index of the sprite I need to display.
TypeScript
BabylonJS
Webpack
Blender
Python