Last week we saw a Dynamo graph that imports a point cloud from an ASCII-based format to specify the initial locations for a fun flocking simulation.
This week we’re going to look at a graph that uses a similar import technique but rather creates a voxel model based on the point cloud:
The main difference from the previous import code is that rather than returning a list of Point objects, we’ve tweaked the code to return 9 doubles for each point that are taken as triangle definitions. The little secret is that the triangle’s vertices are coincident: we use the same XYZ coordinates 3 times.
VASA’s VoxelModel has a handy ByTriangles node that will consume this list to populate itself: wherever a point (defined as a zero area triangle) is ingested that sits within a voxel, that voxel then gets switched on. Obviously many (if not all) voxels will get “hit” by multiple points, so this does in effect simplify the point cloud. And you can choose to read a lot fewer points – we read 1 in a 100 or so – from the file and get a very similar-looking voxel model.
A quick word of warning when looking to make this work with your own point cloud data: when working with grid- or voxel-based tools it’s important to get the scale and resolution right, otherwise you run out of available memory or the calculations take too long. This is perhaps even more important when working with data coming from something like a point cloud, as you can quickly hit problems. VASA will warn you when you allocate beyond a certain limit, though, so it should be obvious when you’re likely to run into issues.
This mechanism allows us to work with point clouds as if they’re solid, which is pretty cool. There are number of parameters that are interesting to play with in the graph, so let’s take a look at them.
Firstly there’s the ability to expand the generated voxel model using SurfaceOperations.ExpandAlongX (and Y and Z). Here’s an animation showing the changes with this set from 0 to 3. (We use 1 in the graph.)
Next is the Level of Detail (LOD) that is used in the ByTriangles call. Here we look at the values of 0 to 5. (We use 4 in the graph.)
To show that this is a shell – rather than being completely solid – I created the below animation from a series of horizontal slices through the model. You can imagine using this technique to extract a floorplan from a more elaborate point cloud showing a building’s internal structure.
Here’s the graph for you to experiment with. You will need to download the archive from the previous post to get the point cloud (which is pretty huge), as I didn’t want to post it again.
In an upcoming post we’ll take a look at some of the other fun things you can do with a voxel model created from a point cloud. A quick teaser: have you ever seen a point cloud that casts shadows?