• 沒有找到結果。

Chapter 1 Introduction

1.2 Thesis Organization

This thesis is organized as follows: In chapter 2, we review the related work about voxelization, the stability of a LEGO sculpture, and legolization. Then, we will show the flow of our proposed system and describe the detail of each process in chapter 3.

Chapter 4 shows our implementation and result. Conclusion and future work are discussed in chapter 5.

4

Chapter 2 Related Works

2.1 Voxelization

A LEGO sculpture is assembled by lots of bricks. Therefore, before analyzing a LEGO structure, we should transform the polygonal model to voxels. We denote this process as “voxeliztion”, which is a mature topic. Silva et al. [8] voxelized a polygonal model to a set of colored voxels and showed them on a screen. They subdivided a triangle to smaller sub-triangles in order to guarantee that a triangle only intersects with one voxel. Therefore, the color of a voxel can be determined by the triangle which it intersects with. However, the color of a voxel is not necessary for our system so we do not need to subdivide triangles. Voorhies [14] tested the intersection between a cube and a triangle to voxelize a polygonal model. He reduced the number of voxels by doing a series of acceptance/rejection tests to speed up the intersection test. Green and Hatch [4] improved the efficiency of Voorhies’ approach. They tested whether the point is in the skewed rhombic dodecahedron in acceptance/rejection tests to make the test more robust. In addition, they made the test be able to deal with arbitrary triangles. We use Akenine-Möller’ method [1] to test intersections among triangles and cubes based on separating axis theorem (SAT). This approach tests whether the projections of a triangle and a cube onto an axis are overlap or not. It is 2.3 times faster than Green and Hatch’s approach.

5

2.2 Stable Structure of LEGO Sculptures

Several researches are proposed after the LEGO Company presents the question

“how to build a sculpture fast”. Gower et al. [3] proposed six heuristic rules, which are shown as follows:

1. High percentage area of each brick should be covered. It can increase the stability of the LEGO sculpture and the connection of each brick.

2. Larger bricks are better. Large bricks are not only increase the connection, but also decrease the sum of brick number.

3. The direction of each consecutive layer should not be the same. It increases the stability of the full sculpture, and decrease the chance of local connection (Figure 2.1 (a) (b)).

4. The vertical boundary (Figure 2.1 (a) (b)) must be covered by the above and below layer. It can help to avoid local connection and unconnected sculpture.

5. If two bricks form T-shaped boundary with its neighborhood, its middle will be at the boundary of its neighborhood (Figure 2.1 (c)).

6. If a brick covers a vertical boundary in previous layer, it should match the boundary (Figure 2.1 (d)).

6

Figure 2.1: The illustrations [9]. (a)(b) The arrows are the directions of bricks. The black boundaries of the two bricks are the vertical boundary. (c) Both of the two red

bricks form a T-shaped boundary with their neighborhood (the blue and yellow bricks). The middle of the red bricks are match the boundaries of their neighbors. (d) When the center of the red brick match the boundary of the bricks in previous layer, it

reinforce the stability.

The direction is the longer side of a brick. Vertical boundary is the boundary of a brick looked in top view. Gower used these heuristics to design a penalty function and calculated the minimum penalty value with simulated annealing algorithm. The more heuristics this model satisfies, the less the penalty value is. In other words, the sculpture is more stable. However, it spends too much time and they never built a LEGO sculpture practically. Petrovic [6] proposed a gene algorithm to replace simulated annealing algorithm. But they still did not build any sculpture in reality.

Van Zijl and Smal [13] used cellular automata to merge and split voxels. Based on

7

Gower’s heuristics [3], they designed a cost function to determine whether to merge a voxel into a brick. Although this method is not a traditional optimal algorithm, it still needs lots of time to check the rules of heuristics.

Another methods to increase the stability of a sculpture is interlocking. Song et al.

[10] was inspired by the interlocking puzzle, whose puzzles can be locked by another puzzles. They used a recursive method to design a puzzle one by one from a voxelized model and ensured that the newest puzzle can lock others. Their approach indeed creates a stable sculpture, but the shape of the puzzles designed by them is various, as shown in Figure 2.2. Thus, this method cannot be used in LEGO sculpture. Stava et al.

[9] proposed a stress relief method. The method we use to adjust center of mass is similar to theirs. They reduced the pressure of some frail parts by hollowing the inner areas. However, they still needed struts to reinforce the stability of models. In our approach, we remove inner voxels to adjust the center of mass of the whole model instead of the frail parts. Therefore, if the center of mass is moved to the ideal position.

