/// <summary>
        /// Constructor
        /// </summary>
        public PageManager(SceneNode rootNode)
        {
            if (instance != null)

            {

                throw new ApplicationException("PageManager.Constructor() called twice!");

            }

            instance = this;

            sceneRoot = rootNode;

            currentCameraPageX = 0;
            currentCameraPageZ = 0;
            currentCameraTileX = 0;
            currentCameraTileZ = 0;

            lastCameraPageState = CameraPageState.Change;

            lastCameraPos = new Vector3(-999999,9999999,-999999);

            pause = 99;

            width = Options.Instance.World_Width;
            heigth = Options.Instance.World_Height;

            pageLoadQueue = new PageQueue();
            pageUnloadQueue = new PageQueue();
            pagePreloadQueue = new PageQueue();
            pagePostunloadQueue = new PageQueue();
            //setup the page array.
            //    mPages.reserve (mWidth);
            //    mPages.resize (mWidth);
            pages = new Pages( width );
            for (long  i = 0; i < width; i++ )
            {
                PageRow pr = new PageRow( heigth );

                //        mPages[ i ].reserve (mHeigth);
                //        mPages[ i ].resize (mHeigth);
                for (long  j = 0; j < heigth; j++ )
                {
                    pr.Add( new Page( i, j ) );
                }

                pages.Add( pr );
            }

            for (long  j = 0; j < heigth; j++ )
            {
                for (long  i = 0; i < width; i++ )
                {
                    if ( j != heigth - 1)
                    {
                        pages[ i ][ j     ].SetNeighbor( Neighbor.South, pages[ i ][ j + 1 ] );
                        pages[ i ][ j + 1 ].SetNeighbor( Neighbor.North, pages[ i ][ j     ] );
                    }

                    if ( i != width - 1)
                    {
                        pages[ i     ][ j ].SetNeighbor( Neighbor.East, pages[ i + 1 ][ j ] );
                        pages[ i + 1 ][ j ].SetNeighbor( Neighbor.West, pages[ i     ][ j ] );
                    }
                }
            }
        }
        /// <summary>

        /// Constructor

        /// </summary>

        public PageManager(SceneNode rootNode)

        {
            if (instance != null)

            {
                throw new ApplicationException("PageManager.Constructor() called twice!");
            }

            instance = this;



            sceneRoot = rootNode;

            currentCameraPageX = 0;
            currentCameraPageZ = 0;
            currentCameraTileX = 0;
            currentCameraTileZ = 0;

            lastCameraPageState = CameraPageState.Change;

            lastCameraPos = new Vector3(-999999, 9999999, -999999);

            pause = 99;

            width  = Options.Instance.World_Width;
            heigth = Options.Instance.World_Height;

            pageLoadQueue       = new PageQueue();
            pageUnloadQueue     = new PageQueue();
            pagePreloadQueue    = new PageQueue();
            pagePostunloadQueue = new PageQueue();
            //setup the page array.
            //    mPages.reserve (mWidth);
            //    mPages.resize (mWidth);
            pages = new Pages(width);
            for (long i = 0; i < width; i++)
            {
                PageRow pr = new PageRow(heigth);

                //        mPages[ i ].reserve (mHeigth);
                //        mPages[ i ].resize (mHeigth);
                for (long j = 0; j < heigth; j++)
                {
                    pr.Add(new Page(i, j));
                }

                pages.Add(pr);
            }

            for (long j = 0; j < heigth; j++)
            {
                for (long i = 0; i < width; i++)
                {
                    if (j != heigth - 1)
                    {
                        pages[i][j].SetNeighbor(Neighbor.South, pages[i][j + 1]);
                        pages[i][j + 1].SetNeighbor(Neighbor.North, pages[i][j]);
                    }

                    if (i != width - 1)
                    {
                        pages[i][j].SetNeighbor(Neighbor.East, pages[i + 1][j]);
                        pages[i + 1][j].SetNeighbor(Neighbor.West, pages[i][j]);
                    }
                }
            }
        }