As we have seen in chapter 8, it is possible to create a LEGO mosaic of any image out there (with some help from software, of course). But in the case of most mosaics, we are using 3-dimensional LEGO pieces to represent 2-dimensional images by exposing just one face/side of each LEGO piece that is used.
It is reasonable to assume that there is also a way to use LEGO pieces to build a replica of any 3-dimensional object. In fact, we have already seen in some of the previous chapters how LEGO can be used to build replicas of buildings and other common objects. We have covered the techniques used to build regular walls, angled walls and even round walls. But it is a far cry to go from building a LEGO model of your house to say, a model of your dog. Where do you even begin?
When we design a model of a house, we would typically get the measurements, determine the right scale to use and so on. But this doesn’t seem very practical for something like a dog. There would be far too many measurements to keep track of (if there was even a way of getting them in the first place). Also, a dog is made up of complex, organic shapes and there is no good way to intuitively figure out how to arrange LEGO pieces to recreate these shapes. This is where, once again, we need software to come to the rescue.
If we had a 3D equivalent of an image file that contained information about the shape of the object, we could have software to convert it into a LEGO model. In fact, this is exactly how a vast majority of the LEGO sculptures you have seen online or in Legoland were probably created. The 3D equivalent of the image file is called a 3D model and much like an image file, it can be created in one of several different formats – STL, OBJ, PLY, DAE (Collada) being some of the common ones. These files are primarily created for use by 3D printers, but we can also use them to help create LEGO sculptures.
It would be beyond the scope of this book to discuss how these 3D model files are created but you can easily find a wide selection of these files available online either for free or for a nominal cost. One caveat with the use of software to create LEGO sculptures is that the output is never perfect. There may still be quite a bit of work needed to fine tune the model and build it in a way that makes it sturdy, but that sure beats creating a LEGO sculpture without using any kind of software (if that is even possible).
Now let us look into how 3D model files are organized. We will cover the most common format known as STL. STL is just a simplified form of the word stereolithography which is the process used for 3D printing. However, people assume that STL stands for Standard Tessellation Language or Standard Triangle Language because tessellation and triangles are two of the keywords related to how STL files are used to describe 3D surfaces. Tessellation is the process of covering a surface with one or more geometric shapes with no gaps or overlaps (much like the way we cover a floor with tiles). Any complex 3D surface can be tessellated into a mesh of interconnected triangles also known as facets (see Figure X).
Each triangle has 3 sides and 3 vertices and the STL file basically contains X, Y and Z coordinate information for these vertices. STL files can be in a binary format (for reduced file sizes) or a regular text format. If you were to open one of the files in a text format, you would see entries like the following for each of the triangles that make up the mesh. In addition to the coordinates of the vertices, we also have the surface normal for each facet which basically tells us which face of the triangle is facing outwards.
A simple shape like a cube (Figure X) can be represented using as few as 12 triangles (2 triangles making up each side), but a more complex organic shape would need many more triangles to accurately represent its surface geometry. In general, the more triangles we have in our mesh the more accurate our 3D model would be, but this also increases the computational requirements for making use of the 3D model. It is possible to use software to simplify a mesh (in a process known as decimation), combining triangles to reduce their total count (this creates a coarser representation of the original shape but can be useful in 3D printing).
Once an STL file is loaded into a program that can manipulate it, it is possible to translate (shift the mesh in 3D space), rotate (along one or more of the axes) or scale (expand or shrink) it along one or more dimensions. As we will see, it is very useful to be able to scale the mesh to compensate for the geometry of the pieces that would make up a LEGO sculpture.
The first step in converting a 3D shape into a LEGO sculpture is known as voxelization (and this happens under the hood of the software we are using). Just as an image is made up of a regular grid of square picture elements or pixels, a 3D shape can be broken down into a 3-dimensional grid of cubes known as voxels. The simplest voxelization algorithms work by subdividing each triangle in the mesh into smaller triangles until each side of each triangle is smaller than the voxel pitch (size of each voxel). Then each voxel location in the grid that contains one or more triangles inside it is marked as an occupied voxel.
If we were looking to build a sculpture that is, say, 16 studs wide in the X dimension, it would make sense to pick a voxel size such that our voxelized representation of the 3D mesh has 16 occupied voxels counted along the X axis.
Once we have this voxel grid, is creating the LEGO sculpture as simple as replacing each voxel with a 1×1 LEGO brick? Conceptually, yes, but in practice there are a few wrinkles we must deal with. For one, unlike a voxel, a LEGO brick is not a perfect cube. It is a little taller than it is wide (even if you disregard the stud at the top). The ratio of the height to width of a 1×1 brick is 6:5. If we simply place a LEGO brick in each occupied voxel location, we will end up with a sculpture that looks vertically stretched.
To get the right proportions in our sculpture we would have to scale the 3D model in the vertical (Z) axis by a factor of 5/6 before voxelization. This way when we voxelize the mesh and replace each voxel with a 1×1 brick, the correct proportions are restored in the resulting sculpture. The second problem is that it is not practical to just stack 1×1 bricks. These bricks will have to be converted into longer bricks and placed in a way that creates a fully interlocked structure.
Converting a random voxel grid into a LEGO model that can be built using real pieces, is a complex mathematical problem that is the subject of many scientific papers. Most software that creates LEGO sculptures addresses the problem by using the basic techniques that we covered in chapter 3 (overlapping bricks to avoid joints that line up either vertically or horizontally, alternating the orientation of bricks between layers, etc.). The LEGO sculptures built this way (by stacking bricks placed with their studs facing up) are known as studs-up sculptures and these are the most common type of LEGO sculptures. Large studs-up sculptures are usually hollow with some kind of internal framework (built out of regular bricks or Technic beams) that provides support.
Mixing bricks and plates in studs-up sculptures
LEGO plates are one third as tall as bricks and this means we can have 3 layers of plates in the space occupied by one layer of bricks. This should technically allow us to capture more detail in the same overall size. But is there any benefit to building an entire sculpture using plates (with a significantly higher piece count and cost)? Not really. If the LEGO pieces in our sculpture are stacked normally with their studs up, we will only be able to add more fine detail in the vertical (Z) dimension. In other words, only the surfaces of the sculpture that face upwards and downwards can benefit from the use of plates while there is no extra detail added to the sides of the sculpture.
What makes more sense is to build the sculpture out of bricks for the most part, with some plates added on the top and bottom surfaces for improved detail. The easiest way this can be implemented in software is by breaking the 3D shape down into voxels representing each plate. Before we do that, the 3D mesh will have to be scaled by a factor of 5/2 in the vertical (Z) axis. This is to compensate for the fact that the ratio of the height of a 1×1 plate to its width is 1:2.5 or 2:5. Once the 3D mesh is converted into a voxel grid, we can replace each occupied voxel with a plate. The last step of course would be to combine 3-high stacks of plates into bricks wherever possible.
Studs-out sculptures extend the idea of the Lowell sphere (Chapter 7) to sculptures in general. If plates help preserve more fine detail than is possible using bricks, but only in the direction that their studs are facing, why not build the sculpture with its entire outer surface lined with plates? These plates could have their studs facing out in one of the six possible directions (top, bottom, front, back, left and right).
While this may seem like a compelling idea, studs-out sculptures can be quite challenging to design and build. How exactly do you determine the orientation of each plate in the studs out sculpture? How do you ensure that the plates pointing in the 6 different directions mesh together with no overlaps or gaps? Lastly, unlike a studs-up sculpture, a studs-out sculpture cannot support itself. It would need a SNOT core on the inside to support it (much like a Lowell sphere). The plates facing the 6 different directions would form 6 panels that can be attached to the SNOT core.
Back in 2006 Bram Lambrecht (who had earlier created a program to generate Lowell spheres of any size) came up with Lsculpt – a program that could convert 3D models into studs-out sculptures. This program generates a shell of the studs-out sculpture that is made up of 1×1 plates, but it is up to the user to combine those plates into interlocked panels and create the SNOT core, so the sculpture can actually be built. There is no fully automated solution available for generating studs-out sculptures.
Let us look into what is actually involved in creating a studs-out sculpture. The method Bram Lambrecht invented takes advantage of the fact that stacking 20 1×1 plates in 4 columns of 5 plates each (see Figure X) creates a perfect cube (if you disregard the studs themselves) with a dimension of 2 studs. This cube could be oriented with the studs pointing in one of six possible directions and still fit within a space that is 2 studs wide, 2 studs deep and 2 studs tall (disregarding the space occupied by the studs themselves).
And so, if our sculpture needs to be 16 studs wide, we could break the 3D mesh down into a voxel grid that is 8 voxels wide. Each voxel would have a dimension equivalent to 2 studs. Let us call this the coarse voxel grid. In parallel, we can also voxelize the 3D mesh into plates like what we did for studs-up sculptures – except this time we would have 3 different voxelized representations with the studs on the plates oriented along the X, Y and Z axes respectively. These 3 voxelized representations (let us just call them A, B and C) would also be aligned with the coarse voxel grid we created earlier with each coarse voxel containing up to 20 plates oriented along one of the 3 axes.
The studs-out sculpture can be created by going through each coarse voxel and picking the orientation of plates (from A, B or C) that would allow us to preserve the most amount of detail. What is the best way to determine this orientation? We can use an algorithm that considers the surface normals of the triangles in the 3D mesh that are contained within the space occupied by each coarse voxel and figures out the dominant orientation. Given that A, B and C are aligned to the same coarse voxel grid, we will not have any gaps or overlaps in the resulting studs-out sculpture.
The algorithm mentioned above isn’t always perfect, especially for complex 3D models that have features thinner than the size of our coarse voxel. Here the surface normals for the triangles within each coarse voxel in the regions with the thin features may be pointing in opposite directions making it harder to determine a single dominant orientation. So, there may always be a need to manually adjust the orientation of plates in some parts of the studs-out sculpture to ensure that it can be built using real pieces.