Blogs

Contents

rtdev logo

Cube spawner: 3D cubes on a terminal

The Math: Rotation & Projection

Code Walkthrough

Contents

The project is fully open source. Please refer to the following link https://github.com/RohitRTdev/cubeSpawner.git. Before we get into it, here's what it actually looks like running.

cubeSpawner rendering wireframe cubes with nothing but '*' characters

cubeSpawner is a small Windows console application that renders wireframe cubes in 3D, using only the asterisk character. There's no graphics API involved anywhere - no OpenGL, no DirectX, not even a GPU. Every cube is just 8 points floating in an abstract 3D space, and the entire renderer is a few hundred lines of C++ that does the two jobs a real graphics pipeline does, just by hand: move the points around with some matrix math, then figure out which characters on a 2D grid of console cells those points land on.

In this blog we'll go through the code and also understand the simple math behind how this works.

Once you've cloned and built it (it's a Visual Studio project, so open rotatingCube.sln and hit run), here's what the controls do:

In case of queries or mistakes you may find, please reach out to me via my email - rohit20011002@gmail.com