Ejemplo n.º 1
0
 /// <summary>
 /// Sets the density value at a given point, if it is inside the chunk.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 /// <param name="value"></param>
 public void SetValueAtPoint(int x, int y, int z, float value)
 {
     if (0 <= x && x < VoxelUtilities.pointsPerAxis && 0 <= y && y < VoxelUtilities.pointsPerAxis && 0 <= z && z < VoxelUtilities.pointsPerAxis)
     {
         points[VoxelUtilities.GetIndex(x, y, z)] = Mathf.Clamp01(value);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds to the density value at a given point, if it is inside the chunk.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 /// <param name="amount"></param>
 public void AddValueAtPoint(int x, int y, int z, float amount)
 {
     if (0 <= x && x < VoxelUtilities.pointsPerAxis && 0 <= y && y < VoxelUtilities.pointsPerAxis && 0 <= z && z < VoxelUtilities.pointsPerAxis)
     {
         points[VoxelUtilities.GetIndex(x, y, z)] += amount;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns the density value at a given point. If the point is outside the chunk,
 /// then we return 1 (i.e solid). TODO: Allow Chunks to retrieve values from neigh-
 /// bouring chunks.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 /// <returns>Density value at the specified point.</returns>
 public float GetValueAtPoint(int x, int y, int z)
 {
     if (0 <= x && x < VoxelUtilities.pointsPerAxis && 0 <= y && y < VoxelUtilities.pointsPerAxis && 0 <= z && z < VoxelUtilities.pointsPerAxis)
     {
         return(points[VoxelUtilities.GetIndex(x, y, z)]);
     }
     else
     {
         return(1f);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Generates the initial density values representing the terrain.
 /// </summary>
 void GetPoints()
 {
     points = new float[VoxelUtilities.pointsPerAxis * VoxelUtilities.pointsPerAxis * VoxelUtilities.pointsPerAxis];
     //for (int z = 6; z < pointsPerAxis - 6; z++)
     //{
     //    for (int y = 14; y < pointsPerAxis -1; y++)
     //    {
     //        for (int x = 6; x < pointsPerAxis - 6; x++)
     //        {
     //            points[z * pointsPerAxisSqr + y * pointsPerAxis + x] = y < pointsPerAxis - 3 ? 0 : 1f;
     //        }
     //    }
     //}
     points[VoxelUtilities.GetIndex(8, 14, 8)] = 1f;
 }