コード例 #1
0
        internal void SetupMatricesLand3d()
        {
            Lighting = false;
            Space    = false;
            RenderTriangle.CullInside = false;

            // For our world matrix, we will just rotate the Earth and Clouds about the y-axis.
            Matrix3d WorldMatrix = Matrix3d.RotationY(((ViewCamera.Lng - 90f) / 180f * Math.PI));

            WorldMatrix.Multiply(Matrix3d.RotationX(((-ViewCamera.Lat) / 180f * Math.PI)));
            World     = WorldMatrix;
            WorldBase = WorldMatrix.Clone();

            viewPoint = Coordinates.GeoTo3d(ViewCamera.Lat, ViewCamera.Lng);

            double distance = 0;

            if (backgroundImageset.IsMandelbrot)
            {
                distance = (4.0 * (ViewCamera.Zoom / 180)) + 0.00000000000000000000000000000000000000001;
            }
            else
            {
                distance = (4.0 * (ViewCamera.Zoom / 180)) + 0.000001;
            }
            fovAngle = ((this.ViewCamera.Zoom) / FOVMULT) / Math.PI * 180;
            fovScale = (fovAngle / Height) * 3600;

            if (gl != null)
            {
                targetAltitude = GetScaledAltitudeForLatLong(ViewCamera.Lat, ViewCamera.Lng);
                double heightNow = 1 + targetAltitude;
                targetAltitude *= NominalRadius;
                //if ((double.IsNaN(heightNow)))
                //{
                //    heightNow = 0;
                //}

                if (targetHeight < heightNow)
                {
                    targetHeight = (((targetHeight * 2) + heightNow) / 3);
                }
                else
                {
                    targetHeight = (((targetHeight * 9) + heightNow) / 10);
                }
                //if (double.IsNaN(targetHeight))
                //{
                //    targetHeight = 0;
                //}
            }
            else
            {
                targetAltitude = 0;
                targetHeight   = 1;
            }

            double rotLocal = ViewCamera.Rotation;

            CameraPosition = Vector3d.Create(
                (Math.Sin(rotLocal) * Math.Sin(ViewCamera.Angle) * distance),
                (Math.Cos(rotLocal) * Math.Sin(ViewCamera.Angle) * distance),
                (-targetHeight - (Math.Cos(ViewCamera.Angle) * distance)));
            Vector3d cameraTarget = Vector3d.Create(0.0f, 0.0f, -targetHeight);


            double camHeight = CameraPosition.Length();


            Vector3d lookUp = Vector3d.Create(Math.Sin(rotLocal) * Math.Cos(ViewCamera.Angle), Math.Cos(rotLocal) * Math.Cos(ViewCamera.Angle), Math.Sin(ViewCamera.Angle));

            View = Matrix3d.LookAtLH(
                (CameraPosition),
                (cameraTarget),
                lookUp);
            // * Matrix3d.RotationX(((-config.DomeTilt) / 180 * Math.PI));

            ViewBase = View;

            double back = Math.Sqrt((distance + 1f) * (distance + 1f) - 1);

            back = Math.Max(.5, back);
            // back = (float)camDist * 40f;
            double m_nearPlane = distance * .05f;

            m_nearPlane = distance * .05f;
            Projection  = Matrix3d.PerspectiveFovLH((Math.PI / 4.0), (double)Width / (double)Height, m_nearPlane, back);

            SetMatrixes();

            MakeFrustum();
        }