MENU

Fun & Interesting

Making a 3D rotating ASCII cube in the terminal (full tutorial)

ComputerBread 2,166 lượt xem 3 weeks ago
Video Not Working? Fix It Now

Hello, this is ComputerBread,

Today, let's build a 3D rotating ASCII cube in the terminal, using only our brain, in zig!!!

No AI, no vibe coding, just a bit of math and brain juice!
This can serve as a gentle introduction to 3D graphics programming.

Source code:
https://github.com/ComputerBread/ASCII-3D/blob/7b4ccc1820a0c7445498479ee3f125bfb71b2fed/video.zig


Want to learn zig? Watch this video: https://youtu.be/q68oiUE2DWw
Leetcode playlist: https://www.youtube.com/playlist?list=PLuJfrVx3aQbG1_9k3khnuR0r2RaxExxse
JavaScript playlist: https://www.youtube.com/playlist?list=PLuJfrVx3aQbGQMDbtGcuIDY2892FA09b2

To support me (if you feel like it): https://ko-fi.com/computerbread/
Cheatcheet/mindmap: https://ko-fi.com/s/34966c8fb1
Twitter: https://twitter.com/ComputerBread
Subscribe: https://www.youtube.com/@ComputerBread?sub_confirmation=1

Chapters:
00:00:00 Intro
00:00:28 the different spaces
00:01:40 Handedness
00:05:35 Defining 3D cube
00:09:02 Perspective projection
00:16:40 Rotation
00:23:37 Scaling
00:27:56 Filling the cube
00:29:26 Triangles
00:32:10 Draw triangles
00:40:30 Draw Flat Bottom Triangle
00:50:43 Draw Flat Top Triangle
00:56:48 Back-face culling
01:05:37 Coding
01:06:59 Printing stuff on the terminal
01:31:15 3D cube
01:36:47 drawCube (high level)
01:46:25 drawScanLine function
01:49:53 drawFlatBottom
01:57:23 drawFlatTop
01:00:50 drawTriangle
02:09:41 drawCube
02:13:03 projection
02:22:10 rotation
02:34:49 back-face culling
02:43:31 deltaTime



(for the algorithm)
zig programming language, C, C++, rust, odin, low level programming, terminal, 3D programming, game dev, computer graphics

Comment