Chapter 3 Algorithm
3.3 LEGO Brick Merging
3.3.3 Merging LEGO Bricks
In order to build a stable and low-cost sculpture, we need to consider the vertical connections and brick costs of all the valid legal bricks in the greedy merge algorithm.
As shown in Figure 3.15, brick A connects with brick B if they overlap in vertical.
Figure 3.15: Two bricks are connected when they overlap.
The connection of a brick means how many bricks it connects with. It influences the stability of a LEGO sculpture because bricks do not drop easily if they are connected by a lot of other bricks. A large brick has higher connection commonly. For example, a
24
2*4 brick can connect with 8 bricks at most, but a 1*4 brick only connect with 4 bricks.
The brick cost is determined by the number of each brick’s type. Larger bricks are less in reality. Consequently, though the large bricks own higher connections, their brick costs are higher because of their rarity. We can reduce the usage rate of the large bricks to cost down. Our algorithm deals with the trade-off between connection and each brick cost, then selects a valid legal brick with highest value. The value of a valid legal brick is computed as Eg. 7,
𝑉𝑏 = 𝛼𝑐1− (1 − 𝛼)𝑐2 (7) , where 𝑐1 is the connection, and 𝑐2 is the cost of a brick’s type. We square the connection in order to reinforce its influence. 𝛼 is the weight of 𝑝1. Higher α-value can strengthen the connections of bricks. Otherwise, the structure with low α-value is frail, but the demands for rare bricks are decreased.
In some special cases, it is not enough to take care of only connections and brick costs when merging bricks. Therefore, we propose three exceptions and show them as follows:
(a) In the button layer. The bricks are as larger as possible.
(b) If the brick does not connect with other bricks. 𝑉𝑏= −∞
(c) If the brick connects with other bricks and its center does not overlap the bricks it connect. 𝑉𝑏= ∞ + 𝑑𝑖𝑠𝑡, where 𝑑𝑖𝑠𝑡 is the minimal distance from the center of the brick to the centers of voxels it connects.
As displayed in Figure 3.16, 𝑑𝑖𝑠𝑡 is the distance between B1 and V2. Higher distance means that B1 is a larger brick. We use larger bricks to avoid producing bricks which are pendent. In Figure 3.18(a), B2 does not connect with other bricks, thus it cannot be built practically. Otherwise, there is not any brick pendent by using larger
25
brick B1, as shown in Figure 3.18(b). After increase exceptions, the process of calculating optimal brick value is presented in Peeudocode 4. Exception (a)(b)(c) are implemented at line 9, 11, and 14 respectively.
Figure 3.16: V1 and V2 are the voxels in the brick B3, which connects with brick B1. B2 is also a brick.
26
These exceptions reduce the bricks which do not connect with other bricks. Figure 3.17 shows the parts of the bunny sculpture. Our system merges a 2*4 brick which crosses the gap, as displayed in Figure 3.17 (c), so the brick does not drop into the gap and it becomes a good base for the above bricks, as shown in Figure 3.17 (e).
Figure 3.17: (a) the 19th, (c) 20th, and (e) the 21th layers of the bunny sculpture. (b), (d) and (f) are the assembly instructions of them respectively. (c) The effect of the exceptions. It chooses larger brick in priority, so that the bricks in the 21th layer can be
built successfully.
27
Chapter 4
Implementation and Results
In this chapter, we present our implementation and results. The explanation of how to decide the brick costs is discussed in section 4.1. Moreover, there are two modes to remove inner voxels. In section 4.2, we shows our results and the structures with different parameters.
4.1 Implementation
The implementation was under the Intel Extreme CPU X9650 with 3.0 GHz and 4GB memory. The IDE is Microsoft Visual Studio 2012. All the polygonal models are acquired from Google 3D warehouse, as shown in Figure 4.1.
Figure 4.1: (a) Coca. (b) Bunny. (c) Yoshi. (d) Dragon models.
There are two modes to remove the inner voxels: hollowing mode and adjusting CoM mode. If the projection of center of mass is located on the safe region after voxelizing, we can use hollowing mode. Therefore, all the erasable voxels are removed, and the model can be built with fewer bricks. The sculpture turns into a stable status
28
when the thickness of the shell is higher than 3-unit-brick, as shown in Figure 4.2. On the other hand, while a model’s center of mass is not situated on the safe region, we use adjusting CoM mode. Under this circumstance, the model’s center of mass is moved into the safe region. However, not all the erasable voxels can be removed because the current center of mass will be further away from the safe region, after removing the inappropriate voxels. Figure 4.3 illustrates the effect on adjusting center of mass. The voxels in the green dash area cannot be removed because they are not in the same half space with center of mass. After adjusting the center of mass, we cannot use the hollowing mode for the same model.
Figure 4.2: The structures of 7th and 8th layers of the bunny sculpture. The thickness is 3-unit-brick.
29
Figure 4.3: (a) and (b) show the structures of the 8th and 9th layers of the voxelized coca model. The shell’s thickness of the model is a 2-unit-brick length.
In a LEGO box, there are several types of bricks with different quantities. Figure 4.4 presents the quantities of the brick types in a LEGO box. The less quantity of the brick type, the higher the brick cost is. Take red bricks as an example, 1*2 and 2*2 bricks are more than others, thus, we can use them more frequently. In contrast, there is only one 2*8 brick in this box, so we raise its cost to reduce the usage rate. The cost is the quotient of dividing 1*2 brick’s quantity by each brick type’s quantity, and then we modifying them by trail-and-error to get suitable costs. Most of the costs are based on their quantities except for the 1*1 brick, since it owns little connection. We raise its cost to avoid using it too often. Table 4.1 shows the actual costs of bricks in our system.
30
Figure 4.4: The content of a LEGO box. It shows the quantities of each brick type.
Brick type Number Cost Brick type Number Cost
Our method is powerful and flexible. For example, the same bunny model can be rotated to a new pose that the tail is contacted the ground, as shown in Figure 4.5.
Because the projection of the center of mass is not in the safe region, the adjusting CoM mode is applied to remove inner voxels. Figure 4.6 illustrates the structure of the lowest layer. The oblique bunny sculpture can stand stably even though only a few bricks touch to the ground. In Figure 4.7(b), we notice that although some bricks do not connect with below layer, they can be connected by the bricks in the above layer. Finally, users can still finish the bunny sculpture successfully, as shown in Figure 4.7.
31
Figure 4.5: (a) The oblique bunny model. (b) The voxelized model. (c) The LEGO sculpture whose ear is pendent. The bricks in the bottom of the ear do not drop
because they are connected by the bricks in the above layer.
Figure 4.6: (a) The voxels in the lowest layer. (b) The structure of the lowest layer.
(c) Real LEGO bricks built based on (b). (d) The final sculpture.
32
Figure 4.7: (a) to (d) are the 14th, 15th, 17th and 18th layers of the oblique bunny sculpture. (a) and (b) show the right bricks cannot connect with the below layer. (c) and (d) display the ears of the bunny finally connecting the bunny’s body positively.
Figure 4.8 displays the bunny sculpture. Because the center of mass lies in the safe region, we use the hollowing mode to remove erasable voxels. Hence, the weight of the sculpture will be lighter than the solid one. Figure 4.9 shows some inner structures of the bunny sculpture and their assembly instructions. Our system can uses suitable bricks to cover the gaps among the bricks.
33
Figure 4.8: The polygonal bunny model is transformed to a LEGO sculpture with 19 layers.
Figure 4.9: (a) to (d) show the 9th to 12th layers of the bunny sculpture and their assembly instructions. Its thickness is 3-unit-brick.
34
Figure 4.10 presents the sculpture of the dragon. The bottom layer of the dragon model is separated into two parts, and will be assembled in the 6th layer. Figure 4.11 exhibits the sculpture of Yoshi. The Yoshi model is not stable because it only uses one leg to stand. After adjusting the center of mass, the sculpture can stand stably in real world.
Our system can produce sculptures with different resolutions, and users can choose a suitable one to create sculptures. The resolution of a LEGO sculpture is determined by the number of layers. Figure 4.12 shows the coca sculptures with 33 layers and 22 layers. For the same polygonal model, the more layers the sculpture has, the more precise the resolution gets. The partial inner structures of the coca sculpture with 22 layers are presented in Figure 4.13 and 4.14. In Figure 4.14 (e), the yellow 2*8 brick crosses the gap, so users can finish the remaining layers.
35
Figure 4.10: (a)(b) The polygonal and voxelized model of dragon. (c)(d) The sculpture with 22 layers is built practically and shown in different views. (e) The structure of the bottom layer. It is separated into two parts. (f) The structure of the 6th
Layer. The red brick is a 1*8 brick which assembles the two parts of the dragon.
36
Figure 4.11: (a) The Yoshi polygonal model. (b) The Voxelized model. (c) The Yoshi sculpture. (d) The Yoshi sculpture use only one leg touching the floor.
37
Figure 4.12: (a) The polygonal model of coca. (b) The sculpture with 33 layers. (c) The sculpture with 22 layers. The sculpture in (b) is larger and more delicate than the
sculpture in (c).
38
Figure 4.13: The layer’s structures of the coca sculpture. The order is from (a) to (f).
In the adjusting CoM mode, we do not all erasable voxels.
39
Figure 4.14: The layer’s structures of the coca sculpture. The order is from (a) to (f).
(d) shows how the large brick crosses the gap.
40
In the process of merging bricks, users can modify the α-value based on their demand. The structures with different α-value are shown in Figure 4.15. The structure is assembled with lots of large bricks when α is equal to 1.0. On the other hand, if α is equal to 0.0, the structure uses 1*2 bricks too often. All the assembly instructions of our results are designed with α = 0.5.
Figure 4.15: The structures with different α-value. Structures with greater α-value use more larger bricks.
The executing time of different models is shown in Table 4.2 and 4.3. Models with greater number of voxels spend more time to remove voxels. Besides, Adjusting CoM mode need more time than hollowing mode when the two models with similar number of voxels. The models with high resolution contain more voxels, so it needs much more time to merge voxels into bricks. Besides, if the structures of a model is more piecemeal, it costs less time because of the smaller set of valid legal bricks. Figure 4.16 shows the structures of the dragon and the coca. The dragon is piecemeal, so the executing time is less than the small coca even though the voxels of the dragon is more.
41
Table 4.2: The executing time of removing voxels.
Table 4.3: The averages of the executing time and the numbers of generation bricks for 20 runs of the five models
42
Figure 4.16: The structures of the dragon and coca model.
4.3 Limitation
There are two limitations are presented in this section. First, the assembly instructions exist some bricks which cannot be assembled. Despite we merge voxels on a shell in priority, some bricks cannot be built because there is not any brick supporting them in the below layer, as illustrated in Figure 4.17. Second, if the object is too tilted, we cannot move the center of mass into the safe region. As shown in Figure 4.18, although we have been adjusted the center of mass, the projection of the center of mass moves slightly
Figure 4.17: The left image shows that there are some bricks cannot be built. The bricks are connected by the above bricks in the right images.
43
Figure 4.18: (a) and (b) shows the projection of center of mass before and after adjusting the center of mass.
44
Chapter 5
Conclusion and future work
In this thesis, we presented a system to build a LEGO sculpture easier. By adjusting center of mass, choosing a polygonal model becomes more flexible and users can build various poses of sculptures from the same model. The proposed greedy merge algorithm deals with the trade-off between the connection and brick cost. In addition, we also proposed 3 exceptions to make the sculpture more stable and buildable.
Therefore, the assembly instructions designed by our system let users be able to build stable and low-cost sculptures.
The first step of our approach is transforming a closed polygonal model to a voxelized model. Next, removing proper erasable voxels reduces the number of bricks which makes the sculptures stand stably in any poses. Third, the proposed greedy algorithm is used to optimize the structure of each layer. Finally, the structures of each layer are treated as the assembly instructions for users to build wonderful and stable sculptures.
Building colorful sculptures is one of our future work. The colorful sculptures can be more like the original models by following the color of the polygonal models.
Moreover, the instructions can present structures in different modes. As shown in Figure 5.1, the instruction illustrates the process of building a fox. It guides users to build the head and the body separately and assemble legs in the last step. This mode makes it easier to assemble the pendent parts, such as bunny’s ears.
45
Figure 5.1: The instruction of building a fox sculpture. It is designed by KAWADA CO., LTD.
46 Construction. Jens Gravesen and Poul Hjorth, 81-94
[4] Green, D. and D. Hatch. (1995). Fast Polygon-Cube Intersection Testing, in Alan Paeth, ed., Graphics Gems V, AP Professional, Boston, pp. 375–379.
http://www.graphicsgems.org/
[5] Lambrecht, B. (2008). Voxelization of boundary representations using oriented LEGOR® plates.
[6] Petrovic, P. (2001). Solving LEGO brick layout problem using Evolutionary Algorithms. In Proceedings to Norwegian Conference on Computer Science.
[7] Prévost, R., Whiting, E., Lefebvre, S., & Sorkine-Hornung, O. (2013). Make it stand: balancing shapes for 3D fabrication. ACM Transactions on Graphics (TOG), 32(4), 81.
[8] Silva, L. F., Pamplona, V. F., & Comba, J. L. D. (2009, October). Legolizer: A Real-Time System for Modeling and Rendering LEGO Representations of Boundary Models. In Computer Graphics and Image Processing (SIBGRAPI), 2009 XXII Brazilian Symposium on (pp. 17-23). IEEE.
[9] Smal, E. (2008). Automated brick sculpture construction (Doctoral dissertation, Stellenbosch: Stellenbosch University).
47
[10] Song, P., Fu, C. W., & Cohen-Or, D. (2012). Recursive interlocking puzzles. ACM Transactions on Graphics (TOG), 31(6), 128.
[11] Stava, O., Vanek, J., Benes, B., Carr, N., & Měch, R. (2012). Stress relief:
improving structural strength of 3D printable objects. ACM Transactions on Graphics (TOG), 31(4), 48.
[12] Testuz, R., Schwartzburg, Y., & Pauly, M. (2013). Automatic Generation of Constructable Brick Sculptures. Eurographics 2013-Short Papers, 81-84.
[13] Van Zijl, L., & Smal, E. (2008). Cellular automata with cell clustering. Automata, 425-441.
[14] Voorhies, D. (1992). Triangle-cube intersection. Graphics Gems III, 236-239.
[15] Asholay Distribution Ltd (2011). Nanoblock History. 2011. Retrieved July 4, 2014, from http://www.nanoblockuk.com/About.html
[16] Phil Lord, & Christopher Miller (2014). THE LEGO MOVIE. Retrieved July 4, 2014, from http://www.thelegomovie.com/
[17] Telegraph Media Group Limited (2008). Lego named Britain’s favourite toy.
Retrieved July 4, 2014, from http://tinyurl.com/p4scvw
[18] Vaunt Design Group (2005), Lego history: Invention of lego. Retrieved July 4, 2014, from http://tinyurl.com/pljydl