public void SetProjectionOffCenterTest()
        {
            OrthographicProjection projection = new OrthographicProjection();

            projection.SetOffCenter(0, 4, 1, 4, 2, 10);

            OrthographicProjection camera2 = new OrthographicProjection();

            camera2.SetOffCenter(0, 4, 1, 4);
            camera2.Near = 2;
            camera2.Far  = 10;

            Projection camera3 = new OrthographicProjection
            {
                Left   = 0,
                Right  = 4,
                Bottom = 1,
                Top    = 4,
                Near   = 2,
                Far    = 10,
            };

            Matrix expected = Matrix.CreateOrthographicOffCenter(0, 4, 1, 4, 2, 10);

            Assert.IsTrue(Matrix.AreNumericallyEqual(expected, projection));
            Assert.IsTrue(Matrix.AreNumericallyEqual(expected, camera2));
            Assert.IsTrue(Matrix.AreNumericallyEqual(expected, camera3.ToMatrix()));
        }
        public void SetProjectionTest()
        {
            OrthographicProjection projection = new OrthographicProjection();

            projection.Set(4, 3, 2, 10);

            OrthographicProjection camera2 = new OrthographicProjection();

            camera2.Set(4, 3);
            camera2.Near = 2;
            camera2.Far  = 10;

            OrthographicProjection camera3 = new OrthographicProjection
            {
                Left   = -2,
                Right  = 2,
                Bottom = -1.5f,
                Top    = 1.5f,
                Near   = 2,
                Far    = 10,
            };

            Matrix expected = Matrix.CreateOrthographic(4, 3, 2, 10);

            Assert.IsTrue(Matrix.AreNumericallyEqual(expected, projection));
            Assert.IsTrue(Matrix.AreNumericallyEqual(expected, camera2));
            Assert.IsTrue(Matrix.AreNumericallyEqual(expected, camera3.ToMatrix()));
        }
Exemplo n.º 3
0
        public SampleGraphicsScreen(IServiceLocator services)
            : base(services.GetInstance <IGraphicsService>())
        {
            _sampleFramework = services.GetInstance <SampleFramework>();

            Name              = "SampleScreen";
            ClearBackground   = false;
            BackgroundColor   = new Color(220, 220, 220);
            DrawReticle       = false;
            UseFixedWidthFont = false;

            // Use 2D texture for reticle.
            var contentManager = services.GetInstance <ContentManager>();

            _reticle = contentManager.Load <Texture2D>("Reticle");

            // Get the sprite fonts used in the UI theme.
            var uiContentManager = services.GetInstance <ContentManager>("UIContent");

            _defaultFont    = uiContentManager.Load <SpriteFont>("UI Themes/BlendBlue/Default");
            _fixedWidthFont = uiContentManager.Load <SpriteFont>("UI Themes/BlendBlue/Console");

            // Set up 2D camera such that (0, 0) is upper, left corner of screen and
            // (screenWidth, screenHeight) is lower, right corner of screen.
            var graphicsDevice = GraphicsService.GraphicsDevice;
            int screenWidth    = graphicsDevice.PresentationParameters.BackBufferWidth;
            int screenHeight   = graphicsDevice.PresentationParameters.BackBufferHeight;
            var projection     = new OrthographicProjection
            {
                Near = 0, Far = 2000,
                Left = 0, Right = screenWidth,
                Top  = 0, Bottom = screenHeight,
            };
            var camera = new Camera(projection);

            _cameraNode2D = new CameraNode(camera)
            {
                PoseWorld = new Pose(new Vector3F(0, 0, 1000)),
            };

            // Initialize renderers.
            _spriteBatch       = new SpriteBatch(graphicsDevice);
            _meshRenderer      = new MeshRenderer();
            _billboardRenderer = new BillboardRenderer(GraphicsService, 2048);
            DebugRenderer2D    = new DebugRenderer(GraphicsService, _defaultFont)
            {
                SpriteFont          = _defaultFont,
                DefaultColor        = new Color(0, 0, 0),
                DefaultTextPosition = new Vector2F(10)
            };
            DebugRenderer = new DebugRenderer(GraphicsService, _defaultFont)
            {
                SpriteFont          = _defaultFont,
                DefaultColor        = new Color(0, 0, 0),
                DefaultTextPosition = new Vector2F(10)
            };

            Scene = new Scene();
        }
