8000 GitHub - lp249839965/hmm: Heightmap meshing utility.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

lp249839965/hmm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hmm

hmm is a heightmap meshing utility.

If you've done any 3D game development, 3D printing, or other such things, you've likely wanted to convert a grayscale heighmap image into a 3D mesh. The naive way is pretty simple but generates huge meshes with millions of triangles. After hacking my way through such solutions over the years, I finally decided I needed to write a good tool for this purpose.

hmm is a modern implementation of a nice algorithm from the 1995 paper Fast Polygonal Approximation of Terrains and Height Fields by Garland and Heckbert. The meshes produced by hmm satisfy the Delaunay condition and can satisfy a specified maximal error or maximal number of triangles or vertices. It's also very fast.

Example

Installation

brew install boost glm # on macOS
git clone https://github.com/fogleman/hmm.git
cd hmm
make

Usage

usage: ./hmm --zscale=float [options] ... infile outfile.stl
options:
  -z, --zscale       z scale relative to x & y (float)
  -x, --zexagg       z exaggeration (float [=1])
  -e, --error        maximum triangulation error (float [=0.001])
  -t, --triangles    maximum number of triangles (int [=0])
  -p, --points       maximum number of vertices (int [=0])
  -q, --quiet        suppress console output
  -?, --help         print this message

hmm supports a variety of file formats like PNG, JPG, etc. for the input heightmap. The output is always a binary STL file. The only other required parameter is ZSCALE, which specifies how much to scale the Z axis in the output mesh.

./hmm input.png output.stl -z ZSCALE

You can also provide a maximal allowed error, number of triangles, or number of vertices. (If multiple are specified, the first one reached is used.)

./hmm input.png output.stl -z 100 -e 0.001 -t 1000000

TODO

  • add a solid base (coming soon)
  • pre-triangulation filters? e.g. gaussian blur
  • export a normal map?
  • automatically compute some z scale?
  • better error handling, especially for file I/O
  • better overflow handling - what's the largest supported heightmap?
  • thread pool doesn't help much usually - get rid of it?
  • OpenCL rasterization?
  • mesh validation?

About

Heightmap meshing utility.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 84.4%
  • C++ 13.8%
  • Makefile 1.8%
0