Пример #1
0
        private QuadTreeNode(TileRegion region)
        {
            this.region = region;

            TileCoord center = region.Center;
            TileCoord start = region.Start;
            TileCoord end = region.End;

            this.box = new ABox();
            this.box.Add(new OpenTK.Vector3(start.Col, start.Row, start.Alt));
            this.box.Add(new OpenTK.Vector3(end.Col, end.Row, end.Alt));

            if (region.TileCount > 16)
            {
                leaf = false;
                children[0] = new QuadTreeNode(new TileRegion(
                    start,
                    center));
                children[1] = new QuadTreeNode(new TileRegion(
                    new TileCoord(center.Row, start.Col, 0),
                    new TileCoord(end.Row, center.Col, 0)));
                children[2] = new QuadTreeNode(new TileRegion(
                    center,
                    end));
                children[3] = new QuadTreeNode(new TileRegion(
                    new TileCoord(start.Row, center.Col, 0),
                    new TileCoord(center.Row, end.Col, 0)));
            }
            else
            {
                leaf = true;
            }
        }
Пример #2
0
        public TileRegion Add(TileRegion otherRG)
        {
            int[] ns = { start[0], start[1], start[2] };
            int[] ne = { end[0], end[1], end[2] };

            Add(otherRG.Start, ns, ne);
            Add(otherRG.End, ns, ne);

            return new TileRegion(new TileCoord(ns), new TileCoord(ne));
        }