The model can stand stably without any struts.

Figure 2.2: The left image shows the puzzle pieces Song et al. created [8]. The right one shows the common bricks we use.

8

2.3 Legolization

Silva et al. [8] provided a process of subdividing triangles and voxelization by using GPU. They transformed a polygon model to a LEGO sculpture efficiently. However, this technique just showed the models on screen after legolizating. They did not discuss the stability of a sculpture and build it practically. Lambrecht [5] categorized LEGO sculpture into two types: stud-up and stud-out model, as shown in Figure 2.3. They focused on the stud-out model, whose bricks allowed orthogonal connections. Despite the bricks make the sculptures more realistic, they are not used widely.

Figure 2.3: The illustrations [5] of (a) stud-up sculpture, and (b) stud-out sculpture.

Testuz et al. [12] replaced graphic algorithm with heuristic optimization algorithms.

Using their algorithm, the whole process does not need to consider all heuristics, because most heuristics are related to the connections among bricks. The more connection of a brick has, the more stable the sculpture is. Calculating the connection of a brick and optimizing LEGO structures by graphic algorithm can enhance the efficiency of computing a stable structure layer-by-layer. We propose our improvement to extend to hollowing and center of mass adjusted models.

9

Chapter 3 Algorithm

The goal of this research is to build a LEGO sculpture easier. In this chapter, we describe the process of the assembly instructions generation. By following the instructions of each layer, users can build a stable and low-cost LEGO sculpture. Figure 3.1 explains the flow of our proposed system. The final output present the assembly instructions of each layer. These instructions assist people to build a LEGO sculpture of an input model in any pose. Furthermore, the constructed LEGO sculpture can always stand at the ground plane stably.

The input of our proposed system is a closed polygonal model. Users can rotate or scale the model arbitrary. The first step is voxelization. The input model is voxelized into a volumetric model. Secondly, in order to make the LEGO sculpture stand stably, we need to adjust the center of mass (CoM) by removing proper inner voxels of the LEGO sculpture. Finally, we optimize the trade-off between the connection and brick cost to construct a suitable structure of each layer. The connection influences the stability of a sculpture and the brick cost is related to the usage rate of different bricks.

The rest of this chapter is organized as follows. In section 3.1 we describe how to test the intersection between a voxel and a triangle by Akenine-Möller’ approach [1].

We define “erasable voxel” and “safe region”, and explain the process of adjusting center of mass in section 3.2. And the section 3.3 discuss about the greedy merge algorithm which deals with the trade-off between the connection and each brick cost

10

Figure 3.1: The flow of our proposed system architecture. (a) The input model and its axis-aligned bounding box. (b) The voxelized model. (c) It shows the center of mass

before and after adjusting center of mass. (d) The 2nd and 3rd layers’ assembly instructions of the oblique bunny. (e) The bunny LEGO sculpture.

3.1 Voxelization

The first step of our algorithm is to transform a polygonal model into voxel data.

11

We apply Akenine-Möller’s approach [1] to detect the intersection among voxels and triangles. Based on the separating axis theorem (SAT), if there exists an axis onto which the projections of a voxel V and a triangle T do not overlap, V and T do not overlap.

The axes onto which V and T project are separating axes. If V and T are disjoint, there is a separating plane between them. And the axes is orthogonal to a separating plane.

We test 13 separating axes as shown in Figure 3.2:

1. [3 tests] Let e , 0 e , and 1 e2 are the normals of a voxel. Voxels always align with the axes of 3D coordinates, so we define normals e = (0, 1, 0), 0 e1 = (0, 0, 1), and e = (1, 0, 0). 2

2. [1 tests] Let n be the normal of a triangle.

3. [9 tests] The cross product of an edge from a voxel with an edge from a triangle.

Treat the normals (e ) of a voxel as its edges, and i uj is the edge of a triangle.

Then we can define aij as follows:

aij = ei × uj (𝑖, 𝑗 ∈ {0, 1, 2}) (1)

Figure 3.2: The illustration of the 13 separating axes. e , 0 e , 1 e , and 2 n are the normals of V and T. The other 9 axes are e i × u j (𝑖, 𝑗 ∈ {0, 1, 2}).

12

To simplify the test, we move the triangle first, so that the voxel is centered on the origin. Let a = (𝑎𝑥, 𝑎𝑦, 𝑎𝑧) stands for one of the 13 separating axes. The process of

