Beispiel #1
0
        public static VoxelizedSolid CreateFullBlock(double voxelSideLength, IReadOnlyList <double[]> bounds)
        {
            var fullBlock = new VoxelizedSolid();

            fullBlock.Bounds          = new double[2][];
            fullBlock.Bounds[0]       = (double[])bounds[0].Clone();
            fullBlock.Bounds[1]       = (double[])bounds[1].Clone();
            fullBlock.Dimensions      = fullBlock.Bounds[1].subtract(fullBlock.Bounds[0]);
            fullBlock.SolidColor      = new Color(Constants.DefaultColor);
            fullBlock.VoxelSideLength = voxelSideLength;
            var voxelsPerSide = fullBlock.Dimensions.Select(d => (int)Math.Ceiling(d / fullBlock.VoxelSideLength)).ToArray();

            fullBlock.numVoxelsX = voxelsPerSide[0];
            fullBlock.numVoxelsY = voxelsPerSide[1];
            fullBlock.numVoxelsZ = voxelsPerSide[2];
            fullBlock.voxels     = new IVoxelRow[fullBlock.numVoxelsY * fullBlock.numVoxelsZ];
            for (int i = 0; i < fullBlock.numVoxelsY * fullBlock.numVoxelsZ; i++)
            {
                var fullRow = new VoxelRowSparse(fullBlock.numVoxelsX);
                fullRow.indices.Add(0);
                fullRow.indices.Add((ushort)fullBlock.numVoxelsX);
                fullBlock.voxels[i] = fullRow;
            }
            fullBlock.UpdateProperties();
            return(fullBlock);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the full block given the dimensions and the size.
        /// </summary>
        /// <param name="voxelSideLength">Length of the voxel side.</param>
        /// <param name="bounds">The bounds.</param>
        /// <returns>VoxelizedSolid.</returns>
        public static VoxelizedSolid CreateFullBlock(double voxelSideLength, IReadOnlyList <Vector3> bounds)
        {
            var fullBlock = new VoxelizedSolid();

            fullBlock.Bounds          = new[] { bounds[0], bounds[1] };
            fullBlock.Dimensions      = fullBlock.Bounds[1].Subtract(fullBlock.Bounds[0]);
            fullBlock.SolidColor      = new Color(Constants.DefaultColor);
            fullBlock.VoxelSideLength = voxelSideLength;
            fullBlock.numVoxelsX      = (int)Math.Ceiling(fullBlock.Dimensions.X / fullBlock.VoxelSideLength);
            fullBlock.numVoxelsY      = (int)Math.Ceiling(fullBlock.Dimensions.Y / fullBlock.VoxelSideLength);
            fullBlock.numVoxelsZ      = (int)Math.Ceiling(fullBlock.Dimensions.Z / fullBlock.VoxelSideLength);
            fullBlock.voxels          = new IVoxelRow[fullBlock.numVoxelsY * fullBlock.numVoxelsZ];
            for (int i = 0; i < fullBlock.numVoxelsY * fullBlock.numVoxelsZ; i++)
            {
                var fullRow = new VoxelRowSparse(fullBlock.numVoxelsX);
                fullRow.indices.Add(0);
                fullRow.indices.Add((ushort)fullBlock.numVoxelsX);
                fullBlock.voxels[i] = fullRow;
            }
            fullBlock.UpdateProperties();
            return(fullBlock);
        }