Exemplo n.º 4
0
        public void GetScreenSizeWithOrthographic()
        {
            // Camera
            var projection = new OrthographicProjection();

            projection.SetOffCenter(0, 4, 0, 2);
            var camera     = new Camera(projection);
            var cameraNode = new CameraNode(camera);

            cameraNode.PoseWorld = new Pose(new Vector3(123, 456, -789), Matrix.CreateRotation(new Vector3(1, -2, 3), MathHelper.ToRadians(75)));

            // 2:1 viewport
            var viewport = new Viewport(10, 10, 200, 100);

            // Test object
            var shape           = new SphereShape();
            var geometricObject = new GeometricObject(shape);

            // Empty sphere at camera position.
            shape.Radius         = 0;
            geometricObject.Pose = cameraNode.PoseWorld;
            Vector2F screenSize = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);

            Assert.AreEqual(0, screenSize.X);
            Assert.AreEqual(0, screenSize.Y);

            // Empty sphere centered at near plane.
            shape.Radius         = 0;
            geometricObject.Pose = cameraNode.PoseWorld * new Pose(new Vector3(0.123f, -0.543f, -1));
            screenSize           = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
            Assert.AreEqual(0, screenSize.X);
            Assert.AreEqual(0, screenSize.Y);

            // Create sphere which as a bounding sphere of ~1 unit diameter:
            // Since the bounding sphere is based on the AABB, we need to make the
            // actual sphere a bit smaller.
            shape.Radius = 1 / (2 * (float)Math.Sqrt(3)) + Numeric.EpsilonF;

            // Sphere at camera position.
            geometricObject.Pose = cameraNode.PoseWorld;
            screenSize           = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
            Assert.IsTrue(Numeric.AreEqual(screenSize.X, 50.0f, 10f));
            Assert.IsTrue(Numeric.AreEqual(screenSize.Y, 50.0f, 10f));

            // Sphere at near plane.
            geometricObject.Pose = cameraNode.PoseWorld * new Pose(new Vector3(0.123f, -0.543f, -1));
            screenSize           = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
            Assert.IsTrue(Numeric.AreEqual(screenSize.X, 50.0f, 10f));
            Assert.IsTrue(Numeric.AreEqual(screenSize.Y, 50.0f, 10f));

            // Double distance --> same size
            geometricObject.Pose = cameraNode.PoseWorld * new Pose(new Vector3(0.123f, -0.543f, -2));
            screenSize           = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
            Assert.IsTrue(Numeric.AreEqual(screenSize.X, 50.0f, 10f));
            Assert.IsTrue(Numeric.AreEqual(screenSize.Y, 50.0f, 10f));
        }
Exemplo n.º 5
0
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (toolStripButtonPICK.Checked)
     {
         return;
     }
     _mdsx    = e.Location.X;
     _mdsy    = e.Location.Y;
     _mdOrtho = _ortho;
 }
Exemplo n.º 6
0
        public void GetScreenSizeWithOrthographic()
        {
            // Camera
              var projection = new OrthographicProjection();
              projection.SetOffCenter(0, 4, 0, 2);
              var camera = new Camera(projection);
              var cameraNode = new CameraNode(camera);
              cameraNode.PoseWorld = new Pose(new Vector3F(123, 456, -789), Matrix33F.CreateRotation(new Vector3F(1, -2, 3), MathHelper.ToRadians(75)));

              // 2:1 viewport
              var viewport = new Viewport(10, 10, 200, 100);

              // Test object
              var shape = new SphereShape();
              var geometricObject = new GeometricObject(shape);

              // Empty sphere at camera position.
              shape.Radius = 0;
              geometricObject.Pose = cameraNode.PoseWorld;
              Vector2F screenSize = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
              Assert.AreEqual(0, screenSize.X);
              Assert.AreEqual(0, screenSize.Y);

              // Empty sphere centered at near plane.
              shape.Radius = 0;
              geometricObject.Pose = cameraNode.PoseWorld * new Pose(new Vector3F(0.123f, -0.543f, -1));
              screenSize = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
              Assert.AreEqual(0, screenSize.X);
              Assert.AreEqual(0, screenSize.Y);

              // Create sphere which as a bounding sphere of ~1 unit diameter:
              // Since the bounding sphere is based on the AABB, we need to make the
              // actual sphere a bit smaller.
              shape.Radius = 1 / (2 * (float)Math.Sqrt(3)) + Numeric.EpsilonF;

              // Sphere at camera position.
              geometricObject.Pose = cameraNode.PoseWorld;
              screenSize = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
              Assert.IsTrue(Numeric.AreEqual(screenSize.X, 50.0f, 10f));
              Assert.IsTrue(Numeric.AreEqual(screenSize.Y, 50.0f, 10f));

              // Sphere at near plane.
              geometricObject.Pose = cameraNode.PoseWorld * new Pose(new Vector3F(0.123f, -0.543f, -1));
              screenSize = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
              Assert.IsTrue(Numeric.AreEqual(screenSize.X, 50.0f, 10f));
              Assert.IsTrue(Numeric.AreEqual(screenSize.Y, 50.0f, 10f));

              // Double distance --> same size
              geometricObject.Pose = cameraNode.PoseWorld * new Pose(new Vector3F(0.123f, -0.543f, -2));
              screenSize = GraphicsHelper.GetScreenSize(cameraNode, viewport, geometricObject);
              Assert.IsTrue(Numeric.AreEqual(screenSize.X, 50.0f, 10f));
              Assert.IsTrue(Numeric.AreEqual(screenSize.Y, 50.0f, 10f));
        }
