Figure 3. Adding height distribution The goal is to change the height of the terrain as sand falls. If sand falls at a single point, the goal is to form a round pile with a slope of The pile should be roughly cone θ. shaped. Since our approach is based on a height map, the height of the terrain is represented as if it consisted of the heights of poles at individual grid coordinates, as shown in Figure 3. Imagine Suppose sand with height is added at point in 3D space, which is vertically H0 P0 aligned with coordinates (nx, in the grid space. The variable represents the ny) wx distance from the left boundary of the grid cell to the coordinates (nx, in the ny) x direction of the terrain, and is the distance from the bottom boundary of this grid cell wy to the coordinates (nx, in the direction of the terrain. Since the increased height can ny) y only be applied to the grid coordinates on the height map, we distribute the added height from position to the nearest four grid coordinates, here called and P0 P00, P01, P10, P11. To add the small height from each sand particle to the height map, such that the height b added to each coordinate is related to its distance from the point of impact, we use the formulas below. convert nx from world coordinates to height map coordinate convert ny from world coordinates to height map coordinate wx = nx floor(nx); – wy = ny floor(ny); – // lower-left coordinate P00 = ( floor(nx), floor(ny) ) H00 = b * ( 1 - wx ) * ( 1 - wy );
Figure 3. Adding height distribution The goal is to change the height of the terrain as sand falls. If sand falls at a single point, the goal is to form a round pile with a slope of θ. The pile should be roughly cone shaped. Since our approach is based on a height map, the height of the terrain is represented as if it consisted of the heights of poles at individual grid coordinates, as shown in Figure 3. Imagine Suppose sand with height H0 is added at point P0 in 3D space, which is vertically aligned with coordinates (nx, ny) in the grid space. The variable wx represents the distance from the left boundary of the grid cell to the coordinates (nx, ny) in the x direction of the terrain, and wy is the distance from the bottom boundary of this grid cell to the coordinates (nx, ny) in the y direction of the terrain. Since the increased height can only be applied to the grid coordinates on the height map, we distribute the added height from position P0 to the nearest four grid coordinates, here called P00, P01, P10, and P11. To add the small height b from each sand particle to the height map, such that the height added to each coordinate is related to its distance from the point of impact, we use the formulas below. convert nx from world coordinates to height map coordinate convert ny from world coordinates to height map coordinate wx = nx – floor(nx); wy = ny – floor(ny); // lower-left coordinate P00 = ( floor(nx), floor(ny) ) H00 = b * ( 1 - wx ) * ( 1 - wy );
Sand.docx