← Part 2 |
Intro
Once the digital elevation data has been manipulated and edited into a model then any subsequent processing will depend on what the model is to be used for. I have two main uses which result in slightly different workflows:
- Viewing the resulting model on a screen, e.g. on Sketchfab
- 3D printing the model
Each of these is described below but to follow my workflow for both you will need some custom software from https://github.com/john-davies/lidar-ply. The two command line executables – lidar2ply
and plymenu
have been built and tested on Linux only. They should work on Windows as long as you have a C++11 compiler.
Sketchfab Upload
To view a simple 3D surface that created from the LiDAR file then only the lidar2ply
executable is needed and is used as follows:
lidar2ply -f landscape.asc -i landscape.png -m
landscape.asc
is the ESRI Arc/Info format file exported in the previous postlandscape.png
is the image overlay exported in the previous post- the
-m
option specifies that a mesh is created automatically
A couple of things to note:
- For the -i option each pixel in the image is used to colour the corresponding vertex in the 3D model. For that reason both data and image files have to have the same number of rows and columns.
- The meshing algorithm assumes that there is a rectangular matrix of regularly spaced points. This is not a generic meshing algorithm 🙂
The output should be a 3D model file in PLY format that can then be loaded into Meshlab if any further processing is needed. After that it can be uploaded to Sketchfab for example:
The slightly surreal blocky object in the bottom left hand corner of the island is a low poly representation of the lighthouse 🙂 The sea around the island has been trimmed to reduce the model size below 50 Mbytes.
3D Printing
So far what we’ve created is effectively an infinitely thin surface which is fine for displaying on a screen but is no good for 3D printing as it has zero volume. Somehow we need to create a solid, watertight object preferably with a steady base to make the printing easier.
There’s an old but very informative post on the MathWorks website which describes the problem and suggests a couple of possible solutions as shown by the image on the left.
The surface can either be thickened to give it volume or blocked where the edges are extended downwards then closed off to create a stable base. The post gives some Matlab code which should implement either option but I don’t have a Matlab licence and I couldn’t get it to work using the open source GNU Octave. Rather than investigate in too much detail and because I wanted to add a few different features I decided to write my own code to implement the “Blocked” approach. Having written some PLY file handling code for the lidar2ply
utility then it wasn’t actually too difficult. The resulting program is called plymenu
and is also available on the GitHub page. It has a few different features but to use it here the following steps should suffice:
- Create the PLY file using the
lidar2ply
utility as above. Unless you have a very expensive 3D printer it’s probably not necessary to add a coloured overlay! - Open the resulting PLY file in
plymenu
- Select option “5 – Holes” then “2 – Find holes” followed by “3 – List holes” ( see note 1 )
- There should be one hole listed with text something line “#1: 2817 verticies”
- Select option “6 – Fill holes and add a base” and “1” as the hole number
- You now have an option to extend the bottom edge of the surface to create a base ( the green area in the image above ). This can either be a percentage of the overall height or an actual value. ( see note 2 )
- Once this is complete then quit back to the main menu and write the new PLY file. It should then be possible to import it into the 3D printing software.
Notes:
1. A key step in extending the surface correctly is to detect the opening at the bottom. This is done by running a hole detection algorithm on the whole mesh and there should be one big hole whose edge is the bottom of the surface. However occasionally there are other smaller holes ( depending on how the mesh was created ) so these are reported as well. Usually these are much smaller than the base so it’s fairly easy to select the correct one. These other small holes will need to be filled before the 3D print slicer will work and something like Meshlab will do this quite efficiently.
2. Two options for extending the base are given to handle the following situations
The original recreation for the rock model on the left can be seen here:
See https://theretiredengineer.wordpress.com/2018/10/28/lidar-3d-print-part-2/ for how the 8 tile landscape print was created.
3. The plymenu
software assumes that the model is in a sensible orientation with the Z axis running vertically up through the model. This is automatically the case for any models created from LiDAR files but not necessarily true for those created by photogrammetry. In the latter case a tool like Meshlab can be used to reorient the model as necessary.
Conclusion
This series of posts has hopefully summarised my current workflow as regards creating 3D landscapes. Obviously this has only scratched the surface but I’ve been using the same basic process for a while now so I think that it’s reasonably stable. Having said that I’m sure that I’ll be writing an update in the not too distant future 🙂