public CubeOutlineVoxelGridChunkPopulator(int bufferWidth, TerrainVoxel voxel)
        {
            Contracts.Requires.That(bufferWidth >= 0);

            this.bufferWidth = bufferWidth;
            this.voxel       = voxel;
        }
Exemple #2
0
        public ExteriorVoxelGridChunkFactory(
            IRasterChunkConfig <Index3D> config, TerrainVoxel outOfBoundsValue, bool modifyingThrowsException)
        {
            Contracts.Requires.That(config != null);

            this.outOfBoundsChunk = new ConstantArray3D <TerrainVoxel>(
                config.Bounds.Dimensions, outOfBoundsValue, modifyingThrowsException);
        }
Exemple #3
0
        public void SetFiniteBounds(
            IStageBounds stageBounds, TerrainVoxel outOfBoundsValue, bool modifyingThrowsException = true)
        {
            Contracts.Requires.That(stageBounds != null);

            this.stageBounds              = stageBounds;
            this.outOfBoundsValue         = outOfBoundsValue;
            this.modifyingThrowsException = modifyingThrowsException;
        }
Exemple #4
0
        /// <inheritdoc />
        public ContourFacingDirection DetermineContour(TerrainVoxel towardsNegative, TerrainVoxel towardsPositive)
        {
            bool isTowardsNegativeSolid = this.voxelPropertiesTable[towardsNegative.Material].IsSolid;
            bool isTowardsPositiveSolid = this.voxelPropertiesTable[towardsPositive.Material].IsSolid;

            if (isTowardsNegativeSolid == isTowardsPositiveSolid)
            {
                // if both are filled or both are not filled
                return(ContourFacingDirection.None);
            }

            return(isTowardsNegativeSolid ?
                   ContourFacingDirection.TowardsPositive : ContourFacingDirection.TowardsNegative);
        }
        private static Vector3 CalculateVertex(
            TerrainVoxel tlAbove,
            TerrainVoxel tlBelow,
            TerrainVoxel trAbove,
            TerrainVoxel trBelow,
            TerrainVoxel blAbove,
            TerrainVoxel blBelow,
            TerrainVoxel brAbove,
            TerrainVoxel brBelow)
        {
            float x = CalculateAxis(tlAbove, trAbove, tlBelow, trBelow, blAbove, brAbove, blBelow, brBelow);
            float y = CalculateAxis(blAbove, tlAbove, brAbove, trAbove, blBelow, tlBelow, brBelow, trBelow);
            float z = CalculateAxis(tlAbove, tlBelow, trAbove, trBelow, blAbove, blBelow, brAbove, brBelow);

            return(new Vector3(x, y, z));
        }
        private static float CalculateAxis(
            TerrainVoxel negativeEdgeA,
            TerrainVoxel positiveEdgeA,
            TerrainVoxel negativeEdgeB,
            TerrainVoxel positiveEdgeB,
            TerrainVoxel negativeEdgeC,
            TerrainVoxel positiveEdgeC,
            TerrainVoxel negativeEdgeD,
            TerrainVoxel positiveEdgeD)
        {
            float sum =
                CalculateEdge(negativeEdgeA, positiveEdgeA) +
                CalculateEdge(negativeEdgeB, positiveEdgeB) +
                CalculateEdge(negativeEdgeC, positiveEdgeC) +
                CalculateEdge(negativeEdgeD, positiveEdgeD);

            return(sum / 4f);
        }
Exemple #7
0
 public Chunk Activate(Vector3 pos, float size)
 {
     Position = pos;
     Master.SetVector("Position", Position);
     Size = size;
     Master.SetFloat("Size", Size);
     Master.SetBuffer(InitKernel1, "InitKernel1Densities", Densities);
     Master.Dispatch(InitKernel1, 1, 1, 19);
     Master.SetBuffer(InitKernel0, "InitKernel0Voxels", Voxels);
     Master.Dispatch(InitKernel0, 1, 1, 18);
     ChangedFlag = true;
     if (TerrainVoxel.IsNew(Position * Size))
     {
         Master.Dispatch(InitKernel1, 1, 1, 19);
     }
     else
     {
         //ReadFromDisk();
     }
     PreSize       = new Vector3Int(1, 1, 1);
     ClearStartPos = new Vector3(1, 1, 1);
     return(this);
 }
 public ExteriorVoxelGridChunkPopulator(TerrainVoxel outOfBoundsValue)
 {
     this.outOfBoundsValue = outOfBoundsValue;
 }
Exemple #9
0
 public CubeVoxelGridChunkPopulator(TerrainVoxel voxel)
 {
     this.voxel = voxel;
 }
 private static float CalculateEdge(TerrainVoxel negativeEnd, TerrainVoxel positiveEnd)
 {
     return(((float)negativeEnd.Density) / ((float)positiveEnd.Density + negativeEnd.Density));
 }