Programmers welcome! Stereo Imagination is a Python toolkit for generating and manipulating 3D geometry from code. This can be used to make visualizations, or as the basis for a graphics engine. There are other solutions out there, but Stereo Imagination also has the quality of being simple and transparent.
Source code and samples (38K)
Stereo Imagination is open source under the MIT License. Samples are CC0.
What you get
The toolkit is made of three major components:
- Py2STL, a library to generate and transform 3D geometry, then export it as STL files;
- Wire3D, a wireframe renderer coupled with loaders for 3D models in STL and OBJ formats;
- WireView 3D. a simple file viewer based on the above.
The latter can be used without any programming knowledge, but only from the command line as of 28 August 2018.
You need a Python runtime, either version 2.7 or 3.3+. It comes preinstalled on Linux and Mac; Windows users can get one from the Python.org website.
To run some of the demos, you also need the Pygame library, available from the Pygame.org website or various software repositories. WireView 3D only exists in a Pygame version at this time, but a more portable one is planned.
Edit: as of 23 April 2021, there's a native port of VireView 3D.
How to use
See the read-me file for Py2STL in the samples directory. Wire3D isn't documented yet; you'll have to read the demo source code. To use WireView 3D, call it from the command line like this:
You can rotate the model with the arrow keys, and zoom with +/-. The R key resets the view. Stick to models well below 10K polygons if you have an older computer, otherwise it will be quite slow.
Speaking of which: while the file loader can deal with arbitrary polygons, the renderer will only work correctly with triangles and quads. Other features of OBJ files such as materials or polylines will be ignored.
Known bug: resizing the viewer window works intermitently on some systems; just fiddle with the edges a little if you run into that.
Notes on the STL file format
Stereo Imagination only deals in the ASCII variant of STL. Binary files are not supported! If storage space is an issue, the format compresses very well.
STL files are only supposed to contain one solid each, but most modern applications seem to deal with multiple solids per file without a problem.
Conversely, STL files are supposed to have a free-form syntax, but most modern applications seem to treat it as line-oriented; this simplifies parsing.