コード例 #1
0
ファイル: VTTileCache.cs プロジェクト: ttou73/IronStar
        /// <summary>
        /// Translates virtual texture address to physical rectangle in physical texture.
        /// </summary>
        /// <param name="address"></param>
        /// <param name="rectangle"></param>
        /// <returns>False if address is not presented in cache</returns>
        public bool TranslateAddress(VTAddress address, VTTile tile, out Rectangle rectangle)
        {
            Page page;

            if (cache.TryGetValue(address, out page))
            {
                var pa   = page.Address;
                var ppc  = pageCount;
                var size = VTConfig.PageSizeBordered;
                int x    = (pa % ppc) * size;
                int y    = (pa / ppc) * size;
                int w    = size;
                int h    = size;
                rectangle = new Rectangle(x, y, w, h);

                page.Tile = tile;

                return(true);
            }
            else
            {
                rectangle = new Rectangle();
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Functionas running in separate thread
        /// </summary>
        void LoaderTask()
        {
            while (!stopLoader)
            {
                VTAddress address;

                        #if USE_PRIORITY_QUEUE
                address = default(VTAddress);
                KeyValuePair <int, VTAddress> result;
                if (!requestQueue.TryDequeue(out result))
                {
                    //Thread.Sleep(1);
                    continue;
                }
                else
                {
                    address = result.Value;
                }
                        #else
                if (!requestQueue.TryDequeue(out address))
                {
                    //Thread.Sleep(1);
                    continue;
                }
                        #endif


                var fileName = address.GetFileNameWithoutExtension(".tile");

                //Log.Message("...vt tile load : {0}", fileName );

                try {
                    var tile = new VTTile(address);
                    tile.Read(storage.OpenFile(fileName, FileMode.Open, FileAccess.Read));

                    loadedTiles.Enqueue(tile);
                } catch (IOException ioex) {
                    var tile = new VTTile(address);
                    tile.Clear(Color.Magenta);

                    loadedTiles.Enqueue(tile);

                    Log.Warning("{0}", ioex);
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Gets loaded tile or zero
 /// </summary>
 /// <returns></returns>
 public bool TryGetTile(out VTTile image)
 {
     return(loadedTiles.TryDequeue(out image));
 }
コード例 #4
0
 /// <summary>
 /// Add tile to stamp queue
 /// </summary>
 /// <param name="tile"></param>
 /// <param name="rect"></param>
 public void Add(VTTile tile, Rectangle rect)
 {
     stamps[rect] = new Stamp(tile, rect);
 }
コード例 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="tile"></param>
 /// <param name="rect"></param>
 public Stamp(VTTile tile, Rectangle rect)
 {
     this.Tile      = tile;
     this.Rectangle = rect;
 }