Beispiel #1
0
        public YndJunctionHeightmap(byte[] data, YndJunction junc)
        {
            if (data == null)
            {
                return;
            }

            var d = junc.RawData;
            int s = d.HeightmapPtr;

            CountX = d.HeightmapDimX;
            CountY = d.HeightmapDimY;

            if ((s + CountX * CountY) > data.Length)
            {
                return;
            }

            Rows = new YndJunctionHeightmapRow[CountY];


            for (int y = 0; y < CountY; y++)
            {
                int    o    = s + y * CountX;
                byte[] vals = new byte[CountX];
                Buffer.BlockCopy(data, o, vals, 0, CountX);
                Rows[y] = new YndJunctionHeightmapRow(vals);
            }
        }
Beispiel #2
0
        public void Resize(int cx, int cy)
        {
            var nrows = new YndJunctionHeightmapRow[cy];

            for (int y = 0; y < cy; y++)
            {
                byte[] nvals = new byte[cx];
                int    minx  = Math.Min(cx, CountX);
                if ((Rows != null) && (y < Rows.Length))
                {
                    Buffer.BlockCopy(Rows[y].Values, 0, nvals, 0, minx);
                }
                nrows[y] = new YndJunctionHeightmapRow(nvals);
            }
            Rows = nrows;

            CountX = cx;
            CountY = cy;
        }