Michael Fogleman created ln; a rendering engine that produces 2D vector graphics (think SVGs) depicting 3D scenes.
Each 3D scene consists of a collection of 3D objects of different shapes (basic shapes like cubes, spheres, cylinders and triangles are supported). An object has a position and scale, and texture: a set of lines on the surface of the object.
When the scene is “rendered”, all lines are split into tiny segments. A ray tracer is used to determine the visibility for each segment. By merging all visible segments back to lines, the full set of visible lines of the 3D scene is found.
The original engine is written in Go. The full source code can be found on GitHub: https://github.com/fogleman/ln.
- 3D Line Art Engine: Spheres
- 3D Line Art Engine: Function
- 3D Line Art Engine: CSG
- 3D Line Art Engine: Skyscrapers
Note: not all code is ported and not all code-paths are tested: there are probably still (a lot of) bugs left.
Another strategy for finding all visible lines of a polygon-based 3D scene is by projecting all 3D polygons to the screen and then draw them front-to-back. For each new line, an intersection test with the polygons already drawn determines the visibility of (parts of) the line. I have used this method for many of my turtles, including Cubic space division #2.
If you like this post, you may also like one of my other posts:
- Marker Detection for Augmented Reality Applications
- Procedural cubic city
- Doom 3 – OpenGL Shading Language
- Tokyo – breakdown of a webgl fragment shader