As illustrated in Figure 3.3, as soon as a separating axis is found that the projections of a triangle T and a voxel V do not overlap, we keep the voxel V and test other voxels and triangles. Otherwise, we continue testing whether the projections of V and T overlap on other separating axes. If V and T overlap on all the 13 separating axes, V intersects with T

Figure 3.3: (a) The projections of V and T onto a do not overlap, so V and T are disjoint. (b) The projections of V and T are overlap on this separating axis. We test

other axes to ensure the intersection status of V and T.

13

3.2 Center of Mass Adjustment

A model can stand stably if the projection of the center of mass is located on the suitable area, which is denoted as the “safe region” of the sculpture. However, for an arbitrary solid model, the center of mass may not lie in the safe region. Thus, we remove voxels to adjust the center of mass. In addition, to avoid destroying the appearance of a model, only the inner voxels can be removed.

3.2.1 Erasable Voxel

To ensure the appearance and the stability of a LEGO sculpture, voxels on the shell cannot be removed. As shown in Figure 3.4, a shell is composed of the outer voxels of a voxelized model. The thickness of a shell is the number of voxels counted from the interior to the exterior of a model. A sculpture is more stable with a thicker shell. In order to strengthen the connections of bricks on a shell, the thickness of a shell should be greater than 2-unit-brick. If voxels are not on the shell, they are denoted as the

“erasable voxel”.

Figure 3.4: (a) The shell in the 8th layer of the voxelized bunny model in (b). The thickness of the shell is 3-unit-birck.

14

The method of determining an erasable voxel is to count the number of its surrounded voxels. If the surrounded voxels of the voxel V is over the shell’s thickness in all the six directions, V is an “erasable voxel”, as displayed in Figure 3.5(a). Figure 3.5(b) illustrates the example of erasable voxels. Voxel A is not an erasable voxel because its number of surrounded voxels in right and behind side is less than the shell’s thickness. In contrast, Voxel B is an erasable voxel.

Figure 3.5: (a) The six direction of a voxel V. (b) The shell’s thickness is 2-unit-birck.

For voxel A, the number of surrounded voxels is 0 in the right side, and it is 1 in the behind side. For voxel B, the number of surrounded voxels is over 2 in all directions.

3.2.2 Safe Region

A safe region means the convex hull of the area where voxels in the lowest layer contacting the ground plane. Based on Prevost’s approach [7], the model can stand stably without any struts when the projection of center of mass onto the ground plane

15

lies in the safe region. We apply Andrew's Monotone Chain convex hull algorithm [2]

to build the convex hull. The pseudo codes are presented in Pseudocode 1 and 2.

In this algorithm, we build a lower hull and an upper hull separately, and concatenate them to form a complete convex hull. Both of the lower hull and upper hull connect to the center of voxels counterclockwise, but a lower hull connects voxels form the leftmost to the rightmost, and the other is reverse, as shown in Figure 3.6.

16

Figure 3.6: The top view of voxels in the bottom layer. The green line is the upper hull and the red line is the lower hull. If it is clockwise from AE to AF , A, E and F

are the vertices of the convex hull.

The processes of building a lower and upper hull are the same. We use a list (L and U, as shown in pseudocode 1) to record the vertices of them. As described at line 7 and

14 in pseudocode 1, the last two vertices in the list and P[i] are used to determine whether the vertices in the list are real vertices or not. For example, as displayed in figure 3.6, voxel A and E are vertices of the lower hull and recorded in list L, and voxel F is the current P[i]. If the cross product of AE and AF is lower than 0, which means they are clockwise, we remove E from L, and then compute the cross product for the current last two vertices and F iteratively. In contrast, F is the new vertex of the convex hull, so we insert B into L. Figure 3.7 displays the safe region built by this algorithm and the center of mass’s projection (𝑐, as shown in Figure 3.7) that is not in the safe region.

17

Figure 3.7: The voxelized bunny model. The blue convex is the safe region of the bunny model. 𝑐 is the projection of center of mass onto the ground plane.

3.2.3 Adjusting Center of Mass

According to Prevost’ approach [7]. If the distance from a voxel to center of mass is greater, removing the voxel can adjust center of mass much closer to the safe region.

Therefore, we sort the voxels in decreasing order by the distance and remove the voxels.

We calculate the distance as follows:

𝑑𝑖 = (𝑐𝑖− 𝑐) ∙ (𝑐 − 𝑐) (4)

