Ejemplo n.º 1
0
        private void LoadProc()
        {
            while (mIsRunning)
            {
                MapAreaLowRender item = null;
                lock (mDataToLoad)
                {
                    if (mDataToLoad.Count > 0)
                    {
                        item = mDataToLoad[0];
                        mDataToLoad.RemoveAt(0);
                    }
                }

                if (item == null)
                {
                    Thread.Sleep(30);
                    continue;
                }

                item.InitFromHeightData(mWdlFile.GetEntry(item.IndexX, item.IndexY));
                lock (mLoadedData)
                    mLoadedData.Add(item);
            }
        }
Ejemplo n.º 2
0
        public void UpdateMap(string mapName)
        {
            mWdlFile = new IO.Files.Terrain.WdlFile();
            try
            {
                mWdlFile.Load(mapName);
                if (mWdlFile.HasEntries == false)
                {
                    UpdateMapNoWdl(mapName);
                    return;
                }
            }
            catch (Exception)
            {
                UpdateMapNoWdl(mapName);
                return;
            }

            if (mImage != null)
            {
                mImage.Dispose();
            }

            var textureData = new uint[Width * Height];

            for (var i = 0; i < 64; ++i)
            {
                for (var j = 0; j < 64; ++j)
                {
                    if (mWdlFile.HasEntry(j, i) == false)
                    {
                        continue;
                    }

                    var entry = mWdlFile.GetEntry(j, i);
                    LoadEntry(entry, textureData, ref i, ref j);
                }
            }

            var bmpProps =
                new BitmapProperties(new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore));

            using (var dataStream = new DataStream(Width * Height * 4, true, true))
            {
                dataStream.WriteRange(textureData);
                dataStream.Position = 0;

                mImage = new Bitmap(InterfaceManager.Instance.Surface.RenderTarget, new Size2(Width, Height),
                                    new DataPointer(dataStream.DataPointer, Width * Height * 4), Width * 4, bmpProps);
            }
        }
Ejemplo n.º 3
0
        public void UpdateMap(string mapName)
        {
            mWdlFile = new IO.Files.Terrain.WdlFile();
            try
            {
                mWdlFile.Load(mapName);
                if(mWdlFile.HasEntries == false)
                {
                    UpdateMapNoWdl(mapName);
                    return;
                }
            }
            catch(Exception)
            {
                UpdateMapNoWdl(mapName);
                return;
            }

            if (mImage != null)
                mImage.Dispose();

            var textureData = new uint[Width * Height];
            for(var i = 0; i < 64; ++i)
            {
                for(var j = 0; j < 64; ++j)
                {
                    if (mWdlFile.HasEntry(j, i) == false)
                        continue;

                    var entry = mWdlFile.GetEntry(j, i);
                    LoadEntry(entry, textureData, ref i, ref j);
                }
            }

            var bmpProps =
                new BitmapProperties(new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore));

            using (var dataStream = new DataStream(Width * Height * 4, true, true))
            {
                dataStream.WriteRange(textureData);
                dataStream.Position = 0;

                mImage = new Bitmap(InterfaceManager.Instance.Surface.RenderTarget, new Size2(Width, Height),
                    new DataPointer(dataStream.DataPointer, Width * Height * 4), Width * 4, bmpProps);
            }
        }