Exemplo n.º 7
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            double x, y, lat, lon;

            _getXY(e.Location, out x, out y);
            _ortho.ToSphere(x, y, out lat, out lon);
            string     text    = null;
            WSMCountry cDef    = _ttC.GetDataAtPointer(e) as WSMCountry;
            string     country = (cDef == null ? "Sea" : cDef.Name);

            if (!double.IsNaN(lat) && !double.IsNaN(lon))
            {
                text = "Latitude:" + GeoCoordinateUtilities.FormatLatitude(lat) + "   Longitude:" +
                       GeoCoordinateUtilities.FormatLongitude(lon);
                _pointerGeoCoordinate = new GeoCoordinate(lat, lon);
            }
            else
            {
                _pointerGeoCoordinate = null;
                country = "SPACE";
            }
            text        += ("   [" + country + "]");
            _pointerText = text;

            if (!toolStripButtonPICK.Checked && _mdOrtho != null)
            {
                // moving view
                double deltaDeg = 90.0 / _worldScreenRadius;
                double φ0       = _mdOrtho.φ0 + deltaDeg * (e.Location.Y - _mdsy);
                if (φ0 > 90)
                {
                    φ0 = 90;
                }
                if (φ0 < -90)
                {
                    φ0 = -90;
                }
                double λ0 = _mdOrtho.λ0 - deltaDeg * (e.Location.X - _mdsx);
                λ0 = OrthographicProjection.SanitizeLongitude(λ0);
                trackBar1.Value = (int)Math.Round(φ0 * 100);
                trackBar2.Value = (int)Math.Round(λ0 * 100);
                _updateProjection();
                _invalidateAllLayers(true);
                return;
            }

            // not moving view
            _mouseOverCountry    = cDef;
            _layerDynamic1.Dirty = true;
            _layerDynamic2.Dirty = true;
            pictureBox1.Refresh();
        }
Exemplo n.º 8
0
        public void SetUp()
        {
            Dictionary <CoordinateOperationParameter, Object> parameters = new Dictionary <CoordinateOperationParameter, Object>();

            parameters.Add(CoordinateOperationParameters.LatitudeOfNaturalOrigin, Angle.FromDegree(55, 0, 0));
            parameters.Add(CoordinateOperationParameters.LongitudeOfNaturalOrigin, Angle.FromDegree(5, 0, 0));
            parameters.Add(CoordinateOperationParameters.FalseEasting, Length.FromMetre(0));
            parameters.Add(CoordinateOperationParameters.FalseNorthing, Length.FromMetre(0));

            Ellipsoid ellipsoid = Ellipsoid.FromInverseFlattening("EPSG::4326", "WGS 84", 6378137.0, 298.2572236);
            AreaOfUse areaOfUse = TestUtilities.ReferenceProvider.AreasOfUse["EPSG::1306"];

            this.projection = new OrthographicProjection("EPSG::4326", "WGS 84 / Orthographic", parameters, ellipsoid, areaOfUse);
        }
