A small and simple C++ CLI tool that converts greyscale heightmaps to 3D OBJ models. Uses lodepng and obj.
./hmap2obj <pngpath> <width> <height> <objpath> <extentX> <extentZ> <maxY>
- pngpath - Absolute path to the input png file.
- width - Width of the input png file in pixels.
- height - Height of the input png file in pixels.
- objpath - Absolute path to the output obj file.
- extentX - Resulting model extent on the X-axis.
- extentZ - Resulting model extent on the Z-axis.
- maxY - White pixels will be mapped to this Y value. All other pixels will be mapped to a value between [0; maxY] according to their greyscale value. A black pixel will always map to Y = 0.
Cmake files have been added to compile and use this library
mkdir build
cd build
cmake ..
make
A shell script file run.sh
has also been included with a sample code. To use it:
sh run.sh
The run.sh
file looks like this:
./build/hmap2obj/hmap2obj \
./example_screenshots/input.png \
1081 \
1081 \
./output.obj \
2 \
2 \
10
Further you can use an online viewer to view the generated obj file.