Exemplo n.º 1
0
        public void Process(object sender, MessageQueueEventArgs e)
        {
#if !SINGLE_THREADED
            _context.MakeCurrent();
#endif

            ShapefileRequest request = (ShapefileRequest)e.Message;
            ShapefileRenderer shapefile = new ShapefileRenderer(
                request.Filename, _context, _globeShape, request.Appearance);

#if !SINGLE_THREADED
            Fence fence = Device.CreateFence();
            while (fence.ClientWait(0) == ClientWaitResult.TimeoutExpired)
            {
                Thread.Sleep(10);   // Other work, etc.
            }
#endif

            _doneQueue.Post(shapefile);
        }
Exemplo n.º 2
0
        public VectorData()
        {
            Ellipsoid globeShape = Ellipsoid.ScaledWgs84;

            _window = Device.CreateWindow(800, 600, "Chapter 7:  Vector Data");
            _window.Resize += OnResize;
            _window.RenderFrame += OnRenderFrame;
            _window.Keyboard.KeyDown += OnKeyDown;
            _window.Keyboard.KeyUp += OnKeyUp; 
            _sceneState = new SceneState();
            _camera = new CameraLookAtPoint(_sceneState.Camera, _window, globeShape);

            Context context = _window.Context;

            _framebuffer = context.CreateFramebuffer();

            _clearBlack = new ClearState();
            _clearBlack.Color = Color.Black;

            _clearWhite = new ClearState();
            _clearWhite.Color = Color.White;

            _quad = new DayNightViewportQuad(context);

            _globe = new DayNightGlobe(context);
            _globe.Shape = globeShape;
            _globe.UseAverageDepth = true;
            _globe.DayTexture = Device.CreateTexture2D(new Bitmap("NE2_50M_SR_W_4096.jpg"), TextureFormat.RedGreenBlue8, false);
            _globe.NightTexture = Device.CreateTexture2D(new Bitmap("land_ocean_ice_lights_2048.jpg"), TextureFormat.RedGreenBlue8, false);

            _countries = new ShapefileRenderer("110m_admin_0_countries.shp", context, globeShape,
                new ShapefileAppearance()
                {
                    PolylineWidth = 1.0,
                    PolylineOutlineWidth = 1.0
                });
            _states = new ShapefileRenderer("110m_admin_1_states_provinces_lines_shp.shp", context, globeShape,
                new ShapefileAppearance()
                {
                    PolylineWidth = 1.0,
                    PolylineOutlineWidth = 1.0
                });
            _rivers = new ShapefileRenderer("50m-rivers-lake-centerlines.shp", context, globeShape,
                new ShapefileAppearance()
                {
                    PolylineColor = Color.LightBlue,
                    PolylineOutlineColor = Color.LightBlue,
                    PolylineWidth = 1.0,
                    PolylineOutlineWidth = 0.0
                });
            
            _populatedPlaces = new ShapefileRenderer("110m_populated_places_simple.shp", context, globeShape,
                new ShapefileAppearance() { Bitmap = new Bitmap("032.png") });
            _airports = new ShapefileRenderer("airprtx020.shp", context, globeShape, 
                new ShapefileAppearance() { Bitmap = new Bitmap("car-red.png") });
            _amtrakStations = new ShapefileRenderer("amtrakx020.shp", context, globeShape, 
                new ShapefileAppearance() { Bitmap = new Bitmap("paper-plane--arrow.png") });

            _hudFont = new Font("Arial", 16);
            _hud = new HeadsUpDisplay();
            _hud.Color = Color.Blue;

            _showVectorData = true;

            _sceneState.DiffuseIntensity = 0.5f;
            _sceneState.SpecularIntensity = 0.1f;
            _sceneState.AmbientIntensity = 0.4f;
            _sceneState.Camera.ZoomToTarget(globeShape.MaximumRadius);

            UpdateHUD();
        }