Exemplo n.º 9
0
        public void SetProjectionTest()
        {
            Matrix projectionMatrix = Matrix.CreateOrthographicOffCenter(1, 4, 2, 5, 6, 11);
            OrthographicProjection orthographicProjection = new OrthographicProjection();

            orthographicProjection.Set(projectionMatrix);
            CameraInstance cameraInstance = new CameraInstance(new Camera(orthographicProjection));

            Assert.AreEqual(Vector3.Zero, cameraInstance.PoseWorld.Position);
            Assert.AreEqual(Matrix.Identity, cameraInstance.PoseWorld.Orientation);
            Assert.That(Numeric.AreEqual(3, cameraInstance.Camera.Projection.Width));
            Assert.That(Numeric.AreEqual(3, cameraInstance.Camera.Projection.Height));
            Assert.That(Numeric.AreEqual(1f, cameraInstance.Camera.Projection.AspectRatio));
            Assert.That(Numeric.AreEqual(6, cameraInstance.Camera.Projection.Near));
            Assert.That(Numeric.AreEqual(11, cameraInstance.Camera.Projection.Far));
            Assert.That(Numeric.AreEqual(1, cameraInstance.Camera.Projection.Left));
            Assert.That(Numeric.AreEqual(4, cameraInstance.Camera.Projection.Right));
            Assert.That(Numeric.AreEqual(2, cameraInstance.Camera.Projection.Bottom));
            Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Top));
            Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Depth));
            Assert.That(Matrix.AreNumericallyEqual(orthographicProjection, cameraInstance.Camera.Projection));
            Assert.That(Matrix.AreNumericallyEqual(orthographicProjection.Inverse, cameraInstance.Camera.Projection.Inverse));
            Assert.IsNotNull(cameraInstance.BoundingShape);

            PerspectiveProjection perspectiveProjection = new PerspectiveProjection();

            perspectiveProjection.Inverse = Matrix.CreatePerspectiveOffCenter(1, 5, 2, 5, 1, 10).Inverse;
            cameraInstance = new CameraInstance(new Camera(perspectiveProjection));

            Assert.AreEqual(Vector3.Zero, cameraInstance.PoseWorld.Position);
            Assert.AreEqual(Matrix.Identity, cameraInstance.PoseWorld.Orientation);
            Assert.That(Numeric.AreEqual(MathHelper.ToRadians(33.690067f), cameraInstance.Camera.Projection.FieldOfViewX));
            Assert.That(Numeric.AreEqual(MathHelper.ToRadians(15.255119f), cameraInstance.Camera.Projection.FieldOfViewY));
            Assert.That(Numeric.AreEqual(4, cameraInstance.Camera.Projection.Width));
            Assert.That(Numeric.AreEqual(3, cameraInstance.Camera.Projection.Height));
            Assert.That(Numeric.AreEqual(4.0f / 3.0f, cameraInstance.Camera.Projection.AspectRatio));
            Assert.That(Numeric.AreEqual(1, cameraInstance.Camera.Projection.Left));
            Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Right));
            Assert.That(Numeric.AreEqual(2, cameraInstance.Camera.Projection.Bottom));
            Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Top));
            Assert.That(Numeric.AreEqual(1, cameraInstance.Camera.Projection.Near));
            Assert.That(Numeric.AreEqual(10, cameraInstance.Camera.Projection.Far));
            Assert.That(Numeric.AreEqual(9, cameraInstance.Camera.Projection.Depth));
            Assert.IsNotNull(cameraInstance.BoundingShape);
        }
        public virtual MapProjection GetProjection(string crsId)
        {
            MapProjection projection = null;

            switch (crsId)
            {
            case WorldMercatorProjection.DefaultCrsId:
                projection = new WorldMercatorProjection();
                break;

            case WebMercatorProjection.DefaultCrsId:
                projection = new WebMercatorProjection();
                break;

            case EquirectangularProjection.DefaultCrsId:
                projection = new EquirectangularProjection();
                break;

            case OrthographicProjection.DefaultCrsId:
                projection = new OrthographicProjection();
                break;

            case AutoEquirectangularProjection.DefaultCrsId:
                projection = new AutoEquirectangularProjection();
                break;

            case GnomonicProjection.DefaultCrsId:
                projection = new GnomonicProjection();
                break;

            case StereographicProjection.DefaultCrsId:
                projection = new StereographicProjection();
                break;

            case "EPSG:97003":     // proprietary CRS ID
                projection = new AzimuthalEquidistantProjection(crsId);
                break;

            default:
                break;
            }

            return(projection);
        }
        public void SetProjectionOffCenterTest()
        {
            OrthographicProjection projection = new OrthographicProjection();
              projection.SetOffCenter(0, 4, 1, 4, 2, 10);

              OrthographicProjection camera2 = new OrthographicProjection();
              camera2.SetOffCenter(0, 4, 1, 4);
              camera2.Near = 2;
              camera2.Far = 10;

              Projection camera3 = new OrthographicProjection
              {
            Left = 0,
            Right = 4,
            Bottom = 1,
            Top = 4,
            Near = 2,
            Far = 10,
              };

              Matrix44F expected = Matrix44F.CreateOrthographicOffCenter(0, 4, 1, 4, 2, 10);
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(expected, projection));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(expected, camera2));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(expected, camera3.ToMatrix44F()));
        }
