コード例 #1
0
        public hVoxelChunk(Accelerator device, Vec3 position, int width, int height, int depth, int maxViewDist, int[] materialIDs)
        {
            this.device      = device;
            this.position    = position - new Vec3(width / 2f, 0, depth / 2f);
            this.width       = width;
            this.depth       = depth;
            this.height      = height;
            this.maxViewDist = maxViewDist;
            this.materialIDs = materialIDs;

            tiles = new int[width, height, depth];

            Random rng = new Random(5);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int z = 0; z < depth; z++)
                    {
                        tiles[x, y, z] = rng.NextDouble() < 0.25 ? rng.Next(1, materialIDs.Length) : 0;
                    }
                }
            }

            d_tiles = device.Allocate <int>(new Index3(width, height, depth));
            d_tiles.CopyFrom(tiles, new Index3(), new Index3(), d_tiles.Extent);

            d_materialIDs = device.Allocate <int>(materialIDs.Length);
            d_materialIDs.CopyFrom(materialIDs, 0, 0, materialIDs.Length);
        }
コード例 #2
0
        public void LoadDatasetInVideoMemory()
        {
            int w = width,
                h = height,
                d = depth;

            short[] buffer = new short[w * h * d];
            var     bands  = Enumerable.Range(1, d).ToArray();

            _dataset.ReadRaster(0, 0, w, h, buffer, w, h, d, bands, 0, 0, 0);
            _datasetV = GpuContext.Instance.Accelerator.Allocate <short>(w, h, d);
            _datasetV.CopyFrom(buffer, 0, Index3.Zero, buffer.Length);
        }
コード例 #3
0
        public hVoxelChunk(Accelerator device, Vec3 position, int width, int depth, int height, int maxViewDist, int[] materialIDs, int[,,] tiles)
        {
            this.device      = device;
            this.position    = position;
            this.width       = width;
            this.depth       = depth;
            this.height      = height;
            this.tiles       = tiles;
            this.maxViewDist = maxViewDist;
            this.materialIDs = materialIDs;

            d_tiles = device.Allocate <int>(new Index3(width, height, depth));
            d_tiles.CopyFrom(tiles, new Index3(), new Index3(), d_tiles.Extent);
        }