示例#1
0
        void Initialize()
        {
            LayerRetainsBacking = true;
            LayerColorFormat    = EAGLColorFormat.RGBA8;
            ContextRenderingApi = EAGLRenderingAPI.OpenGLES1;

            MultipleTouchEnabled = true;

            var now = DateTime.UtcNow;
            _sunLoc = Location.SunLocation(now);
            Camera = new Camera();
            CameraMan = new BlimpCameraMan(
                new Location(-122.3352, 47.645),
                new Location(-122.3352, 47.6453));
            Unload += HandleUnload;
        }
示例#2
0
        void DrawTiles(Camera cam, TileName centerTile, float alpha)
        {
            //
            // Determine the number of tiles to show
            //
            int minX=99999999, minY=99999999, maxX=0, maxY=0;
            for (var i = 0; i < cam.ScreenLocations.Length; i++) {
                var loc = cam.ScreenLocations[i];
                if (loc != null) {
                    var c = TileName.FromLocation(loc, centerTile.Zoom);
                    minX = Math.Min(c.X, minX);
                    minY = Math.Min(c.Y, minY);
                    maxX = Math.Max(c.X, maxX);
                    maxY = Math.Max(c.Y, maxY);
                }
            }
            minX = Math.Min(centerTile.X, minX);
            minY = Math.Min(centerTile.Y, minY);
                    maxX = Math.Max(centerTile.X, maxX);
                    maxY = Math.Max(centerTile.Y, maxY);
            minX-=1;
            minY-=1;
            maxX+=1;
            maxY+=1;

            //
            // Draw them
            //
            var nd = 0;
            var tile = new TileName() { Zoom = centerTile.Zoom };

            var n = (int)Math.Pow(2, tile.Zoom);

            foreach (var p in RenderOrder) {
                tile.X = centerTile.X + p.X;
                tile.Y = centerTile.Y + p.Y;

                while (tile.X < 0) tile.X += n;
                while (tile.Y < 0) tile.Y += n;
                while (tile.X >= n) tile.X -= n;
                while (tile.Y >= n) tile.Y -= n;

                if (tile.X < minX || tile.Y < minY) continue;
                if (tile.X > maxX || tile.Y > maxY) continue;

                DrawTile(tile, alpha);
                nd ++;
            }
        }
示例#3
0
 void Initialize()
 {
     var now = DateTime.Now;
     _sunLoc = Caulker.Location.SunLocation(now);
     Camera = new Camera();
     CameraMan = new BlimpCameraMan(
         new Location(153.0306, -27.4778),         // Greetings from Brisbane :)
         new Location(153.0306, -27.4878));
     Unload += HandleUnload;
 }
示例#4
0
        public void Draw(Camera cam, SimTime t)
        {
            GL.Disable(All.DepthTest);
            GL.Enable(All.Texture2D);

            _textures.BeginFrame();
            _geometries.BeginFrame();

            GL.EnableClientState(All.TextureCoordArray);
            GL.EnableClientState(All.NormalArray);

            var zoom = cam.Zoom;

            if (_lastZoom < 0) _lastZoom = zoom;
            if (zoom != _lastZoom) {
                _prevZoom = _lastZoom;
                _lastZoomFadeTime = t.WallTime;
            }
            var fadeTime = t.WallTime - _lastZoomFadeTime;
            var shouldFade = fadeTime.TotalSeconds < FadeSecs;
            var fade = shouldFade ? (float)(fadeTime.TotalSeconds/FadeSecs) : 1.0f;
            _lastZoom = zoom;

            var centerTile1 = TileName.FromLocation(cam.LookAt, _prevZoom);
            var centerTile = TileName.FromLocation(cam.LookAt, zoom);

            //
            // Draw the tiles
            //
            if (shouldFade) {
                DrawTiles(cam, centerTile1, 1.0f);
            }
            DrawTiles(cam, centerTile, fade);

            GL.DisableClientState(All.TextureCoordArray);
            GL.DisableClientState(All.NormalArray);
            GL.Disable(All.Texture2D);
            GL.Enable(All.DepthTest);
        }