Exemplo n.º 12
0
        private bool _cullingEnabled = true; // True to use frustum culling. False to disable frustum culling.


        public FrustumCullingSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            GraphicsScreen.ClearBackground = true;
            GraphicsScreen.BackgroundColor = Color.CornflowerBlue;

            // The top-down camera.
            var orthographicProjection = new OrthographicProjection();

            orthographicProjection.Set(
                LevelSize * 1.1f * GraphicsService.GraphicsDevice.Viewport.AspectRatio,
                LevelSize * 1.1f,
                1,
                10000f);
            var topDownCamera = new Camera(orthographicProjection);

            _topDownCameraNode = new CameraNode(topDownCamera)
            {
                View = Matrix44F.CreateLookAt(new Vector3F(0, 1000, 0), new Vector3F(0, 0, 0), -Vector3F.UnitZ),
            };

            // The perspective camera moving through the scene.
            var perspectiveProjection = new PerspectiveProjection();

            perspectiveProjection.SetFieldOfView(
                MathHelper.ToRadians(45),
                GraphicsService.GraphicsDevice.Viewport.AspectRatio,
                1,
                500);
            var sceneCamera = new Camera(perspectiveProjection);

            _sceneCameraNode = new CameraNode(sceneCamera);

            // Initialize collision detection.
            // We use one collision domain that manages all objects.
            _domain = new CollisionDomain(new CollisionDetection())
            {
                // We exchange the default broad phase with a DualPartition. The DualPartition
                // has special support for frustum culling.
                BroadPhase = new DualPartition <CollisionObject>(),
            };

            // Create a lot of random objects and add them to the collision domain.
            RandomHelper.Random = new Random(12345);
            for (int i = 0; i < NumberOfObjects; i++)
            {
                // A real scene consists of a lot of complex objects such as characters, vehicles,
                // buildings, lights, etc. When doing frustum culling we need to test each objects against
                // the viewing frustum. If it intersects with the viewing frustum, the object is visible
                // from the camera's point of view. However, in practice we do not test the exact object
                // against the viewing frustum. Each objects is approximated by a simpler shape. In our
                // example, we assume that each object is approximated with an oriented bounding box.
                // (We could also use an other shape, such as a bounding sphere.)

                // Create a random box.
                Shape randomShape = new BoxShape(RandomHelper.Random.NextVector3F(1, 10));

                // Create a random position.
                Vector3F randomPosition;
                randomPosition.X = RandomHelper.Random.NextFloat(-LevelSize / 2, LevelSize / 2);
                randomPosition.Y = RandomHelper.Random.NextFloat(0, 2);
                randomPosition.Z = RandomHelper.Random.NextFloat(-LevelSize / 2, LevelSize / 2);

                // Create a random orientation.
                QuaternionF randomOrientation = RandomHelper.Random.NextQuaternionF();

                // Create object and add it to collision domain.
                var geometricObject = new GeometricObject(randomShape, new Pose(randomPosition, randomOrientation));
                var collisionObject = new CollisionObject(geometricObject)
                {
                    CollisionGroup = 0,
                };
                _domain.CollisionObjects.Add(collisionObject);
            }

            // Per default, the collision domain computes collision between all objects.
            // In this sample we do not need this information and disable it with a collision
            // filter.
            // In a real application, we would use this collision information for rendering,
            // for example, to find out which lights overlap with which meshes, etc.
            var filter = new CollisionFilter();

            // Disable collision between objects in collision group 0.
            filter.Set(0, 0, false);
            _domain.CollisionDetection.CollisionFilter = filter;

            // Start with the top-down camera.
            GraphicsScreen.CameraNode = _topDownCameraNode;

            // We will collect a few statistics for debugging.
            Profiler.SetFormat("NoCull", 1000, "Time in ms to submit DebugRenderer draw jobs without frustum culling.");
            Profiler.SetFormat("WithCull", 1000, "Time in ms to submit DebugRenderer draw jobs with frustum culling.");
        }
