Skip to content

Dnyarri/img2mesh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

【EN】 〖RU〗

Bitmap to POVRay 3D triangle mesh converter

Python program for conversion of bitmap heightfield (in PNG or PGM/PPM format) to 3D triangle mesh in POVRay POV, Wavefront OBJ, Autodesk DXF and stereolithography (3D printer) STL format. Resulting triangle mesh provides better rendering in case of low-res source files as compared to using source bitmaps as a heightfield directly.

Example of img2mesh output rendering

Format compatibility

Import image format Export 3D mesh format
16 and 8 bits per channel PNG, PGM and PPM POV, OBJ, ASCII STL, ASCII DXF

Project content

  • img2mesh - suitable GUI frontend comprising all programs and functions.

  • list2mesh module, including:

    • list2pov: nested 3D list to POV-Ray scene conversion and output. Exported file contain fully operational scene;

    • list2stl: nested 3D list to stereolithography ascii STL object conversion and output. Exported file contain elevation map mesh plus sides and bottom as needed for 3D printer;

    • list2obj: nested 3D list to Wavefront OBJ conversion and output. Exported file contain elevation map mesh only;

    • list2dxf: nested 3D list to Autodesk ascii DXF conversion and output Exported file contain elevation map mesh only;

  • pypng and pypnm modules contain components providing PNG and PPM image files reading as nested 3D lists.

Preview of img2mesh output files in one folder

Dependencies

  1. PyPNG. Copy included into current img2mesh distribution.
  2. PyPNM. Copy included into current img2mesh distribution.
  3. Tkinter. Included into standard CPython distribution.

Installation and Usage

Programs distribution is rather self-contained and is supposed to run right out of the box. Program is equipped with minimal GUI, so all you have to do after starting a program is use "Open..." dialog to open image file, then use "Export..." to name 3D file to be created, then wait while program does the job, then open resulting file with suitable 3D software and render the scene.

For developers

Module list2mesh, including 3D-export functions, may be copied and used by other developers at will.

References

  1. POV-Ray and POV SDL specifications.

  2. Wavefront Object Files (.obj) specs from Paul Bourke collection.

  3. Stereo Lithography Files (.stl) brief description ibid.

  4. DXF Reference by Autodesk, Inc.

Related

Dnyarri website - the rest of Dnyarri stuff with previews etc.

github Dnyarri

gitflic Dnyarri