ChunktoRegionRelative() public method

public ChunktoRegionRelative ( ) : void
return void
コード例 #1
0
ファイル: Renderer.cs プロジェクト: Banane9/Topographer
        private Bitmap RenderRegionBiomes(RegionFile region, Bitmap b, int offsetX, int offsetY)
        {
            foreach (Chunk c in region.Chunks)
            {
                if (c == null || c.Root == null)
                    continue;
                Coord chunkOffset = new Coord(c.Coords);
                chunkOffset.ChunktoRegionRelative();
                chunkOffset.ChunktoAbsolute();
                RenderChunkBiomes(c, b, offsetX + chunkOffset.X, offsetY + chunkOffset.Z);
            }

            return b;
        }
コード例 #2
0
ファイル: RegionUtil.cs プロジェクト: mblaine/BiomePainter
        private static void RenderRegionChunkstobePopulated(RegionFile region, int chunkStartX, int chunkEndX, int chunkStartZ, int chunkEndZ, int offsetX, int offsetY, Bitmap populate)
        {
            using (Graphics g = Graphics.FromImage(populate))
            {
                Brush brush = new SolidBrush(Color.Yellow);
                for (int x = chunkStartX; x <= chunkEndX; x++)
                {
                    for (int z = chunkStartZ; z <= chunkEndZ; z++)
                    {
                        Chunk c = region.Chunks[x, z];
                        if (c == null || c.Root == null)
                            continue;
                        Coord chunkOffset = new Coord(c.Coords);
                        chunkOffset.ChunktoRegionRelative();
                        chunkOffset = new Coord(chunkOffset.X - chunkStartX, chunkOffset.Z - chunkStartZ);
                        chunkOffset.ChunktoAbsolute();
                        chunkOffset.Add(offsetX, offsetY);

                        RenderChunktobePopulated(c, g, brush, chunkOffset.X, chunkOffset.Z);
                    }
                }
                brush.Dispose();
            }
        }
コード例 #3
0
ファイル: RegionUtil.cs プロジェクト: mblaine/BiomePainter
        private static void RenderRegionTerrain(RegionFile region, int chunkStartX, int chunkEndX, int chunkStartZ, int chunkEndZ, int offsetX, int offsetY, Bitmap map)
        {
            if (signal != null || mutex != null || taskCount > 0)
                throw new Exception("RenderRegionTerrain re-entered, shouldn't be possible.");

            signal = new ManualResetEvent(false);
            taskCount = (chunkEndX - chunkStartX + 1) * (chunkEndZ - chunkStartZ + 1);
            mutex = new Mutex();

            for (int x = chunkStartX; x <= chunkEndX; x++)
            {
                for (int z = chunkStartZ; z <= chunkEndZ; z++)
                {
                    Chunk c = region.Chunks[x, z];
                    if (c == null || c.Root == null)
                    {
                        if (Interlocked.Decrement(ref taskCount) == 0)
                            signal.Set();
                        continue;
                    }
                    Coord chunkOffset = new Coord(c.Coords);
                    chunkOffset.ChunktoRegionRelative();
                    chunkOffset = new Coord(chunkOffset.X - chunkStartX, chunkOffset.Z - chunkStartZ);
                    chunkOffset.ChunktoAbsolute();
                    chunkOffset.Add(offsetX, offsetY);

                    ThreadPool.QueueUserWorkItem(RenderChunkTerrain, new Object[]{c, map, chunkOffset.X, chunkOffset.Z});
                }
            }

            signal.WaitOne();
            signal.Dispose();
            signal = null;
            mutex.WaitOne();
            mutex.ReleaseMutex();
            mutex.Dispose();
            mutex = null;
        }
コード例 #4
0
ファイル: RegionUtil.cs プロジェクト: mblaine/BiomePainter
        private static void RenderRegionBiomes(RegionFile region, int chunkStartX, int chunkEndX, int chunkStartZ, int chunkEndZ, int offsetX, int offsetY, Bitmap biomes, String[,] toolTips)
        {
            for (int x = chunkStartX; x <= chunkEndX; x++)
            {
                for (int z = chunkStartZ; z <= chunkEndZ; z++)
                {
                    Chunk c = region.Chunks[x, z];
                    if (c == null || c.Root == null)
                        continue;
                    Coord chunkOffset = new Coord(c.Coords);
                    chunkOffset.ChunktoRegionRelative();
                    chunkOffset = new Coord(chunkOffset.X - chunkStartX, chunkOffset.Z - chunkStartZ);
                    chunkOffset.ChunktoAbsolute();
                    chunkOffset.Add(offsetX, offsetY);

                    RenderChunkBiomes(c, biomes, toolTips, chunkOffset.X, chunkOffset.Z);
                }
            }
        }