Exemplo n.º 13
0
        private void _updateProjection()
        {
            double x, y;

            double lat = trackBar1.Value / 100.0;

            labelLAT.Text = lat.ToString(CultureInfo.InvariantCulture);
            labelLAT.Refresh();
            double lon = trackBar2.Value / 100.0;

            labelLONG.Text = lon.ToString(CultureInfo.InvariantCulture);
            labelLONG.Refresh();
            _zoomRadius   = trackBar3.Value;
            labelRAD.Text = _zoomRadius.ToString(CultureInfo.InvariantCulture);
            labelRAD.Refresh();


            _ortho = new OrthographicProjection(lat, lon);

            _stressTable.ProjectToTangentPlane(_ortho, textBoxFILTER.Text);

            // extras
            StressTable.ProjectToTangentPlane(_ortho, _myList);
            StressTable.ProjectToTangentPlane(_ortho, _closeList);

            foreach (var mLine in mapLines)
            {
                foreach (var item in mLine.Collection)
                {
                    if (_ortho.ToTangentPlane(item.Latitude, item.Longitude, out x, out y))
                    {
                        item.ProjectedX = x;
                        item.ProjectedY = y;
                    }
                    else
                    {
                        item.ProjectedX = double.NaN;
                        item.ProjectedY = double.NaN;
                    }
                }
            }

            if (cities != null)
            {
                foreach (NamedCoordinate nC in cities.Collection)
                {
                    if (_ortho.ToTangentPlane(nC.Latitude, nC.Longitude, out x, out y))
                    {
                        nC.ProjectedX = x;
                        nC.ProjectedY = y;
                    }
                    else
                    {
                        nC.ProjectedX = double.NaN;
                        nC.ProjectedY = double.NaN;
                    }
                }
            }

            foreach (WSMCountry cDef in _rwmap.Collection)
            {
                var cc = cDef.CentralCoordinate;
                if (_ortho.ToTangentPlane(cc.Latitude, cc.Longitude, out x, out y))
                {
                    cc.ProjectedX = x;
                    cc.ProjectedY = y;
                }
                else
                {
                    cc.ProjectedX = double.NaN;
                    cc.ProjectedY = double.NaN;
                }

                foreach (WSMPolygon poly in cDef.Collection)
                {
                    int nOk = 0;
                    poly.MinX = poly.MinY = double.MaxValue;
                    poly.MaxX = poly.MaxY = double.MinValue;
                    foreach (BaseCoordinate item in poly.Collection)
                    {
                        if (_ortho.ToTangentPlane(item.Latitude, item.Longitude, out x, out y))
                        {
                            item.ProjectedX = x;
                            item.ProjectedY = y;
                            nOk++;
                            poly.MinX = Math.Min(poly.MinX, x);
                            poly.MinY = Math.Min(poly.MinY, y);
                            poly.MaxX = Math.Max(poly.MaxX, x);
                            poly.MaxY = Math.Max(poly.MaxY, y);
                        }
                        else
                        {
                            item.ProjectedX = double.NaN;
                            item.ProjectedY = double.NaN;
                        }
                    }
                    poly.Draw = nOk >= 3;
                }
            }


            _invalidateAllLayers(false);
        }
Exemplo n.º 14
0
 private void trackBar_Scroll(object sender, EventArgs e)
 {
     _mdOrtho = _ortho;
     _updateProjection();
     _invalidateAllLayers(true);
 }
Exemplo n.º 15
0
 private void trackBar_MouseUp(object sender, MouseEventArgs e)
 {
     _mdOrtho = null;
     _invalidateAllLayers(true);
 }
