Esempio n. 1
0
        public GlobeRayCasting()
        {
            Ellipsoid globeShape = Ellipsoid.ScaledWgs84;

            _window = Device.CreateWindow(800, 600, "Chapter 4:  Globe Ray Casting");
            _window.Resize += OnResize;
            _window.RenderFrame += OnRenderFrame;
            _sceneState = new SceneState();
            _camera = new CameraLookAtPoint(_sceneState.Camera, _window, globeShape);
            _clearState = new ClearState();

            _window.Keyboard.KeyDown += delegate(object sender, KeyboardKeyEventArgs e)
            {
                if (e.Key == KeyboardKey.P)
                {
                    CenterCameraOnPoint();
                }
                else if (e.Key == KeyboardKey.C)
                {
                    CenterCameraOnGlobeCenter();
                }
            };

            Bitmap bitmap = new Bitmap("NE2_50M_SR_W_4096.jpg");
            _texture = Device.CreateTexture2D(bitmap, TextureFormat.RedGreenBlue8, false);

            _globe = new RayCastedGlobe(_window.Context);
            _globe.Shape = globeShape;
            _globe.Texture = _texture;
            _globe.ShowWireframeBoundingBox = true;

            _sceneState.Camera.ZoomToTarget(globeShape.MaximumRadius);
        }
        public ClipmapTerrainOnGlobe()
        {
            _window = Device.CreateWindow(800, 600, "Chapter 13:  Clipmap Terrain on a Globe");

            _ellipsoid = Ellipsoid.Wgs84;

            WorldWindTerrainSource terrainSource = new WorldWindTerrainSource();
            EsriRestImagery imagery = new EsriRestImagery();
            _clipmap = new GlobeClipmapTerrain(_window.Context, terrainSource, imagery, _ellipsoid, 511);
            _clipmap.HeightExaggeration = 1.0f;

            _sceneState = new SceneState();
            _sceneState.DiffuseIntensity = 0.90f;
            _sceneState.SpecularIntensity = 0.05f;
            _sceneState.AmbientIntensity = 0.05f;
            _sceneState.Camera.FieldOfViewY = Math.PI / 3.0;

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

            _sceneState.Camera.PerspectiveNearPlaneDistance = 0.000001 * _ellipsoid.MaximumRadius;
            _sceneState.Camera.PerspectiveFarPlaneDistance = 10.0 * _ellipsoid.MaximumRadius;
            _sceneState.SunPosition = new Vector3D(200000, 300000, 200000) * _ellipsoid.MaximumRadius;

             _lookCamera = new CameraLookAtPoint(_sceneState.Camera, _window, _ellipsoid);
             _lookCamera.Range = 1.5 * _ellipsoid.MaximumRadius;

             _globe = new RayCastedGlobe(_window.Context);
             _globe.Shape = _ellipsoid;
             Bitmap bitmap = new Bitmap("NE2_50M_SR_W_4096.jpg");
             _globe.Texture = Device.CreateTexture2D(bitmap, TextureFormat.RedGreenBlue8, false);

             _clearDepth = new ClearState();
             _clearDepth.Buffers = ClearBuffers.DepthBuffer | ClearBuffers.StencilBuffer;

            _window.Keyboard.KeyDown += OnKeyDown;

            _window.Resize += OnResize;
            _window.RenderFrame += OnRenderFrame;
            _window.PreRenderFrame += OnPreRenderFrame;

            _hudFont = new Font("Arial", 16);
            _hud = new HeadsUpDisplay();
            _hud.Color = Color.Blue;
            UpdateHUD();
        }
Esempio n. 3
0
        public Curves()
        {
            _semiMinorAxis = Ellipsoid.ScaledWgs84.Radii.Z;
            SetShape();

            _window = Device.CreateWindow(800, 600, "Chapter 2:  Curves");
            _window.Resize += OnResize;
            _window.RenderFrame += OnRenderFrame;
            _window.Keyboard.KeyDown += OnKeyDown;
            _sceneState = new SceneState();
            _camera = new CameraLookAtPoint(_sceneState.Camera, _window, _globeShape);

            _clearState = new ClearState();

            _texture = Device.CreateTexture2D(new Texture2DDescription(1, 1, TextureFormat.RedGreenBlue8));
            WritePixelBuffer pixelBuffer = Device.CreateWritePixelBuffer(PixelBufferHint.Stream, 3);
            pixelBuffer.CopyFromSystemMemory(new byte[] { 0, 255, 127 });
            _texture.CopyFromBuffer(pixelBuffer, ImageFormat.RedGreenBlue, ImageDatatype.UnsignedByte, 1);

            _instructions = new HeadsUpDisplay();
            _instructions.Color = Color.Black;
            
            _sampledPoints = new BillboardCollection(_window.Context);
            _sampledPoints.Texture = Device.CreateTexture2D(Device.CreateBitmapFromPoint(8), TextureFormat.RedGreenBlueAlpha8, false);
            _sampledPoints.DepthTestEnabled = false;
            
            _ellipsoid = new RayCastedGlobe(_window.Context);
            _ellipsoid.Texture = _texture;

            _polyline = new Polyline();
            _polyline.Width = 3;
            _polyline.DepthTestEnabled = false;

            _plane = new Plane(_window.Context);
            _plane.Origin = Vector3D.Zero;
            _plane.OutlineWidth = 3;

            CreateScene();
            
            ///////////////////////////////////////////////////////////////////

            _sceneState.Camera.Eye = Vector3D.UnitY;
            _sceneState.Camera.ZoomToTarget(2 * _globeShape.MaximumRadius);
        }
