/voxel_orientations

A document that gives a guideline for implementing block orientations in voxel games.

Creative Commons Zero v1.0 UniversalCC0-1.0

While developing my voxel engine, I wanted to be able to orient all blocks. I wanted the orientation to include a rotation, and a flip (inverting the X, Y, or Z axes).

I also wanted to be able to orient orientations, which means that if I have an orientation that rotates and flips the block/mesh, then I can apply it to another orientation to get a new orientation that is distinct from the original two.

So I set out to find a way to implement these orientations for my game. The way I ended up doing it was by using massive match expressions (in rust). You can also use lookup tables, but the match expression is possibly faster. If you were using a different language than Rust, you would be using a switch statement (or similar syntax).

Full Writeup

Here are some videos of orientations being oriented:

X-Axis

x_axis_rotation.mp4

Y-Axis

y_axis_rotation.mp4

Z-Axis

z_axis_rotation.mp4

And here's what flipping looks like

flipping.mp4