Exemplo n.º 16
0
        public void SetProjectionTest()
        {
            Matrix44F projectionMatrix = Matrix44F.CreateOrthographicOffCenter(1, 4, 2, 5, 6, 11);
              OrthographicProjection orthographicProjection = new OrthographicProjection();
              orthographicProjection.Set(projectionMatrix);
              CameraInstance cameraInstance = new CameraInstance(new Camera(orthographicProjection));

              Assert.AreEqual(Vector3F.Zero, cameraInstance.PoseWorld.Position);
              Assert.AreEqual(Matrix33F.Identity, cameraInstance.PoseWorld.Orientation);
              Assert.That(Numeric.AreEqual(3, cameraInstance.Camera.Projection.Width));
              Assert.That(Numeric.AreEqual(3, cameraInstance.Camera.Projection.Height));
              Assert.That(Numeric.AreEqual(1f, cameraInstance.Camera.Projection.AspectRatio));
              Assert.That(Numeric.AreEqual(6, cameraInstance.Camera.Projection.Near));
              Assert.That(Numeric.AreEqual(11, cameraInstance.Camera.Projection.Far));
              Assert.That(Numeric.AreEqual(1, cameraInstance.Camera.Projection.Left));
              Assert.That(Numeric.AreEqual(4, cameraInstance.Camera.Projection.Right));
              Assert.That(Numeric.AreEqual(2, cameraInstance.Camera.Projection.Bottom));
              Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Top));
              Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Depth));
              Assert.That(Matrix44F.AreNumericallyEqual(orthographicProjection, cameraInstance.Camera.Projection));
              Assert.That(Matrix44F.AreNumericallyEqual(orthographicProjection.Inverse, cameraInstance.Camera.Projection.Inverse));
              Assert.IsNotNull(cameraInstance.BoundingShape);

              PerspectiveProjection perspectiveProjection = new PerspectiveProjection();
              perspectiveProjection.Inverse = Matrix44F.CreatePerspectiveOffCenter(1, 5, 2, 5, 1, 10).Inverse;
              cameraInstance = new CameraInstance(new Camera(perspectiveProjection));

              Assert.AreEqual(Vector3F.Zero, cameraInstance.PoseWorld.Position);
              Assert.AreEqual(Matrix33F.Identity, cameraInstance.PoseWorld.Orientation);
              Assert.That(Numeric.AreEqual(MathHelper.ToRadians(33.690067f), cameraInstance.Camera.Projection.FieldOfViewX));
              Assert.That(Numeric.AreEqual(MathHelper.ToRadians(15.255119f), cameraInstance.Camera.Projection.FieldOfViewY));
              Assert.That(Numeric.AreEqual(4, cameraInstance.Camera.Projection.Width));
              Assert.That(Numeric.AreEqual(3, cameraInstance.Camera.Projection.Height));
              Assert.That(Numeric.AreEqual(4.0f / 3.0f, cameraInstance.Camera.Projection.AspectRatio));
              Assert.That(Numeric.AreEqual(1, cameraInstance.Camera.Projection.Left));
              Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Right));
              Assert.That(Numeric.AreEqual(2, cameraInstance.Camera.Projection.Bottom));
              Assert.That(Numeric.AreEqual(5, cameraInstance.Camera.Projection.Top));
              Assert.That(Numeric.AreEqual(1, cameraInstance.Camera.Projection.Near));
              Assert.That(Numeric.AreEqual(10, cameraInstance.Camera.Projection.Far));
              Assert.That(Numeric.AreEqual(9, cameraInstance.Camera.Projection.Depth));
              Assert.IsNotNull(cameraInstance.BoundingShape);
        }
Exemplo n.º 17
0
 private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     _mdOrtho           = null;
     _layerStress.Dirty = true;
     pictureBox1.Invalidate();
 }
        public void SetProjectionTest()
        {
            OrthographicProjection projection = new OrthographicProjection();
              projection.Set(4, 3, 2, 10);

              OrthographicProjection camera2 = new OrthographicProjection();
              camera2.Set(4, 3);
              camera2.Near = 2;
              camera2.Far = 10;

              OrthographicProjection camera3 = new OrthographicProjection
              {
            Left = -2,
            Right = 2,
            Bottom = -1.5f,
            Top = 1.5f,
            Near = 2,
            Far = 10,
              };

              Matrix44F expected = Matrix44F.CreateOrthographic(4, 3, 2, 10);
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(expected, projection));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(expected, camera2));
              Assert.IsTrue(Matrix44F.AreNumericallyEqual(expected, camera3.ToMatrix44F()));
        }