Skip to content

GazPrash/3dToASCII

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3D to ASCII Renderer

wolf demo

a little project that can take a .obj file, reads the vertex data, and then turn it into a moving ASCII chars in the terminal.

flow: the 3d coordinates are extracted from the obj file, and then projected onto a 2D space

projectedX = x / z;
projectedY = y / z;

screenX = ((projectedX + 1.0) / 2.0) * width;
screenY = (1.0 - ((projectedY + 1.0) / 2.0)) * height;

rotation is handled with using the standard transformation formula:

xNew = x * cos(angle) - z * sin(angle);
yNew = y;
zNew = x * sin(angle) + z * cos(angle);

and then each projected vertex gets mapped to a terminal cell, and the renderer picks a character based on depth:

.,:;ox%#@

In case of the web preview or any other graphic library, instead of rendering a char in the terminal cell, we can just basically render a circle or square as a point and then connect the points via face information using the convex hull extraction formula, and then we can render the points as well as a wireframe onto a 2D plane aka our screen.

run:

./3dToAscii.sh path/to/model.obj

you can also cap the animation length:

./3dToAscii.sh path/to/model.obj --frames 300

About

Small program that displays 3D files as ascii animations on the terminal

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors