Week 35&36 ( Aug. 24 - Sep. 6) Coding Stage 3
- groupyyzdh2323
- Sep 6, 2020
- 2 min read
Generation of attraction points
To let users have more freedom, we add cube volume to the attraction points generation system.
To uniformly generate points in cubes, we need a different algorithm from the sphere:

which is much more intuitive than the generation inside spheres.
The problem now falls in how to define the structure of the Volume class. We decided to add parameter int shape and Vector3 cubeSize into the class, and use the volume parameters accordingly.

Now to deal with the intersection between volumes, we keep a list of added volumes. And for cubes, we require a different algorithm to judge whether a newly-generated point is inside, which is simply to check whether the x, y and z coordinates of the point are inside the range of cubes' minimum and maximum coordinates.
The UI interface is adjusted to include the new type of volume.

Adding attraction points on volume surfaces is enabled. Which is done by fixing the r coordinate when generating on spheres, and separately generating on the six faces for cubes.

Space colonization algorithm
Knowing the growth direction of the branch is influenced by the attraction points’ positions, we have to define a concrete rule or model to guide the growth through script. the sum of the direction vector is normalized to compute the direction and position of the next branch segment.

One notice during experimenting the branch growth is that there will be a very small chance that the branch segment is stuck exactly between two attraction points within influence range. As the previously defined rule, it will continue growing in the current direction without passing any of these two points. To avoid this situation, a function RandomGrowthVector()is implemented. The function returns a three-dimensional random vector. By adding this randomness to the formula, the issue is solved.

Reference:
[1]. Baptiste Crespy. 2019. Generating a 3D growing tree using a space colonization algorithm. (2019).https://ciphered.xyz/2019/09/11/generating-a-3d-growing-tree-using-a-space-colonization-algorithm/.
Comments