Exemplo n.º 1
0
        public override TilePyramid VisibleTiles(GridRectangle VisibleBounds, double DownSample)
        {
            int roundedDownsample = NearestAvailableLevel(DownSample);

            GridQuad VisibleQuad = null;

            //Add any corners of the VisibleBounds that we can transform to the list of points
            List<MappingGridVector2> VisiblePoints = VisibleBoundsCorners(VolumeTransform, VisibleBounds);
            if (VisiblePoints.Count != 4)
            {
                //If we can't map all four corners then add all the points from the transform falling inside the visible rectangle or
                //connected to those points by an edge
                List<MappingGridVector2> listTransformPoints = this.VolumeTransform.IntersectingControlRectangle(VisibleBounds, true);
                VisiblePoints.AddRange(listTransformPoints);
            }
            else
            {
                VisiblePoints.Sort(new MappingGridVector2SortByMapPoints());
                VisibleQuad = new GridQuad(VisiblePoints[0].MappedPoint,
                                           VisiblePoints[1].MappedPoint,
                                           VisiblePoints[2].MappedPoint,
                                           VisiblePoints[3].MappedPoint);
            }

            //OK, transform all points falling inside the section border
            //Starting with low-res tiles, add tiles to the list until we reach desired resolution
            //List<Tile> TilesToDraw = new List<Tile>();
            TilePyramid TilesToDraw = new TilePyramid(VisibleBounds);

            if (VisiblePoints.Count < 3)
                return TilesToDraw;

            GridRectangle SectionBorder = MappingGridVector2.CalculateMappedBounds(VisiblePoints.ToArray());

            int iLevel = AvailableLevels.Length - 1;
            int level = AvailableLevels[iLevel];
            do
            {
                List<Tile> newTiles = RecursiveVisibleTiles(VisibleBounds,
                                                            SectionBorder,
                                                            VisibleQuad,
                                                            level
                                                            //PORT: AsynchTextureLoad
                                                            );

                //Insert at the beginning so we overwrite earlier tiles with poorer resolution
                TilesToDraw.AddTiles(level, newTiles.ToArray());

                iLevel--;
                if (iLevel >= 0)
                    level = AvailableLevels[iLevel];
            }
            while (level >= roundedDownsample && iLevel >= 0);

            //  Trace.WriteLine("Drawing " + TilesToDraw.Count.ToString() + " Tiles", "VolumeModel");

            return TilesToDraw;
        }
Exemplo n.º 2
0
        public override TilePyramid VisibleTiles(GridRectangle VisibleBounds, double DownSample)
        {
            TilePyramid VisibleTiles = new TilePyramid(VisibleBounds);
            int roundedDownsample = NearestAvailableLevel(DownSample);

            //Starting with low-res tiles, add tiles to the list until we reach desired resolution
            //            List<Tile> TilesToDraw = new List<Tile>();

            //Find the starting level of our rendering
            int iLevel = AvailableLevels.Length - 1;
            int level = AvailableLevels[iLevel];

            do
            {
                List<Tile> newTiles = RecursiveVisibleTiles(
                    VisibleBounds,
                    level
                    //PORT: AsynchTextureLoad
                    );

                //Insert at the beginning so we overwrite earlier tiles with poorer resolution
                VisibleTiles.AddTiles(level, newTiles);
                //TilesToDraw.AddRange(newTiles);

                iLevel--;
                if(iLevel >= 0)
                    level = AvailableLevels[iLevel];
            }
            while (level >= roundedDownsample && iLevel >= 0);

            //Trace.WriteLine("Drawing " + TilesToDraw.Count.ToString() + " Tiles", "VolumeModel");

            return VisibleTiles;
        }