Esempio n. 4
0
        public Multithreading()
        {
            Ellipsoid globeShape = Ellipsoid.ScaledWgs84;

            _workerWindow = Device.CreateWindow(1, 1);
            _window = Device.CreateWindow(800, 600, "Chapter 10:  Multithreading");
            _window.Resize += OnResize;
            _window.RenderFrame += OnRenderFrame;
            _sceneState = new SceneState();
            _camera = new CameraLookAtPoint(_sceneState.Camera, _window, globeShape);
            _clearState = new ClearState();

            Bitmap bitmap = new Bitmap("NE2_50M_SR_W_4096.jpg");
            _texture = Device.CreateTexture2D(bitmap, TextureFormat.RedGreenBlue8, false);

            _globe = new RayCastedGlobe(_window.Context);
            _globe.Shape = globeShape;
            _globe.Texture = _texture;
            _globe.UseAverageDepth = true;

            ///////////////////////////////////////////////////////////////////

            _doneQueue.MessageReceived += ProcessNewShapefile;

            _requestQueue.MessageReceived += new ShapefileWorker(_workerWindow.Context, globeShape, _doneQueue).Process;

            // 2ND_EDITION:  Draw order
            _requestQueue.Post(new ShapefileRequest("110m_admin_0_countries.shp", 
                new ShapefileAppearance()));
            _requestQueue.Post(new ShapefileRequest("110m_admin_1_states_provinces_lines_shp.shp", 
                new ShapefileAppearance()));
            _requestQueue.Post(new ShapefileRequest("airprtx020.shp", 
                new ShapefileAppearance() { Bitmap = new Bitmap("paper-plane--arrow.png") }));
            _requestQueue.Post(new ShapefileRequest("amtrakx020.shp", 
                new ShapefileAppearance() { Bitmap = new Bitmap("car-red.png") }));
            _requestQueue.Post(new ShapefileRequest("110m_populated_places_simple.shp", 
                new ShapefileAppearance() { Bitmap = new Bitmap("032.png") }));

#if SINGLE_THREADED
            _requestQueue.ProcessQueue();
#else
            _requestQueue.StartInAnotherThread();
#endif

            ///////////////////////////////////////////////////////////////////

            _sceneState.Camera.ZoomToTarget(globeShape.MaximumRadius);
        }
Esempio n. 5
0
        private void myButton1_Click(object sender, EventArgs e)
        {
            _window = Device.CreateWindow(800, 600, "Chapter 13:  Clipmap Terrain on a Globe");

            _ellipsoid = Ellipsoid.Wgs84;

            WorldWindTerrainSource terrainSource = new WorldWindTerrainSource();
            GMapRestImagery imagery = new GMapRestImagery();
            _clipmap = new GlobeClipmapTerrain(_window.Context, terrainSource, imagery, _ellipsoid, 511);
            _clipmap.HeightExaggeration = 1.0f;

            IList<GridResolution> gridResolutions = new List<GridResolution>();
            gridResolutions.Add(new GridResolution(
                new Interval(0, 1000000, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.005, 0.005)));
            gridResolutions.Add(new GridResolution(
                new Interval(1000000, 2000000, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.01, 0.01)));
            gridResolutions.Add(new GridResolution(
                new Interval(2000000, 20000000, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.05, 0.05)));
            gridResolutions.Add(new GridResolution(
                new Interval(20000000, double.MaxValue, IntervalEndpoint.Closed, IntervalEndpoint.Open),
                new Vector2D(0.1, 0.1)));

            _sceneState = new SceneState();
            _sceneState.DiffuseIntensity = 0.90f;
            _sceneState.SpecularIntensity = 0.05f;
            _sceneState.AmbientIntensity = 0.05f;
            _sceneState.Camera.FieldOfViewY = Math.PI / 3.0;

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

            _sceneState.Camera.PerspectiveNearPlaneDistance = 0.000001 * _ellipsoid.MaximumRadius;
            _sceneState.Camera.PerspectiveFarPlaneDistance = 10.0 * _ellipsoid.MaximumRadius;
            _sceneState.SunPosition = new Vector3D(200000, 300000, 200000) * _ellipsoid.MaximumRadius;

            _lookCamera = new CameraLookAtPoint(_sceneState.Camera, _window, _ellipsoid);
            _lookCamera.Range = 1.5 * _ellipsoid.MaximumRadius;

            _globe = new RayCastedGlobe(_window.Context);
            _globe.Shape = _ellipsoid;
            Bitmap bitmap = new Bitmap("NE2_50M_SR_W_4096.jpg");
            _globe.Texture = Device.CreateTexture2D(bitmap, TextureFormat.RedGreenBlue8, false);
            //_globe.GridResolutions = new GridResolutionCollection(gridResolutions);

            _clearDepth = new ClearState();
            _clearDepth.Buffers = ClearBuffers.DepthBuffer | ClearBuffers.StencilBuffer;

            //_window.Keyboard.KeyDown += OnKeyDown;

            _window.Resize += OnResize;
            _window.RenderFrame += OnRenderFrame;
            _window.PreRenderFrame += OnPreRenderFrame;

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

            //_flyCamera = new CameraFly(_sceneState.Camera, _window);
            //_flyCamera.MovementRate = 1200.0;
            //_flyCamera.InputEnabled = true;

            _sceneState.Camera.Target = new Vector3D(115, -35, 100.0);

            _window.Run(30);
        }