, where 𝑐𝑖 is the center of a voxel. 𝑐 is the center of the safe region and its height equals to the center of mass. 𝑐 is also treated as the ideal center of mass. 𝑐 is the center of mass’s position, and we get it by Eg. 5:

𝑐 = 𝑛𝑖=0𝑛𝑐𝑖 (5)

, where 𝑛 is the total number of voxels in a model. As shown in Figure 3.8, a model is separated into two half spaces by a plane which is perpendicular to the ground plane and passes through 𝑐. Removing the voxels located in the half space, which contains

18

the center of mass, can make 𝑐 closer to 𝑐. In contrast, removing the voxels in the other half space makes 𝑐 further away from 𝑐. Consequently, voxels can be removed if they are in the same half space with center of mass. We remove voxels whose distances are greater than 0.

Figure 3.8: We separate the model into two half spaces based on the ideal center of mass (𝑐). When 𝑐 and 𝑐𝑖 are in the same half space, removing 𝑐𝑖 can make 𝑐

closer to 𝑐.

The effect of adjusting center of mass is presented in Figure 3.9. 𝑐 is moved into the safe region after adjusting center of mass, so the model can stand stably after built in reality. Although a model is stable while the center of mass lies in the safe region, we continue removing erasable voxels to decrease the number of voxels as less as

19

possible. At last, we will remove all voxels which are in the same half space with center of mass.

Figure 3.9: The model (a) before and (b) after adjusting center of mass. (c) and (d) Compare the inner structure of the model before and after adjusting center of mass.

3.3 LEGO Brick Merging

To build a stable LEGO sculpture more easily in reality, we need the assembly instructions of each layer. Because the types of LEGO bricks are various, it costs too much time to test all types of bricks and choose the proper one. Therefore, we constrain the usable types, as shown in Figure 3.10, and denote them as “legal brick”.

20

Figure 3.10: The legal bricks [12].

We construct the instructions layer-by-layer by a greedy merge algorithm, which merges voxels into a legal brick with highest value. The process of optimizing an assembly instruction is presented in Pseudocode 3. We describe the details of each step in the following sub-sections:

3.3.1 Voxel Selection

The shell of a LEGO sculpture is often difficult to build because there are too many 1*1 bricks. It causes weak connection of the bricks on the shell, as displayed in Figure 3.11. Thus, we raise the probability of being selected for the voxels which are on a shell in order to merge them into bricks first. The probability is determined by the number of a voxel’s neighbors and computed as Eg. 6,

probability = { 1, 𝑖𝑓 𝑛𝑢𝑚 ≤ 3

1 / exp(𝑛𝑢𝑚) , 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 (6)

, where num is the number of neighbors. We make the voxels with less neighbors are

21

chosen more easily because they are usually on the shell, as shown in Figure 3.12.

Figure 3.11: (a) A shell is composed of 1*1 bricks. It cannot be built in reality because of the weak connection of bricks. (b) Using proper bricks makes the shell

stable and buildable.

Figure 3.12: Ignore the vertical neighbors. Red voxel: the number of neighbors is 2.

Yellow voxels: the number of neighbors is 3. The voxels with few neighbors usually exist on the shell.

22

3.3.2 A Set of Valid Legal Bricks

We combine the chosen voxel and its neighbors to form a legal brick. A brick can be put laterally or longitudinally, which means that a brick is able to involve in the chosen voxel with different positions. For example, there exists 16 different selections for a 2*4 brick as presented in Figure 3.13.

Figure 3.13: The yellow voxel is a chosen voxel. The green brick is a 2*4 brick. (a) Two examples of putting a 2*4 brick on the chosen voxel laterally. (b) Two examples

of putting a 2*4 brick on the chosen voxel longitudinally.

We test all the selections of each legal brick to confirm whether they are valid or not. As illustrated in Figure 3.14, a brick becomes valid if all the voxels in this brick exist; otherwise, the brick is invalid. Therefore, each brick’s type can produce several

“valid legal bricks”. We compute the connections and brick costs of all the valid legal bricks, and merge the chosen voxel and its neighbors to the optimal one.

23

Figure 3.14: The chosen voxel (yellow) and its neighbors is merged into a 2*4 brick (red). We put the brick in different positions. The positions of a brick in (a) and (b) are

valid legal bricks. (c) A 2*4 brick with unsuitable position is invalid because it does not contains 8 voxels

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 connection of a brick means how many bricks it connects with. It influences

相關文件