public override void Render(TextWriter writer, RenderTypes renderTypes)
 {
     foreach (var element in this.ChildElements)
     {
         element.Render(writer, renderTypes);
     }
 }
Esempio n. 2
0
        public override void Render(TextWriter writer, RenderTypes renderTypes)
        {
            var renderer = RenderFactory.Create(renderTypes, ElementTypes.Hyperlink, this);

            renderer.Render(writer);

            if (renderTypes == RenderTypes.Html)
            {
                if (this.ChildElements.Count > 0)
                {
                    base.Render(writer, renderTypes);
                }
                else
                {
                    writer.Write(this.Url.HtmlEncode());
                }

                renderer = FinishRenderersFactory.Create(FinishTypes.Hyperlink, renderTypes, this);
                renderer.Render(writer);
            }

            if (renderTypes == RenderTypes.Text)
            {
                base.Render(writer, renderTypes);
                renderer = FinishRenderersFactory.Create(FinishTypes.Hyperlink, renderTypes, this);
                renderer.Render(writer);
            }
        }
Esempio n. 3
0
        private static void DrawWireOverlay(Mesh meshToRender, RenderTypes renderType, Color color, Action meshChanged = null)
        {
            GL.Color4(color.red, color.green, color.blue, color.alpha == 0 ? 255 : color.alpha);

            GL.Disable(EnableCap.Lighting);

            GL.DisableClientState(ArrayCap.TextureCoordArray);
            GLMeshWirePlugin glWireMeshPlugin = null;

            if (renderType == RenderTypes.Outlines)
            {
                glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender, MathHelper.Tau / 8, meshChanged);
            }
            else
            {
                glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender);
            }

            GL.EnableClientState(ArrayCap.VertexArray);
            VectorPOD <WireVertexData> edgeLines = glWireMeshPlugin.EdgeLines;

            unsafe
            {
                fixed(WireVertexData *pv = edgeLines.Array)
                {
                    GL.VertexPointer(3, VertexPointerType.Float, 0, new IntPtr(pv));
                    GL.DrawArrays(BeginMode.Lines, 0, edgeLines.Count);
                }
            }

            GL.DisableClientState(ArrayCap.VertexArray);
            GL.Enable(EnableCap.Lighting);
        }
Esempio n. 4
0
        public override void Render(TextWriter writer, RenderTypes renderTypes)
        {
            var renderer = RenderFactory.Create(renderTypes, ElementTypes.Paragraph, this);

            renderer.Render(writer);
            base.Render(writer, renderTypes);

            renderer = FinishRenderersFactory.Create(FinishTypes.Paragraph, renderTypes, this);
            renderer.Render(writer);
        }
Esempio n. 5
0
 public static void Render(Mesh meshToRender,
                           Color partColor,
                           RenderTypes renderType        = RenderTypes.Shaded,
                           Matrix4X4?meshToViewTransform = null,
                           Color wireFrameColor          = default(Color),
                           Action meshChanged            = null,
                           bool blendTexture             = true,
                           bool forceCullBackFaces       = true)
 {
     Render(meshToRender, partColor, Matrix4X4.Identity, renderType, meshToViewTransform, wireFrameColor, meshChanged, blendTexture, forceCullBackFaces: forceCullBackFaces);
 }
Esempio n. 6
0
        public override void Render(TextWriter writer, RenderTypes renderTypes)
        {
            var renderer = RenderFactory.Create(renderTypes, ElementTypes.Document, this);

            renderer.Render(writer);
            base.Render(writer, renderTypes);

            if (renderTypes == RenderTypes.Html)
            {
                renderer = FinishRenderersFactory.Create(FinishTypes.DocumentHtmlFinish, renderTypes, this);
                renderer.Render(writer);
            }
        }
Esempio n. 7
0
        public XCamera(ref XMain X, float nearplane, float farplane)
            : base(ref X)
        {
            ProjectionType = ProjectionTypes.Perspective;
            RenderType     = RenderTypes.Normal;
            NearPlane      = nearplane;
            FarPlane       = farplane;
            FOV            = MathHelper.PiOver4;
            GenerateProjection(ref X, this.FOV, this.ProjectionType, NearPlane, FarPlane);

            Base      = this;
            DrawOrder = 50000;
        }
        private static void DrawWithWireOverlay(Mesh meshToRender, RenderTypes renderType)
        {
            GLMeshTrianglePlugin glMeshPlugin = GLMeshTrianglePlugin.Get(meshToRender);

            GL.Enable(EnableCap.PolygonOffsetFill);
            GL.PolygonOffset(1, 1);

            DrawToGL(meshToRender);

            GL.Color4(0, 0, 0, 255);

            GL.PolygonOffset(0, 0);
            GL.Disable(EnableCap.PolygonOffsetFill);
            GL.Disable(EnableCap.Lighting);

            GL.DisableClientState(ArrayCap.TextureCoordArray);
            GLMeshWirePlugin glWireMeshPlugin = null;

            if (renderType == RenderTypes.Outlines)
            {
                glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender, MathHelper.Tau / 8);
            }
            else
            {
                glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender);
            }

            VectorPOD <WireVertexData> edegLines = glWireMeshPlugin.edgeLinesData;

            GL.EnableClientState(ArrayCap.VertexArray);

#if true
            unsafe
            {
                fixed(WireVertexData *pv = edegLines.Array)
                {
                    GL.VertexPointer(3, VertexPointerType.Float, 0, new IntPtr(pv));
                    GL.DrawArrays(BeginMode.Lines, 0, edegLines.Count);
                }
            }
#else
            GL.InterleavedArrays(InterleavedArrayFormat.V3f, 0, edegLines.Array);
            GL.DrawArrays(BeginMode.Lines, 0, edegLines.Count);
#endif

            GL.DisableClientState(ArrayCap.VertexArray);
            GL.Enable(EnableCap.Lighting);
        }
Esempio n. 9
0
        public static IRenderer Create(RenderTypes renderTypes, ElementTypes elementTypes, object element)
        {
            IRenderer renderer = null;

            switch (renderTypes)
            {
            case RenderTypes.Text:
                renderer = TextRenderFactory.Create(elementTypes, element);
                return(renderer);

            case RenderTypes.Html:
                renderer = HtmlRenderFactory.Create(elementTypes, element);
                return(renderer);

            default:
                throw new NotSupportedException("Not suportet Render Type");
            }
        }
 public static void Render(Mesh meshToRender, IColorType partColor, RenderTypes renderType = RenderTypes.Shaded)
 {
     Render(meshToRender, partColor, Matrix4X4.Identity, renderType);
 }
Esempio n. 11
0
        private void SetupMatricesSpaceMultiChannel(double localZoomFactor, RenderTypes renderType)
        {
            bool faceSouth = false;

            if ((Settings.Active.LocalHorizonMode && !Settings.Active.GalacticMode) && CurrentImageSet.DataSetType == ImageSetType.Sky)
            {
                faceSouth = !Properties.Settings.Default.FaceNorth;
                Coordinates currentRaDec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(0, 0), SpaceTimeController.Location, SpaceTimeController.Now);

                alt = 0;
                az = 0;
                config.DomeTilt = 0;
                if (Properties.Settings.Default.DomeTilt != 0)
                {
                    Properties.Settings.Default.DomeTilt = 0;
                }

                TargetLat = ViewLat = currentRaDec.Dec;
                TargetLong = ViewLong = RAtoViewLng(currentRaDec.RA);

            }

            if (SolarSystemTrack != SolarSystemObjects.Custom && SolarSystemTrack != SolarSystemObjects.Undefined)
            {
                viewCamera.ViewTarget = Planets.GetPlanetTargetPoint(SolarSystemTrack, ViewLat, ViewLong, 0);
            }

            RenderContext11.LightingEnabled = false;

            double localZoom = ZoomFactor * 20;
            Vector3d lookAt = new Vector3d(0, 0, -1);
            FovAngle = ((ZoomFactor/**16*/) / FOVMULT) / Math.PI * 180;

            // for constellations
            ViewPoint = Coordinates.RADecTo3d(this.RA, -this.Dec, 1.0);


            double distance = (Math.Min(1, (.5 * (ZoomFactor / 180)))) - 1 + 0.0001;

            RenderContext11.CameraPosition = new Vector3d(0, 0, distance);
            Vector3d lookUp = new Vector3d(Math.Sin(CameraRotate), Math.Cos(CameraRotate), 0.0001f);

            Matrix3d lookAtAdjust = Matrix3d.Identity;

            if ((Settings.Active.GalacticMode && !Settings.Active.LocalHorizonMode) && CurrentImageSet.DataSetType == ImageSetType.Sky)
            {
                if (!galMatInit)
                {
                    galacticMatrix = Matrix3d.Identity;
                    galacticMatrix.Multiply(Matrix3d.RotationY(-(90 - (17.7603329867975 * 15)) / 180.0 * Math.PI));
                    galacticMatrix.Multiply(Matrix3d.RotationX(-((-28.9361739586894)) / 180.0 * Math.PI));
                    galacticMatrix.Multiply(Matrix3d.RotationZ(((31.422052860102041270114993238783) - 90) / 180.0 * Math.PI));
                    galMatInit = true;
                }

                WorldMatrix = galacticMatrix;
                WorldMatrix.Multiply(Matrix3d.RotationY(((az)) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(-((alt)) / 180.0 * Math.PI));


                double[] gPoint = Coordinates.GalactictoJ2000(az, alt);

                this.RA = gPoint[0] / 15;
                this.Dec = gPoint[1];
                targetViewCamera.Lat = viewCamera.Lat;
                targetViewCamera.Lng = viewCamera.Lng;
            }
            else
            {
                // Show in Ecliptic

                WorldMatrix = Matrix3d.RotationY(-((this.ViewLong + 90) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(((-this.ViewLat) / 180.0 * Math.PI)));
            }


            RenderContext11.World = WorldMatrix;
            RenderContext11.WorldBase = WorldMatrix;



            lookAt.TransformCoordinate(lookAtAdjust);
            Matrix3d matHeadingPitchRoll;

            if (DomePreviewPopup.Active)
            {
                matHeadingPitchRoll =

                      Matrix3d.RotationY((DomePreviewPopup.Az / 180 * Math.PI)) *
                      Matrix3d.RotationX((DomePreviewPopup.Alt / 180 * Math.PI));
            }
            else
            {
                matHeadingPitchRoll =
                      Matrix3d.RotationZ((config.Roll / 180 * Math.PI)) *
                      Matrix3d.RotationY((config.Heading / 180 * Math.PI)) *
                      Matrix3d.RotationX(((config.Pitch) / 180 * Math.PI));
            }

            if (rift)
            {
                Matrix3d matRiftView = Matrix3d.RotationY(GetHeading()) * Matrix3d.RotationX(GetPitch()) * Matrix3d.RotationZ(-GetRoll());
                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * matRiftView;
            }
            else
            {
                Matrix3d matNorth = Matrix3d.RotationY(faceSouth ? Math.PI : 0);

                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * matNorth * DomeMatrix * matHeadingPitchRoll;
            }

            Vector3d temp = lookAt - RenderContext11.CameraPosition;
            temp.Normalize();
            ViewPoint = temp;

            // Set the near clip plane close enough that the sky dome isn't clipped
            double cameraZ = (Math.Min(1, (.5 * (ZoomFactor / 180)))) - 1 + 0.0001;
            m_nearPlane = (float)(1.0 + cameraZ) * 0.5f;

            back = 12;
            double aspect = config.Aspect;
            double top = m_nearPlane * 2 / ((1 / Math.Tan(config.UpFov / 180 * Math.PI))) / 2;
            double bottom = m_nearPlane * 2 / -(1 / Math.Tan(config.DownFov / 180 * Math.PI)) / 2;
            double right = m_nearPlane * 2 / (1 / Math.Tan((config.UpFov + config.DownFov) / 2 / 180 * Math.PI)) * aspect / 2;
            double left = -right;


            if (config.MultiChannelDome1)
            {
                ProjMatrix = Matrix3d.PerspectiveOffCenterLH(
                    left,
                    right,
                    bottom,
                    top,
                    m_nearPlane,
                    back);
            }
            else if (rift)
            {
                RenderContext11.View = RenderContext11.View * config.ViewMatrix;
                ProjMatrix = Matrix3d.PerspectiveFovLH(riftFov, (double)ViewWidth / (double)renderWindow.ClientRectangle.Height, m_nearPlane, back);
                RenderContext11.PerspectiveFov = riftFov;

            }
            else
            {
                RenderContext11.View = RenderContext11.View * config.ViewMatrix;
                ProjMatrix = Matrix3d.PerspectiveFovLH((75f / 180f) * Math.PI, 1.777778, m_nearPlane, back);

            }

            if (rift)
            {
                if (renderType == RenderTypes.LeftEye)
                {

                    ProjMatrix.M31 += iod;
                }
                else
                {
                    ProjMatrix.M31 -= iod;
                }
            }


            RenderContext11.Projection = ProjMatrix;

            ViewMatrix = RenderContext11.View;
            RenderContext11.ViewBase = RenderContext11.View;
            MakeFrustum();
        }
Esempio n. 12
0
 public abstract void Render(TextWriter writer, RenderTypes renderTypes);
Esempio n. 13
0
        public override void Render(TextWriter writer, RenderTypes renderTypes)
        {
            var renderer = RenderFactory.Create(renderTypes, ElementTypes.TextElement, this);

            renderer.Render(writer);
        }
Esempio n. 14
0
		public static void Render(Mesh meshToRender, IColorType partColor, RenderTypes renderType = RenderTypes.Shaded)
		{
			Render(meshToRender, partColor, Matrix4X4.Identity, renderType);
		}
Esempio n. 15
0
        private void RenderFrame(RenderTargetTexture targetTexture, DepthBuffer depthBuffer, RenderTypes renderType)
        {
            CurrentRenderType = renderType;

            bool offscreenRender = targetTexture != null;

            Tile.deepestLevel = 0;
 
            try
            {
                if (offscreenRender)
                {
                    RenderContext11.SetOffscreenRenderTargets(targetTexture, depthBuffer);
                }
                else
                {
                    RenderContext11.SetDisplayRenderTargets();
                }

                //Clear the backbuffer to a black color 

                RenderContext11.ClearRenderTarget(new SharpDX.Color(SkyColor.R, SkyColor.G, SkyColor.B, SkyColor.A));



                RenderContext11.RenderType = CurrentImageSet.DataSetType;

                RenderContext11.BlendMode = BlendMode.Alpha;
                if (CurrentImageSet.DataSetType == ImageSetType.Sandbox)
                {
                    // Start Sandbox mode
                    RenderContext11.SunPosition = LayerManager.GetPrimarySandboxLight();
                    RenderContext11.SunlightColor = LayerManager.GetPrimarySandboxLightColor();

                    RenderContext11.ReflectedLightColor = Color.Black;
                    RenderContext11.HemisphereLightColor = Color.Black;

                    SkyColor = Color.Black;
                    if ((int)SolarSystemTrack < (int)SolarSystemObjects.Custom)
                    {
                        double radius = Planets.GetAdjustedPlanetRadius((int)SolarSystemTrack);
                        double distance = SolarSystemCameraDistance;
                        double camAngle = fovLocal;
                        double distrad = distance / (radius * Math.Tan(.5 * camAngle));
                        if (distrad < 1)
                        {
                            planetFovWidth = Math.Asin(distrad);
                        }
                        else
                        {
                            planetFovWidth = Math.PI;
                        }
                    }
                    else
                    {
                        planetFovWidth = Math.PI;
                    }


                    SetupMatricesSolarSystem11(false, renderType);

 
                    Matrix3d matLocal = RenderContext11.World;
                    matLocal.Multiply(Matrix3d.Translation(-viewCamera.ViewTarget));
                    RenderContext11.World = matLocal;

                    RenderContext11.WorldBase = RenderContext11.World;
                    RenderContext11.WorldBaseNonRotating = RenderContext11.World;
                    RenderContext11.NominalRadius = 1;

                    Earth3d.MainWindow.MakeFrustum();

                    double zoom = Earth3d.MainWindow.ZoomFactor;

                    LayerManager.Draw(RenderContext11, 1.0f, false, "Sandbox", true, false);

                    if ((SolarSystemMode) && label != null && !TourPlayer.Playing)
                    {
                        label.Draw(RenderContext11, true);
                    }

                    RenderContext11.setRasterizerState(TriangleCullMode.Off);
                    // end Sandbox Mode
                }
                else if (CurrentImageSet.DataSetType == ImageSetType.SolarSystem)
                {



                    {
                        SkyColor = Color.Black;
                        if ((int)SolarSystemTrack < (int)SolarSystemObjects.Custom)
                        {
                            double radius = Planets.GetAdjustedPlanetRadius((int)SolarSystemTrack);
                            double distance = SolarSystemCameraDistance;
                            double camAngle = fovLocal;
                            double distrad = distance / (radius * Math.Tan(.5 * camAngle));
                            if (distrad < 1)
                            {
                                planetFovWidth = Math.Asin(distrad);
                            }
                            else
                            {
                                planetFovWidth = Math.PI;
                            }
                        }
                        else
                        {
                            planetFovWidth = Math.PI;
                        }


                        if (trackingObject == null)
                        {
                            trackingObject = Search.FindCatalogObjectExact("Sun");
                        }

                        SetupMatricesSolarSystem11(true, renderType);



                        float skyOpacity = 1.0f - Planets.CalculateSkyBrightnessFactor(RenderContext11.View, viewCamera.ViewTarget);
                        if (float.IsNaN(skyOpacity))
                        {
                            skyOpacity = 0f;
                        }

                        double zoom = Earth3d.MainWindow.ZoomFactor;
                        float milkyWayBlend = (float)Math.Min(1, Math.Max(0, (Math.Log(zoom) - 8.4)) / 4.2);
                        float milkyWayBlendIn = (float)Math.Min(1, Math.Max(0, (Math.Log(zoom) - 17.9)) / 2.3);


                        if (Properties.Settings.Default.SolarSystemMilkyWay.State)
                        {
                            if (milkyWayBlend < 1) // Solar System mode Milky Way background
                            {
                                if (milkyWayBackground == null)
                                {
                                    milkyWayBackground = GetImagesetByName("Digitized Sky Survey (Color)");
                                }

                                if (milkyWayBackground != null)
                                {
                                    float c = ((1 - milkyWayBlend)) / 4;
                                    Matrix3d matOldMW = RenderContext11.World;
                                    Matrix3d matLocalMW = RenderContext11.World;
                                    matLocalMW.Multiply(Matrix3d.Scaling(100000, 100000, 100000));
                                    matLocalMW.Multiply(Matrix3d.RotationX(-23.5 / 180 * Math.PI));
                                    matLocalMW.Multiply(Matrix3d.RotationY(Math.PI));
                                    matLocalMW.Multiply(Matrix3d.Translation(cameraOffset));
                                    RenderContext11.World = matLocalMW;
                                    RenderContext11.WorldBase = matLocalMW;
                                    Earth3d.MainWindow.MakeFrustum();

                                    RenderContext11.SetupBasicEffect(BasicEffect.TextureColorOpacity, 1, Color.White);
                                    RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                                    DrawTiledSphere(milkyWayBackground, c * Properties.Settings.Default.SolarSystemMilkyWay.Opacity, Color.FromArgb(255, 255, 255, 255));
                                    RenderContext11.World = matOldMW;
                                    RenderContext11.WorldBase = matOldMW;
                                    RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                                }
                            }
                        }

                        // CMB

                        float cmbBlend = (float)Math.Min(1, Math.Max(0, (Math.Log(zoom) - 33)) / 2.3);


                        double cmbLog = Math.Log(zoom);

                        if (Properties.Settings.Default.SolarSystemCMB.State)
                        {
                            if (cmbBlend > 0) // Solar System mode Milky Way background
                            {
                                if (cmbBackground == null)
                                {
                                    cmbBackground = GetImagesetByName("Planck CMB");
                                }

                                if (cmbBackground != null)
                                {
                                    float c = ((cmbBlend)) / 16;
                                    Matrix3d matOldMW = RenderContext11.World;
                                    Matrix3d matLocalMW = RenderContext11.World;
  
                                    matLocalMW.Multiply(Matrix3d.Scaling(2.9090248982E+15, 2.9090248982E+15, 2.9090248982E+15));
                                    matLocalMW.Multiply(Matrix3d.RotationX(-23.5 / 180 * Math.PI));
                                    matLocalMW.Multiply(Matrix3d.RotationY(Math.PI));

                                    RenderContext11.World = matLocalMW;
                                    RenderContext11.WorldBase = matLocalMW;
                                    Earth3d.MainWindow.MakeFrustum();

                                    RenderContext11.SetupBasicEffect(BasicEffect.TextureColorOpacity, 1, Color.White);

                                    RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                                    DrawTiledSphere(cmbBackground, c * Properties.Settings.Default.SolarSystemCMB.Opacity, Color.FromArgb(255, 255, 255, 255));
                                    RenderContext11.World = matOldMW;
                                    RenderContext11.WorldBase = matOldMW;
                                    RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                                }
                            }
                        }




                        {
                            Matrix3d matOld = RenderContext11.World;

                            Matrix3d matLocal = RenderContext11.World;
                            matLocal.Multiply(Matrix3d.Translation(viewCamera.ViewTarget));
                            RenderContext11.World = matLocal;
                            Earth3d.MainWindow.MakeFrustum();

                            if (Properties.Settings.Default.SolarSystemCosmos.State)
                            {
                                RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                                Grids.DrawCosmos3D(RenderContext11, Properties.Settings.Default.SolarSystemCosmos.Opacity * skyOpacity);
                                RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                            }

                            if (true)
                            {
                                RenderContext11.DepthStencilMode = DepthStencilMode.Off;

                                Grids.DrawCustomCosmos3D(RenderContext11, skyOpacity);

                                RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                            }


                            if (Properties.Settings.Default.SolarSystemMilkyWay.State && milkyWayBlendIn > 0)
                            {
                                Grids.DrawGalaxy3D(RenderContext11, Properties.Settings.Default.SolarSystemMilkyWay.Opacity * skyOpacity * milkyWayBlendIn);
                            }


                            if (Properties.Settings.Default.SolarSystemStars.State)
                            {
                                Grids.DrawStars3D(RenderContext11, Properties.Settings.Default.SolarSystemStars.Opacity * skyOpacity);
                            }

                                         
                            LayerManager.Draw(RenderContext11, 1.0f, true, "Sky", true, false);

                            RenderContext11.World = matOld;
                            Earth3d.MainWindow.MakeFrustum();
                        }


                        if (SolarSystemCameraDistance < 15000)
                        {
                            SetupMatricesSolarSystem11(false, renderType);


                            if (Properties.Settings.Default.SolarSystemMinorPlanets.State)
                            {
                                MinorPlanets.DrawMPC3D(RenderContext11, Properties.Settings.Default.SolarSystemMinorPlanets.Opacity, viewCamera.ViewTarget);
                            }

                            Planets.DrawPlanets3D(RenderContext11, Properties.Settings.Default.SolarSystemPlanets.Opacity, viewCamera.ViewTarget);
                        }

                        double p = Math.Log(zoom);
                        double d = (180 / SolarSystemCameraDistance) * 100; 

                        float sunAtDistance = (float)Math.Min(1, Math.Max(0, (Math.Log(zoom) - 7.5)) / 3);

                        if (sunAtDistance > 0 && Settings.Active.SolarSystemPlanets)
                        {
                            Planets.DrawPointPlanet(RenderContext11, new Vector3d(0, 0, 0), (float)d * sunAtDistance, Color.FromArgb(192, 191, 128), false, 1);
                        }

                        if ((SolarSystemMode) && label != null && !TourPlayer.Playing)
                        {
                            label.Draw(RenderContext11, true);
                        }
                    }

                    RenderContext11.setRasterizerState(TriangleCullMode.Off);
                }
                else
                {

                    if (CurrentImageSet.DataSetType == ImageSetType.Panorama || CurrentImageSet.DataSetType == ImageSetType.Sky)
                    {
                        SkyColor = Color.Black;

                        if ((int)renderType < 5)
                        {
                            SetupMatricesSpaceDome(false, renderType);
                        }
                        else
                        {
                            SetupMatricesSpace11(ZoomFactor, renderType);
                        }
                        RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                    }
                    else
                    {

                        if (Settings.DomeView)
                        {
                            SetupMatricesLandDome(renderType);
                        }
                        else
                        {
                            SetupMatricesLand11(renderType);
                        }
                        RenderContext11.DepthStencilMode = DepthStencilMode.ZReadWrite;
                    }

                    ComputeViewParameters(CurrentImageSet);

                    // Update Context pane
                    CurrentViewCorners = new Coordinates[] 
                    {
                        GetCoordinatesForScreenPoint(0, 0),
                        GetCoordinatesForScreenPoint(ViewWidth, 0),
                        GetCoordinatesForScreenPoint(ViewWidth, renderWindow.ClientRectangle.Height),
                        GetCoordinatesForScreenPoint(0, renderWindow.ClientRectangle.Height) 
                    };

                    Coordinates temp = GetCoordinatesForScreenPoint(ViewWidth / 2, renderWindow.ClientRectangle.Height / 2);

                    if (contextPanel != null && ((int)renderType > 4 || renderType == RenderTypes.DomeFront))
                    {
                        contextPanel.SetViewRect(CurrentViewCorners);
                    }
                    UpdateKmlViewInfo();

                    if (KmlMarkers != null)
                    {
                        KmlMarkers.ClearGroundOverlays();
                    }

                    string referenceFrame = GetCurrentReferenceFrame();


                    if (PlanetLike || Space)
                    {
                        LayerManager.PreDraw(RenderContext11, 1.0f, Space, referenceFrame, true);
                    }

                    if (Properties.Settings.Default.EarthCutawayView.State && !Space && CurrentImageSet.DataSetType == ImageSetType.Earth)
                    {
                        Grids.DrawEarthStructure(RenderContext11, 1f);
                    }

                    RenderContext11.SetupBasicEffect(BasicEffect.TextureColorOpacity, 1, Color.White);

                    if (KmlMarkers != null)
                    {
                        KmlMarkers.SetupGroundOverlays(RenderContext11);
                    }

                    if (PlanetLike)
                    {
                        RenderContext11.setRasterizerState(TriangleCullMode.Off);
                    }

                    // Call DrawTiledSphere instead of PaintLayerFull, because PaintLayerFull
                    // will reset ground layer state
                    DrawTiledSphere(CurrentImageSet, 1.0f, Color.White);


                    if (imageStackVisible)
                    {
                        foreach (ImageSet set in ImageStackList)
                        {
                            PaintLayerFull11(set, StudyOpacity);
                        }
                    }

                    if (studyImageset != null)
                    {
                        if (studyImageset.DataSetType != CurrentImageSet.DataSetType)
                        {
                            StudyImageset = null;
                        }
                        else
                        {
                            PaintLayerFull11(studyImageset, StudyOpacity);
                        }
                    }


                    if (previewImageset != null && PreviewBlend.State)
                    {
                        if (previewImageset.DataSetType != CurrentImageSet.DataSetType)
                        {
                            previewImageset = null;
                        }
                        else
                        {
                            PaintLayerFull11(previewImageset, PreviewBlend.Opacity * 100.0f);
                        }
                    }
                    else
                    {
                        PreviewBlend.State = false;
                        previewImageset = null;
                    }


                    if (Space && (CurrentImageSet.Name == "Plotted Sky"))
                    {

                        Grids.DrawStars(RenderContext11, 1f);
                    }

                    if (Space && Properties.Settings.Default.ShowSolarSystem.State)
                    {
                        Planets.DrawPlanets(RenderContext11, Properties.Settings.Default.ShowSolarSystem.Opacity);
                    }


                    if (PlanetLike || Space)
                    {
                        if (!Space)
                        {
                            //todo fix this for other planets..
                            double angle = Coordinates.MstFromUTC2(SpaceTimeController.Now, 0) / 180.0 * Math.PI;
                            RenderContext11.WorldBaseNonRotating = Matrix3d.RotationY(angle) * RenderContext11.WorldBase;
                            RenderContext11.NominalRadius = CurrentImageSet.MeanRadius;
                        }
                        else
                        {
                            RenderContext11.WorldBaseNonRotating = RenderContext11.World;
                            RenderContext11.NominalRadius = CurrentImageSet.MeanRadius;
                            RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                        }

                        LayerManager.Draw(RenderContext11, 1.0f, Space, referenceFrame, true, Space);
                    }

                    if (Space && !hemisphereView && Settings.Active.LocalHorizonMode && !Settings.DomeView && !ProjectorServer)
                    {
                        Grids.DrawHorizon(RenderContext11, 1f);
                    }

                    if (Settings.Active.ShowClouds && !Space && CurrentImageSet.DataSetType == ImageSetType.Earth)
                    {
                        DrawClouds();
                    }


                    // Draw Field of view indicator

                    if (Settings.Active.ShowFieldOfView)
                    {
                        fovBlend.TargetState = true;
                    }
                    else
                    {
                        fovBlend.TargetState = false;
                    }

                    if (fovBlend.State)
                    {
                        if (fov != null && Space)
                        {
                            fov.Draw3D(RenderContext11, fovBlend.Opacity, RA, Dec);
                        }
                    }

                    if (label != null && !TourPlayer.Playing)
                    {
                        label.Draw(RenderContext11, PlanetLike);
                    }

                    if (ShowKmlMarkers && KmlMarkers != null)
                    {
                        KmlMarkers.DrawLabels(RenderContext11);
                    }



                    // End Planet & space
                }

                if (uiController != null)
                {
                    {
                        uiController.Render(this);
                    }
                }

                if (videoOverlay != null)
                {
                    if ((int)renderType < 5)
                    {
                        SetupMatricesVideoOverlayDome(false, renderType);
                    }
                    else
                    {
                        SetupMatricesVideoOverlay(ZoomFactor);
                    }
                    DepthStencilMode mode = RenderContext11.DepthStencilMode = DepthStencilMode.Off;
                    PaintLayerFull11(videoOverlay, 100f);
                    RenderContext11.DepthStencilMode = mode;
                }

                if (measuringDrag && measureLines != null)
                {
                    measureLines.DrawLines(RenderContext11, 1.0f, Color.Yellow);

                }

                if (Properties.Settings.Default.ShowCrosshairs && !TourPlayer.Playing && renderType == RenderTypes.Normal)
                {
                    float aspect = RenderContext11.ViewPort.Height / RenderContext11.ViewPort.Width;


                    crossHairPoints[0].X = .01f * aspect;
                    crossHairPoints[1].X = -.01f * aspect;
                    crossHairPoints[0].Y = 0;
                    crossHairPoints[1].Y = 0;
                    crossHairPoints[0].Z = .9f;
                    crossHairPoints[1].Z = .9f;
                    crossHairPoints[0].W = 1f;
                    crossHairPoints[1].W = 1f;
                    crossHairPoints[0].Color = Color.White;
                    crossHairPoints[1].Color = Color.White;

                    crossHairPoints[2].X = 0;
                    crossHairPoints[3].X = 0;
                    crossHairPoints[2].Y = -.01f;
                    crossHairPoints[3].Y = .01f;
                    crossHairPoints[2].Z = .9f;
                    crossHairPoints[3].Z = .9f;
                    crossHairPoints[2].W = 1f;
                    crossHairPoints[3].W = 1f;
                    crossHairPoints[2].Color = Color.White;
                    crossHairPoints[3].Color = Color.White;

                    Sprite2d.DrawLines(RenderContext11, crossHairPoints, 4, SharpDX.Matrix.OrthoLH(1f, 1f, 1, -1), false);

                }


                if (Properties.Settings.Default.ShowTouchControls && (!TourPlayer.Playing || mover == null) && ( renderType == RenderTypes.Normal || renderType == RenderTypes.LeftEye || renderType == RenderTypes.RightEye) && !rift )
                {
                    DrawTouchControls();
                }


                DrawKinectUI();

                SetupMatricesAltAz();
                Reticle.DrawAll(RenderContext11);


            }
            catch (Exception e)
            {
                if (Earth3d.Logging) { Earth3d.WriteLogMessage("RenderFrame: Exception"); }
                if (offscreenRender)
                {
                    throw e;
                }
            }
            finally
            {
                if (offscreenRender)
                {

                    RenderContext11.SetDisplayRenderTargets();
                }
            }

            PresentFrame11(offscreenRender);
        }
Esempio n. 16
0
        private void SetupMatricesVideoOverlayDome(bool forStars, RenderTypes renderType)
        {


            Vector3d center = viewCamera.ViewTarget;
            RenderContext11.LightingEnabled = false;

            double localZoom = ZoomFactor * 20;
            Vector3d lookAt = new Vector3d(0, 0, -1);
            FovAngle = ((360) / FOVMULT) / Math.PI * 180;

            double distance = 1;

            RenderContext11.CameraPosition = new Vector3d(0, 0, distance);
            Vector3d lookUp = new Vector3d(Math.Sin(-0), Math.Cos(-0), 0.0001f);

            Matrix3d lookAtAdjust = Matrix3d.Identity;

            switch (renderType)
            {
                case RenderTypes.DomeUp:
                    lookAtAdjust.Multiply(Matrix3d.RotationX(Math.PI / 2));
                    break;
                case RenderTypes.DomeLeft:
                    lookAtAdjust.Multiply(Matrix3d.RotationY(Math.PI / 2));
                    break;
                case RenderTypes.DomeRight:
                    lookAtAdjust.Multiply(Matrix3d.RotationY(-Math.PI / 2));
                    break;
                case RenderTypes.DomeFront:
                    break;
                case RenderTypes.DomeBack:
                    lookAtAdjust.Multiply(Matrix3d.RotationY(Math.PI));
                    break;
                default:
                    break;
            }

            WorldMatrix = Matrix3d.RotationY(-((0 + 90) / 180f * Math.PI));
            WorldMatrix.Multiply(Matrix3d.RotationX(((0) / 180f * Math.PI)));
            RenderContext11.World = WorldMatrix;
            RenderContext11.WorldBase = WorldMatrix;

            if (rift)
            {
                double amount = 0;
                Matrix3d stereoTranslate = Matrix3d.Translation(renderType == RenderTypes.LeftEye ? amount : -amount, 0, 0);
                Matrix3d matRiftView = Matrix3d.RotationY(GetHeading()) * Matrix3d.RotationX(GetPitch()) * Matrix3d.RotationZ(-GetRoll());
                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * DomeMatrix * lookAtAdjust * matRiftView * stereoTranslate;
            }
            else
            {
                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * DomeMatrix * lookAtAdjust;
            }

            Vector3d temp = lookAt - RenderContext11.CameraPosition;
            temp.Normalize();
            ViewPoint = temp;


            m_nearPlane = ((.000000001));

            if (rift)
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH(riftFov, 1.0f, m_nearPlane, -1f);
            }
            else
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH((Math.PI / 2.0), 1.0f, m_nearPlane, -1f);
            }

            if (multiMonClient)
            {
                ProjMatrix.M11 *= MonitorCountX * bezelSpacing;
                ProjMatrix.M22 *= MonitorCountY * bezelSpacing;
                ProjMatrix.M31 = (MonitorCountX - 1) - (MonitorX * bezelSpacing * 2);
                ProjMatrix.M32 = -((MonitorCountY - 1) - (MonitorY * bezelSpacing * 2));
            }

            if (rift)
            {
                if (renderType == RenderTypes.LeftEye)
                {

                    ProjMatrix.M31 += iod;
                }
                else
                {
                    ProjMatrix.M31 -= iod;
                }
            }

            RenderContext11.Projection = ProjMatrix;

            ViewMatrix = RenderContext11.View;
            RenderContext11.ViewBase = RenderContext11.View;
            MakeFrustum();
        }
Esempio n. 17
0
        private void SetupMatricesSpaceDome(bool forStars, RenderTypes renderType)
        {

            if (SolarSystemTrack != SolarSystemObjects.Custom && SolarSystemTrack != SolarSystemObjects.Undefined)
            {
                viewCamera.ViewTarget = Planets.GetPlanetTargetPoint(SolarSystemTrack, ViewLat, ViewLong, 0);
            }


            double camLocal = CameraRotate;
            if ((Settings.Active.LocalHorizonMode && !Settings.Active.GalacticMode) && CurrentImageSet.DataSetType == ImageSetType.Sky)
            {
                if (Properties.Settings.Default.ShowHorizon != false)
                {
                    Properties.Settings.Default.ShowHorizon = false;
                }
                Coordinates zenithAltAz = new Coordinates(0, 0);

                zenithAltAz.Az = 0;

                zenithAltAz.Alt = 0;

                ZoomFactor = TargetZoom = ZoomMax;
                alt = 0;
                az = 0;

                Coordinates zenith = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now);

                double raPart = -((zenith.RA - 6) / 24.0 * (Math.PI * 2));
                double decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2));
                string raText = Coordinates.FormatDMS(zenith.RA);
                WorldMatrix = Matrix3d.RotationY(-raPart);
                WorldMatrix.Multiply(Matrix3d.RotationX(decPart));

                if (SpaceTimeController.Location.Lat < 0)
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((alt) / 180.0 * Math.PI)));
                    camLocal += Math.PI;
                }
                else
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((-az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((-alt) / 180.0 * Math.PI)));
                }

                Coordinates currentRaDec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now);

                TargetLat = ViewLat = currentRaDec.Dec;
                TargetLong = ViewLong = RAtoViewLng(currentRaDec.RA);

            }

            Vector3d center = viewCamera.ViewTarget;
            RenderContext11.LightingEnabled = false;

            double localZoom = ZoomFactor * 20;
            Vector3d lookAt = new Vector3d(0, 0, -1);
            FovAngle = ((ZoomFactor/**16*/) / FOVMULT) / Math.PI * 180;


             double distance = (Math.Min(1, (.5 * (ZoomFactor / 180)))) - 1 + 0.0001;

            RenderContext11.CameraPosition = new Vector3d(0, 0, distance);
            Vector3d lookUp = new Vector3d(Math.Sin(-CameraRotate), Math.Cos(-CameraRotate), 0.0001f);

            Matrix3d lookAtAdjust = Matrix3d.Identity;

            switch (renderType)
            {
                case RenderTypes.DomeUp:
                    lookAtAdjust.Multiply(Matrix3d.RotationX(Math.PI / 2));
                    break;
                case RenderTypes.DomeLeft:
                    lookAtAdjust.Multiply(Matrix3d.RotationY(Math.PI / 2));
                    break;
                case RenderTypes.DomeRight:
                    lookAtAdjust.Multiply(Matrix3d.RotationY(-Math.PI / 2));
                    break;
                case RenderTypes.DomeFront:
                    break;
                case RenderTypes.DomeBack:
                    lookAtAdjust.Multiply(Matrix3d.RotationY(Math.PI));
                    break;
                default:
                    break;
            }


            if ((Settings.Active.GalacticMode && !Settings.Active.LocalHorizonMode) && CurrentImageSet.DataSetType == ImageSetType.Sky)
            {
                if (!galMatInit)
                {
                    galacticMatrix = Matrix3d.Identity;
                    galacticMatrix.Multiply(Matrix3d.RotationY(-(90 - (17.7603329867975 * 15)) / 180.0 * Math.PI));
                    galacticMatrix.Multiply(Matrix3d.RotationX(-((-28.9361739586894)) / 180.0 * Math.PI));
                    galacticMatrix.Multiply(Matrix3d.RotationZ(((31.422052860102041270114993238783) - 90) / 180.0 * Math.PI));
                    galMatInit = true;
                }

                WorldMatrix = galacticMatrix;
                WorldMatrix.Multiply(Matrix3d.RotationY(((az)) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(-((alt)) / 180.0 * Math.PI));


                double[] gPoint = Coordinates.GalactictoJ2000(az, alt);

                this.RA = gPoint[0] / 15;
                this.Dec = gPoint[1];
                targetViewCamera.Lat = viewCamera.Lat;
                targetViewCamera.Lng = viewCamera.Lng;
            }
            else
            {
                // Show in Ecliptic

                WorldMatrix = Matrix3d.RotationY(-((this.ViewLong + 90.0) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(((-this.ViewLat) / 180.0 * Math.PI)));
            }

            RenderContext11.World = WorldMatrix;
            RenderContext11.WorldBase = WorldMatrix;


            if (Settings.Active.LocalHorizonMode)
            {
                Matrix3d matNorth = Matrix3d.RotationY(Properties.Settings.Default.FaceNorth ? 0 : Math.PI);
                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * matNorth * DomeAngleMatrix * lookAtAdjust;
            }
            else
            {
                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * DomeMatrix * lookAtAdjust;
            }
            Vector3d temp = lookAt - RenderContext11.CameraPosition;
            temp.Normalize();
            ViewPoint = temp;

            // Set the near clip plane close enough that the sky dome isn't clipped
            double cameraZ = (Math.Min(1, (.5 * (ZoomFactor / 180)))) - 1 + 0.0001;
            m_nearPlane = (float)(1.0 + cameraZ) * 0.5f;

            ProjMatrix = Matrix3d.PerspectiveFovLH((Math.PI / 2.0), 1.0f, m_nearPlane, -1f);
            RenderContext11.PerspectiveFov = (Math.PI / 2.0);
            if (multiMonClient)
            {
                ProjMatrix.M11 *= MonitorCountX * bezelSpacing;
                ProjMatrix.M22 *= MonitorCountY * bezelSpacing;
                ProjMatrix.M31 = (MonitorCountX - 1) - (MonitorX * bezelSpacing * 2);
                ProjMatrix.M32 = -((MonitorCountY - 1) - (MonitorY * bezelSpacing * 2));
            }

            RenderContext11.Projection = ProjMatrix;

            ViewMatrix = RenderContext11.View;
            RenderContext11.ViewBase = RenderContext11.View;
            MakeFrustum();
        }
Esempio n. 18
0
        private void SetupMatricesSolarSystem11(bool forStars, RenderTypes renderType)
        {
            if (SandboxMode)
            {
                if (SolarSystemTrack != SolarSystemObjects.Custom && SolarSystemTrack != SolarSystemObjects.Undefined)
                {
                    viewCamera.ViewTarget = new Vector3d();
                }
            }
            else
            {
                if (SolarSystemTrack != SolarSystemObjects.Custom && SolarSystemTrack != SolarSystemObjects.Undefined)
                {
                    viewCamera.ViewTarget = Planets.GetPlanetTargetPoint(SolarSystemTrack, ViewLat, ViewLong, 0);
                }
            }



            double cameraDistance = SolarSystemCameraDistance;

            Matrix3d trackingMatrix = Matrix3d.Identity;
            cameraDistance -= 0.000001;

            bool activeTrackingFrame = false;
            if (SolarSystemTrack == SolarSystemObjects.Custom && !string.IsNullOrEmpty(TrackingFrame))
            {
                activeTrackingFrame = true;
                viewCamera.ViewTarget = LayerManager.GetFrameTarget(RenderContext11, TrackingFrame, out trackingMatrix);
            }
            else if (!string.IsNullOrEmpty(TrackingFrame))
            {
                TrackingFrame = "";
            }


            Vector3d center = viewCamera.ViewTarget;
            Vector3d lightPosition = -center;

            double localZoom = ZoomFactor * 20;
            Vector3d lookAt = new Vector3d(0, 0, 0);

            Matrix3d viewAdjust = Matrix3d.Identity;
            viewAdjust.Multiply(Matrix3d.RotationX(((-this.ViewLat) / 180f * Math.PI)));
            viewAdjust.Multiply(Matrix3d.RotationY(((-this.ViewLong) / 180f * Math.PI)));

            Matrix3d lookAtAdjust = Matrix3d.Identity;


            bool dome = false;

            Vector3d lookUp;





            if (useSolarSystemTilt && !SandboxMode)
            {
                double angle = CameraAngle;
                if (cameraDistance > 0.0008)
                {
                    angle = 0;
                }
                else if (cameraDistance > 0.00001)
                {
                    double val = Math.Min(1.903089987, Math.Log(cameraDistance, 10) + 5) / 1.903089987;

                    angle = angle * Math.Max(0, 1 - val);
                }



                RenderContext11.CameraPosition = new Vector3d(
                (Math.Sin(-CameraRotate) * Math.Sin(angle) * cameraDistance),
                (Math.Cos(-CameraRotate) * Math.Sin(angle) * cameraDistance),
                ((Math.Cos(angle) * cameraDistance)));
                lookUp = new Vector3d(Math.Sin(-CameraRotate), Math.Cos(-CameraRotate), 0.00001f);
            }
            else
            {
                RenderContext11.CameraPosition = new Vector3d(0, 0, ((cameraDistance)));

                lookUp = new Vector3d(Math.Sin(-CameraRotate), Math.Cos(-CameraRotate), 0.0001f);
            }


            RenderContext11.CameraPosition.TransformCoordinate(viewAdjust);

            cameraOffset = RenderContext11.CameraPosition;

            cameraOffset.TransformCoordinate(Matrix3d.Invert(trackingMatrix));



            lookUp.TransformCoordinate(viewAdjust);



            switch (renderType)
            {
                case RenderTypes.DomeUp:
                    dome = true;
                    lookAtAdjust.Multiply(Matrix3d.RotationX(Math.PI / 2));
                    break;
                case RenderTypes.DomeLeft:
                    dome = true;
                    lookAtAdjust.Multiply(Matrix3d.RotationY(Math.PI / 2));
                    break;
                case RenderTypes.DomeRight:
                    dome = true;
                    lookAtAdjust.Multiply(Matrix3d.RotationY(-Math.PI / 2));
                    break;
                case RenderTypes.DomeFront:
                    dome = true;
                    break;
                case RenderTypes.DomeBack:
                    lookAtAdjust.Multiply(Matrix3d.RotationY(Math.PI));
                    dome = true;
                    break;
                default:
                    break;
            }
            WorldMatrix = Matrix3d.Identity;
            RenderContext11.World = WorldMatrix;
            RenderContext11.WorldBase = RenderContext11.World;

            if (config.MultiChannelDome1)
            {
                Matrix3d matHeadingPitchRoll =
                    Matrix3d.RotationZ((config.Roll / 180 * Math.PI)) *
                    Matrix3d.RotationY((config.Heading / 180 * Math.PI)) *
                    Matrix3d.RotationX(((config.Pitch) / 180 * Math.PI));

                RenderContext11.View = trackingMatrix * Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * DomeMatrix * matHeadingPitchRoll;
            }
            else
            {
                if (Settings.DomeView)
                {
                    RenderContext11.View = trackingMatrix * Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * DomeMatrix * lookAtAdjust;

                }
                else
                {
                    if (DomePreviewPopup.Active && !dome)
                    {
                        Matrix3d matDomePreview =
                             Matrix3d.RotationY((DomePreviewPopup.Az / 180 * Math.PI)) *
                             Matrix3d.RotationX((DomePreviewPopup.Alt / 180 * Math.PI));
                        RenderContext11.View = trackingMatrix * Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * DomeMatrix * matDomePreview;
                    }
                    else if (rift || renderType == RenderTypes.RightEye || renderType == RenderTypes.LeftEye)
                    {
                        double amount = cameraDistance / 100;
                        Matrix3d stereoTranslate = Matrix3d.Translation(renderType == RenderTypes.LeftEye ? amount : -amount, 0, 0);
                        Matrix3d matRiftView = Matrix3d.Identity;
                        if (rift)
                        {
                            matRiftView = Matrix3d.RotationY(GetHeading()) * Matrix3d.RotationX(GetPitch()) * Matrix3d.RotationZ(-GetRoll());
                        }

                        RenderContext11.View = trackingMatrix * Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * lookAtAdjust * matRiftView * stereoTranslate;
                    }
                    else
                    {
                        RenderContext11.View = trackingMatrix * Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * lookAtAdjust;
                    }

                    if (multiMonClient)
                    {
                        RenderContext11.View = RenderContext11.View * Matrix3d.RotationY((config.Heading / 180 * Math.PI));
                    }

                }
            }

            RenderContext11.ViewBase = RenderContext11.View;


            Vector3d temp = lookAt - RenderContext11.CameraPosition;
            temp.Normalize();
            temp = Vector3d.TransformCoordinate(temp, trackingMatrix);
            temp.Normalize();
            ViewPoint = temp;



            if (activeTrackingFrame)
            {
                Vector3d atfCamPos = RenderContext11.CameraPosition;
                Vector3d atfLookAt = lookAt;
                Vector3d atfLookUp = lookUp;
                Matrix3d mat = trackingMatrix;
                mat.Invert();

                atfCamPos.TransformCoordinate(mat);
                atfLookAt.TransformCoordinate(mat);
                atfLookUp.TransformCoordinate(mat);
                atfLookAt.Normalize();
                atfLookUp.Normalize();

                CustomTrackingParams.Angle = 0;
                CustomTrackingParams.Rotation = 0;
                CustomTrackingParams.DomeAlt = viewCamera.DomeAlt;
                CustomTrackingParams.DomeAz = viewCamera.DomeAz;
                CustomTrackingParams.TargetReferenceFrame = "";
                CustomTrackingParams.ViewTarget = viewCamera.ViewTarget;
                CustomTrackingParams.Zoom = viewCamera.Zoom;
                CustomTrackingParams.Target = SolarSystemObjects.Custom;


                Vector3d atfLook = atfCamPos - atfLookAt;
                atfLook.Normalize();



                Coordinates latlng = Coordinates.CartesianToSpherical2(atfLook);
                CustomTrackingParams.Lat = latlng.Lat;
                CustomTrackingParams.Lng = latlng.Lng - 90;

                Vector3d up = Coordinates.GeoTo3dDouble(latlng.Lat + 90, latlng.Lng - 90);
                Vector3d left = Vector3d.Cross(atfLook, up);

                double dotU = Math.Acos(Vector3d.Dot(atfLookUp, up));
                double dotL = Math.Acos(Vector3d.Dot(atfLookUp, left));

                CustomTrackingParams.Rotation = dotU;// -Math.PI / 2;
            }


            double radius = Planets.GetAdjustedPlanetRadius((int)SolarSystemTrack);


            if (cameraDistance < radius * 2.0 && !forStars)
            {
                m_nearPlane = cameraDistance * 0.03;

                m_nearPlane = Math.Max(m_nearPlane, .00000000001);
                back = 1900;
            }
            else
            {
                if (forStars)
                {
                    back = 900056;
                    back = cameraDistance > 900056 ? cameraDistance * 3 : 900056;
                    m_nearPlane = .00003f;

                }
                else
                {
                    back = cameraDistance > 1900 ? cameraDistance + 200 : 1900;

                    if (Settings.Active.SolarSystemScale < 13)
                    {
                        m_nearPlane = (float)Math.Min(cameraDistance * 0.03, 0.01);
                    }
                    else
                    {
                        m_nearPlane = .001f;
                    }
                }
            }
            if (config.MultiChannelDome1)
            {
                double aspect = config.Aspect;
                double top = m_nearPlane * 2 / ((1 / Math.Tan(config.UpFov / 180 * Math.PI))) / 2;
                double bottom = m_nearPlane * 2 / -(1 / Math.Tan(config.DownFov / 180 * Math.PI)) / 2;
                double right = m_nearPlane * 2 / (1 / Math.Tan((config.UpFov + config.DownFov) / 2 / 180 * Math.PI)) * aspect / 2;
                double left = -right;

                ProjMatrix = Matrix3d.PerspectiveOffCenterLH(
                    left,
                    right,
                    bottom,
                    top,
                    m_nearPlane,
                    back);
            }
            else if (config.MultiProjector)
            {

                RenderContext11.View = RenderContext11.View * config.ViewMatrix;

                ProjMatrix = Matrix3d.PerspectiveFovLH((75f / 180f) * Math.PI, 1.777778, m_nearPlane, back);

                RenderContext11.ViewBase = RenderContext11.View;
            }
            else if (multiMonClient && !dome)
            {
                double fov = (((config.UpFov + config.DownFov) / 2 / 180 * Math.PI));
                if (fov == 0)
                {
                    fov = (Math.PI / 4.0);
                }
                ProjMatrix = Matrix3d.PerspectiveFovLH((Math.PI / 4.0), (double)(monitorWidth * MonitorCountX) / ((double)monitorHeight * (double)MonitorCountY), m_nearPlane, back);
            }
            else if (dome)
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH((Math.PI / 2.0), 1.0f, m_nearPlane, back);
            }
            else if (rift)
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH(riftFov, (double)ViewWidth / (double)renderWindow.ClientRectangle.Height, m_nearPlane, back);
                RenderContext11.PerspectiveFov = riftFov;

            }
            else
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH((fovLocal), (double)ViewWidth / (double)renderWindow.ClientRectangle.Height, m_nearPlane, back);
                RenderContext11.PerspectiveFov = fovLocal;
            }

            if (multiMonClient && !config.MultiChannelDome1 && !config.MultiProjector)
            {
                ProjMatrix.M11 *= MonitorCountX * bezelSpacing;
                ProjMatrix.M22 *= MonitorCountY * bezelSpacing;
                ProjMatrix.M31 = (MonitorCountX - 1) - (MonitorX * bezelSpacing * 2);
                ProjMatrix.M32 = -((MonitorCountY - 1) - (MonitorY * bezelSpacing * 2));
            }

            if (rift)
            {
                if (renderType == RenderTypes.LeftEye)
                {

                    ProjMatrix.M31 += iod;
                }
                else
                {
                    ProjMatrix.M31 -= iod;
                }
            }

            RenderContext11.Projection = ProjMatrix;

            ViewMatrix = RenderContext11.View;
            RenderContext11.ViewBase = RenderContext11.View;

            MakeFrustum();
        }
Esempio n. 19
0
        private void SetupMatricesLandDome(RenderTypes renderType)
        {
            FovAngle = 60;

            RenderContext11.LightingEnabled = false;

            double localZoom = ZoomFactor * 20;
            double distance = (4.0 * (ZoomFactor / 180)) + 0.000001;


            Vector3d lookAt = new Vector3d(0.0f, 0.0f, -targetHeight);

            if (Settings.Active.ShowElevationModel)
            {
                double heightNow = 1 + GetScaledAltitudeForLatLong(ViewLat, ViewLong);
                if (targetHeight < heightNow)
                {
                    targetHeight = (((targetHeight * 2) + heightNow) / 3);
                }
                else
                {
                    targetHeight = (((targetHeight * 9) + heightNow) / 10);
                }

            }
            else
            {
                targetHeight = 1;
            }

            double rotLocal = CameraRotate;

            if (renderType == RenderTypes.RightEye)
            {
                rotLocal -= .008;
            }
            if (renderType == RenderTypes.LeftEye)
            {
                rotLocal += .008;
            }

            RenderContext11.CameraPosition = new Vector3d(
                (Math.Sin(rotLocal) * Math.Sin(CameraAngle) * distance),
                (Math.Cos(rotLocal) * Math.Sin(CameraAngle) * distance),
                (-targetHeight - (Math.Cos(CameraAngle) * distance)));

            Matrix3d lookAtAdjust = Matrix3d.Identity;

            Vector3d lookUp = new Vector3d(Math.Sin(rotLocal) * Math.Cos(CameraAngle), Math.Cos(rotLocal) * Math.Cos(CameraAngle), Math.Sin(CameraAngle));

            Matrix3d cubeMat = Matrix3d.Identity;

            switch (renderType)
            {
                case RenderTypes.DomeUp:
                    cubeMat = Matrix3d.RotationX((Math.PI / 2));
                    break;
                case RenderTypes.DomeLeft:
                    cubeMat = Matrix3d.RotationY((Math.PI / 2));
                    break;
                case RenderTypes.DomeRight:
                    cubeMat = Matrix3d.RotationY(-(Math.PI / 2));
                    break;
                case RenderTypes.DomeFront:
                    break;
                case RenderTypes.DomeBack:
                    cubeMat = Matrix3d.RotationY((Math.PI));
                    break;
                default:
                    break;
            }
            double camHeight = RenderContext11.CameraPosition.Length();

            if (CurrentImageSet.Projection == ProjectionType.Toast && (CurrentImageSet.MeanRadius > 0 && CurrentImageSet.MeanRadius < 4000000))
            {
                int val = (int)Math.Max(0, Math.Min(255, 255 - Math.Min(255, (camHeight - 1) * 5000)));
                SkyColor = Color.FromArgb(213 * val / 255, 165 * val / 255, 118 * val / 255);
            }
            else if (CurrentImageSet.DataSetType == ImageSetType.Earth && Settings.Active.ShowEarthSky)
            {
                int val = (int)Math.Max(0, Math.Min(255, 255 - Math.Min(255, (camHeight - 1) * 5000)));
                SkyColor = Color.FromArgb(255, val / 3, val / 3, val);
            }
            else
            {
                SkyColor = Color.Black;
            }

            WorldMatrix = Matrix3d.RotationY(((this.ViewLong + 90f) / 180f * Math.PI));
            WorldMatrix.Multiply(Matrix3d.RotationX(((-this.ViewLat) / 180f * Math.PI)));
            RenderContext11.World = WorldMatrix;
            RenderContext11.WorldBase = WorldMatrix;

            if (config.MultiChannelDome1)
            {
                Matrix3d matHeadingPitchRoll =
                    Matrix3d.RotationZ((config.Roll / 180 * Math.PI)) *
                    Matrix3d.RotationX((config.Pitch / 180 * Math.PI)) *
                    Matrix3d.RotationY((config.Heading / 180 * Math.PI));

                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp)
                    * DomeMatrix
                    * matHeadingPitchRoll;
            }
            else
            {
                RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, lookAt, lookUp) * DomeMatrix * cubeMat;
            }

            Vector3d temp = lookAt - RenderContext11.CameraPosition;
            temp.Normalize();
            ViewPoint = temp;


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


            ProjMatrix = Matrix3d.PerspectiveFovLH((Math.PI / 2.0), 1.0f, m_nearPlane, back);
            if (config.MultiChannelDome1)
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH(((config.UpFov + config.DownFov) / 180 * Math.PI), (double)ViewWidth / (double)renderWindow.ClientRectangle.Height, m_nearPlane, back);
            }

            else if (multiMonClient)
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH((Math.PI / 2.0), 1.0f, m_nearPlane, back);
                RenderContext11.PerspectiveFov = (Math.PI / 2.0);
            }

            RenderContext11.Projection = ProjMatrix;


            ViewMatrix = RenderContext11.View;
            RenderContext11.ViewBase = RenderContext11.View;

            MakeFrustum();
        }
Esempio n. 20
0
        private void SetupMatricesLand11(RenderTypes renderType)
        {
            WorldMatrix = Matrix3d.RotationY(((this.ViewLong + 90f) / 180f * Math.PI));
            WorldMatrix.Multiply(Matrix3d.RotationX(((-this.ViewLat) / 180f * Math.PI)));
            RenderContext11.World = WorldMatrix;
            RenderContext11.WorldBase = WorldMatrix;


            double distance = 0;
            if (CurrentImageSet.IsMandelbrot)
            {

                distance = (4.0 * (ZoomFactor / 180)) + 0.00000000000000000000000000000000000000001;
            }
            else
            {

                distance = (4.0 * (ZoomFactor / 180)) + 0.000001;
            }

            if (Settings.Active.ShowElevationModel)
            {
                targetAltitude = GetScaledAltitudeForLatLong(ViewLat, ViewLong);
                double heightNow = 1 + targetAltitude;
                targetAltitude *= RenderContext11.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;
                }
                if (config.MultiChannelDome1 || config.MultiProjector)
                {
                    targetHeight = heightNow = NetControl.focusAltitude;
                }

            }
            else
            {
                targetAltitude = 0;
                targetHeight = 1;
            }
            double rotLocal = CameraRotate;
            if (!rift)
            {
                if (renderType == RenderTypes.RightEye)
                {
                    rotLocal -= .008;
                }
                if (renderType == RenderTypes.LeftEye)
                {
                    rotLocal += .008;
                }
            }

            RenderContext11.CameraPosition = new Vector3d(
                (Math.Sin(rotLocal) * Math.Sin(CameraAngle) * distance),
                (Math.Cos(rotLocal) * Math.Sin(CameraAngle) * distance),
                (-targetHeight - (Math.Cos(CameraAngle) * distance)));
            cameraTarget = new Vector3d(0.0f, 0.0f, -targetHeight);

            double camHeight = RenderContext11.CameraPosition.Length();
            if (Tile.GrayscaleStyle)
            {
                if (CurrentImageSet.Projection == ProjectionType.Toast && (CurrentImageSet.MeanRadius > 0 && CurrentImageSet.MeanRadius < 4000000))
                {
                    int val = (int)Math.Max(0, Math.Min(255, 255 - Math.Min(255, (camHeight - 1) * 5000)));
                    SkyColor = Color.FromArgb(213 * val / 255, 165 * val / 255, 118 * val / 255);
                }
                else if (CurrentImageSet.DataSetType == ImageSetType.Earth)
                {
                    SkyColor = Color.FromArgb(255, 184, 184, 184);
                }
                else
                {
                    SkyColor = Color.Black;
                }
            }
            else
            {
                if (CurrentImageSet.ReferenceFrame == "Mars" && Settings.Active.ShowEarthSky)
                {
                    int val = (int)Math.Max(0, Math.Min(255, 255 - Math.Min(255, (camHeight - 1) * 5000)));
                    SkyColor = Color.FromArgb(213 * val / 255, 165 * val / 255, 118 * val / 255);
                }
                else if (CurrentImageSet.DataSetType == ImageSetType.Earth && Settings.Active.ShowEarthSky)
                {
                    int val = (int)Math.Max(0, Math.Min(255, 255 - Math.Min(255, (camHeight - 1) * 5000)));
                    SkyColor = Color.FromArgb(255, val / 3, val / 3, val);
                }
                else
                {
                    SkyColor = Color.Black;
                }
            }
 
            if (config.MultiChannelGlobe)
            {
                // Move the camera to some fixed distance from the globe
                RenderContext11.CameraPosition *= 50.0 / RenderContext11.CameraPosition.Length();

                // Modify camera position in globe mode
                Matrix3d globeCameraRotation =
                    Matrix3d.RotationZ((config.Roll / 180 * Math.PI)) *
                    Matrix3d.RotationY((config.Heading / 180 * Math.PI)) *
                    Matrix3d.RotationX(((config.Pitch) / 180 * Math.PI));
                RenderContext11.CameraPosition = globeCameraRotation.Transform(RenderContext11.CameraPosition);
                cameraTarget = globeCameraRotation.Transform(cameraTarget);
                RenderContext11.View = Matrix3d.LookAtLH(
                    RenderContext11.CameraPosition,
                    cameraTarget,
                    new Vector3d(Math.Sin(rotLocal) * Math.Cos(CameraAngle), Math.Cos(rotLocal) * Math.Cos(CameraAngle), Math.Sin(CameraAngle)));
            }
            else if (config.MultiChannelDome1)
            {
                Matrix3d matHeadingPitchRoll =
                    Matrix3d.RotationZ((config.Roll / 180 * Math.PI)) *
                    Matrix3d.RotationY((config.Heading / 180 * Math.PI)) *
                    Matrix3d.RotationX(((config.Pitch) / 180 * Math.PI));
                RenderContext11.View = Matrix3d.LookAtLH(
                            RenderContext11.CameraPosition,
                            cameraTarget,
                            new Vector3d(Math.Sin(rotLocal) * Math.Cos(CameraAngle), Math.Cos(rotLocal) * Math.Cos(CameraAngle), Math.Sin(CameraAngle)))
                            * DomeMatrix
                            * matHeadingPitchRoll;
                RenderContext11.ViewBase = RenderContext11.View;
            }
            else
            {

                Vector3d lookUp = new Vector3d(Math.Sin(rotLocal) * Math.Cos(CameraAngle), Math.Cos(rotLocal) * Math.Cos(CameraAngle), Math.Sin(CameraAngle));

                if (DomePreviewPopup.Active)
                {
                    Matrix3d matDomePreview =
                         Matrix3d.RotationY((DomePreviewPopup.Az / 180 * Math.PI)) *
                         Matrix3d.RotationX((DomePreviewPopup.Alt / 180 * Math.PI));
                    RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, cameraTarget, lookUp) * Matrix3d.RotationX(((-config.TotalDomeTilt) / 180 * Math.PI)) * matDomePreview;
                }
                else if (rift)
                {
                    double amount = distance / 100;
                    Matrix3d stereoTranslate = Matrix3d.Translation(renderType == RenderTypes.LeftEye ? amount : -amount, 0, 0);
                    Matrix3d matRiftView = Matrix3d.RotationY(GetHeading()) * Matrix3d.RotationX(GetPitch()) * Matrix3d.RotationZ(-GetRoll());
                    RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, cameraTarget, lookUp) * Matrix3d.Translation(HeadPosition) * matRiftView * stereoTranslate;
                }
                else
                {
                    RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, cameraTarget, lookUp) * Matrix3d.Translation(HeadPosition);

                }

                if (multiMonClient)
                {
                    RenderContext11.View = RenderContext11.View * Matrix3d.RotationY((config.Heading / 180 * Math.PI));
                }


                RenderContext11.ViewBase = RenderContext11.View;


            }

            back = Math.Sqrt((distance + 1f) * (distance + 1f) - 1);
            back = Math.Max(.5, back);

            if (Properties.Settings.Default.EarthCutawayView.State)
            {
                back = 20;
            }
            m_nearPlane = distance * .05f;
            if (config.MultiChannelGlobe)
            {
                m_nearPlane = RenderContext11.CameraPosition.Length() - 2.0;
                back = m_nearPlane + 4.0;
                ProjMatrix = Matrix3d.OrthoLH(config.Aspect * 2.0, 2.0, m_nearPlane, back);
            }
            else if (config.MultiChannelDome1)
            {
                double aspect = config.Aspect;
                double top = m_nearPlane * 2 / ((1 / Math.Tan(config.UpFov / 180 * Math.PI))) / 2;
                double bottom = m_nearPlane * 2 / -(1 / Math.Tan(config.DownFov / 180 * Math.PI)) / 2;
                double right = m_nearPlane * 2 / (1 / Math.Tan((config.UpFov + config.DownFov) / 2 / 180 * Math.PI)) * aspect / 2;
                double left = -right;

                ProjMatrix = Matrix3d.PerspectiveOffCenterLH(
                    left,
                    right,
                    bottom,
                    top,
                    m_nearPlane,
                    back);


            }
            else if (config.MultiProjector)
            {
                RenderContext11.View = RenderContext11.View * config.ViewMatrix;
                ProjMatrix = Matrix3d.PerspectiveFovLH((75f / 180f) * Math.PI, 1.777778, m_nearPlane, back);
                RenderContext11.ViewBase = RenderContext11.View;

            }
            else if (multiMonClient)
            {
                double fov = (((config.UpFov + config.DownFov) / 2 / 180 * Math.PI));
                if (fov == 0)
                {
                    fov = (Math.PI / 4.0);
                }

                m_nearPlane = distance * .05f;
                ProjMatrix = Matrix3d.PerspectiveFovLH(fov, (monitorWidth * MonitorCountX) / (monitorHeight * MonitorCountY), m_nearPlane, back);
            }
            else if (rift)
            {
                m_nearPlane = distance * .05f;
                ProjMatrix = Matrix3d.PerspectiveFovLH(riftFov, (double)ViewWidth / (double)renderWindow.ClientRectangle.Height, m_nearPlane, back);
                RenderContext11.PerspectiveFov = riftFov;

            }
            else
            {

                m_nearPlane = distance * .05f;
                ProjMatrix = Matrix3d.PerspectiveFovLH(fovLocal, (double)ViewWidth / (double)renderWindow.ClientRectangle.Height, m_nearPlane, back);
                RenderContext11.PerspectiveFov = fovLocal;
            }


            if (multiMonClient && !config.MultiChannelDome1 && !Config.MultiProjector && !Config.MultiChannelGlobe)
            {
                ProjMatrix.M11 *= MonitorCountX * bezelSpacing;
                ProjMatrix.M22 *= MonitorCountY * bezelSpacing;
                ProjMatrix.M31 = (MonitorCountX - 1) - (MonitorX * bezelSpacing * 2);
                ProjMatrix.M32 = -((MonitorCountY - 1) - (MonitorY * bezelSpacing * 2));
            }

            if (rift)
            {
                if (renderType == RenderTypes.LeftEye)
                {

                    ProjMatrix.M31 += iod;
                }
                else
                {
                    ProjMatrix.M31 -= iod;
                }
            }


            RenderContext11.Projection = ProjMatrix;

            colorBlend = 1 / distance;

            ViewMatrix = RenderContext11.View;


            MakeFrustum();
        }
        public static void Render(Mesh meshToRender, IColorType partColor, Matrix4X4 transform, RenderTypes renderType)
        {
            if (meshToRender != null)
            {
                GL.Color4(partColor.Red0To255, partColor.Green0To255, partColor.Blue0To255, partColor.Alpha0To255);

                if (partColor.Alpha0To1 < 1)
                {
                    GL.Enable(EnableCap.Blend);
                }
                else
                {
                    GL.Disable(EnableCap.Blend);
                }

                GL.MatrixMode(MatrixMode.Modelview);
                GL.PushMatrix();
                GL.MultMatrix(transform.GetAsFloatArray());

                switch (renderType)
                {
                case RenderTypes.Hidden:
                    break;

                case RenderTypes.Shaded:
                    DrawToGL(meshToRender);
                    break;

                case RenderTypes.Polygons:
                case RenderTypes.Outlines:
                    DrawWithWireOverlay(meshToRender, renderType);
                    break;
                }

                GL.PopMatrix();
            }
        }
Esempio n. 22
0
		private static void DrawWithWireOverlay(Mesh meshToRender, RenderTypes renderType)
		{
			GLMeshTrianglePlugin glMeshPlugin = GLMeshTrianglePlugin.Get(meshToRender);

			GL.Enable(EnableCap.PolygonOffsetFill);
			GL.PolygonOffset(1, 1);

			DrawToGL(meshToRender);

			GL.Color4(0, 0, 0, 255);

			GL.PolygonOffset(0, 0);
			GL.Disable(EnableCap.PolygonOffsetFill);
			GL.Disable(EnableCap.Lighting);

			GL.DisableClientState(ArrayCap.TextureCoordArray);
			GLMeshWirePlugin glWireMeshPlugin = null;
			if (renderType == RenderTypes.Outlines)
			{
				glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender, MathHelper.Tau / 8);
			}
			else
			{
				glWireMeshPlugin = GLMeshWirePlugin.Get(meshToRender);
			}

			VectorPOD<WireVertexData> edegLines = glWireMeshPlugin.edgeLinesData;
			GL.EnableClientState(ArrayCap.VertexArray);

#if true
			unsafe
			{
				fixed (WireVertexData* pv = edegLines.Array)
				{
					GL.VertexPointer(3, VertexPointerType.Float, 0, new IntPtr(pv));
					GL.DrawArrays(BeginMode.Lines, 0, edegLines.Count);
				}
			}
#else
            GL.InterleavedArrays(InterleavedArrayFormat.V3f, 0, edegLines.Array);
            GL.DrawArrays(BeginMode.Lines, 0, edegLines.Count);
#endif

			GL.DisableClientState(ArrayCap.VertexArray);
			GL.Enable(EnableCap.Lighting);
		}
Esempio n. 23
0
 public static void Render(Mesh meshToRender, Color partColor, RenderTypes renderType = RenderTypes.Shaded, Matrix4X4?meshToViewTransform = null, Color wireFrameColor = default(Color), Action meshChanged = null)
 {
     Render(meshToRender, partColor, Matrix4X4.Identity, renderType, meshToViewTransform, wireFrameColor, meshChanged);
 }
Esempio n. 24
0
		public static void Render(Mesh meshToRender, IColorType partColor, Matrix4X4 transform, RenderTypes renderType)
		{
			if (meshToRender != null)
			{
				GL.Color4(partColor.Red0To255, partColor.Green0To255, partColor.Blue0To255, partColor.Alpha0To255);

				if (partColor.Alpha0To1 < 1)
				{
					GL.Enable(EnableCap.Blend);
				}
				else
				{
					GL.Disable(EnableCap.Blend);
				}

				GL.MatrixMode(MatrixMode.Modelview);
				GL.PushMatrix();
				GL.MultMatrix(transform.GetAsFloatArray());

				switch (renderType)
				{
					case RenderTypes.Hidden:
						break;

					case RenderTypes.Shaded:
						DrawToGL(meshToRender);
						break;

					case RenderTypes.Polygons:
					case RenderTypes.Outlines:
						DrawWithWireOverlay(meshToRender, renderType);
						break;
				}

				GL.PopMatrix();
			}
		}
Esempio n. 25
0
        public static void Render(Mesh meshToRender, Color color, Matrix4X4 transform, RenderTypes renderType, Matrix4X4?meshToViewTransform = null, Color wireFrameColor = default(Color), Action meshChanged = null)
        {
            if (meshToRender != null)
            {
                GL.Enable(EnableCap.CullFace);

                GL.Color4(color.Red0To255, color.Green0To255, color.Blue0To255, color.Alpha0To255);

                if (color.Alpha0To1 < 1)
                {
                    GL.Enable(EnableCap.Blend);
                }
                else
                {
                    GL.Disable(EnableCap.Blend);
                }

                GL.MatrixMode(MatrixMode.Modelview);
                GL.PushMatrix();
                GL.MultMatrix(transform.GetAsFloatArray());

                switch (renderType)
                {
                case RenderTypes.Hidden:
                    break;

                case RenderTypes.Polygons:
                case RenderTypes.Outlines:
                    if (color.Alpha0To255 > 0)
                    {
                        GL.Enable(EnableCap.PolygonOffsetFill);
                        GL.PolygonOffset(1, 1);
                        DrawToGL(meshToRender, color.Alpha0To1 < 1, meshToViewTransform);
                        GL.PolygonOffset(0, 0);
                        GL.Disable(EnableCap.PolygonOffsetFill);
                    }

                    DrawWireOverlay(meshToRender, renderType, wireFrameColor, meshChanged);
                    break;

                case RenderTypes.Wireframe:
                    DrawWireOverlay(meshToRender, renderType, wireFrameColor);
                    break;

                case RenderTypes.Overhang:
                    OverhangRender.EnsureUpdated(meshToRender, transform);
                    DrawToGL(meshToRender, color.Alpha0To1 < 1, meshToViewTransform);
                    break;

                case RenderTypes.Shaded:
                case RenderTypes.Materials:
                    DrawToGL(meshToRender, color.Alpha0To1 < 1, meshToViewTransform);
                    break;
                }

                GL.PopMatrix();
            }
        }
Esempio n. 26
0
        public static void Render(Mesh meshToRender,
                                  Color color,
                                  Matrix4X4 transform,
                                  RenderTypes renderType        = RenderTypes.Shaded,
                                  Matrix4X4?meshToViewTransform = null,
                                  Color wireFrameColor          = default(Color),
                                  Action meshChanged            = null,
                                  bool blendTexture             = true,
                                  bool allowBspRendering        = true,
                                  bool forceCullBackFaces       = true)
        {
            if (meshToRender != null)
            {
                GL.Color4(color.Red0To255, color.Green0To255, color.Blue0To255, color.Alpha0To255);

                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

                if (color.Alpha0To1 < 1)
                {
                    if (forceCullBackFaces)
                    {
                        GL.Enable(EnableCap.CullFace);
                    }
                    else
                    {
                        // by default render back faces of transparent objects
                        GL.Disable(EnableCap.CullFace);
                    }
                    GL.Enable(EnableCap.Blend);
                }
                else
                {
                    GL.Enable(EnableCap.CullFace);
                    GL.Enable(EnableCap.Blend);
                }

                GL.MatrixMode(MatrixMode.Modelview);
                GL.PushMatrix();
                GL.MultMatrix(transform.GetAsFloatArray());

                switch (renderType)
                {
                case RenderTypes.Hidden:
                    break;

                case RenderTypes.Polygons:
                case RenderTypes.Outlines:
                case RenderTypes.NonManifold:
                    if (color.Alpha0To255 > 0)
                    {
                        GL.Enable(EnableCap.PolygonOffsetFill);
                        GL.PolygonOffset(1, 1);
                        DrawToGL(meshToRender, color.Alpha0To1 < 1, meshToViewTransform, allowBspRendering: allowBspRendering);
                        GL.PolygonOffset(0, 0);
                        GL.Disable(EnableCap.PolygonOffsetFill);
                    }

                    DrawWireOverlay(meshToRender, renderType, wireFrameColor, meshChanged);
                    break;

                case RenderTypes.Wireframe:
                    DrawWireOverlay(meshToRender, renderType, wireFrameColor);
                    break;

                case RenderTypes.Overhang:
                    OverhangRender.EnsureUpdated(meshToRender, transform);
                    DrawToGL(meshToRender, color.Alpha0To1 < 1, meshToViewTransform);
                    break;

                case RenderTypes.Shaded:
                case RenderTypes.Materials:
                    DrawToGL(meshToRender, color.Alpha0To1 < 1, meshToViewTransform, blendTexture, allowBspRendering);
                    break;
                }

                GL.PopMatrix();
            }
        }
        /// <summary>
        /// 表示场景切换的动画效果方案
        /// </summary>
        /// <remarks>当切换风格为Color时需要设置FromColor和ToColor的值</remarks>
        public struct SwitchResolution
        {
            #region Fields

            public uint FromColor;
            public SwitchStyles SwitchStyle;
Esempio n. 28
0
        public static IRenderer Create(FinishTypes finishTypes, RenderTypes type, object element)
        {
            switch (finishTypes)
            {
            case FinishTypes.DocumentHtmlFinish:

                if (element is Document documentHtmlFinish)
                {
                    var renderer = new DocumentFinishRenderer(documentHtmlFinish);
                    return(renderer);
                }
                else
                {
                    throw new InvalidCastException("Invalid element type");
                }

            case FinishTypes.Hyperlink:

                if (element is Hyperlink hyperlink)
                {
                    IRenderer renderer = null;

                    switch (type)
                    {
                    case RenderTypes.Text:
                        renderer = new HyperlinkTextFinishRenderer(hyperlink);
                        return(renderer);

                    case RenderTypes.Html:
                        renderer = new HyperlinkHtmlFinishRenderer(hyperlink);
                        return(renderer);

                    default:
                        throw new NotSupportedException("Not suportet Render Type");
                    }
                }
                else
                {
                    throw new InvalidCastException("Invalid element type");
                }

            case FinishTypes.Paragraph:
                if (element is Paragraph paragraph)
                {
                    IRenderer renderer = null;

                    switch (type)
                    {
                    case RenderTypes.Text:
                        renderer = new ParagraphTextFinish(paragraph);
                        return(renderer);

                    case RenderTypes.Html:
                        renderer = new ParagraphHtmlFinish(paragraph);
                        return(renderer);

                    default:
                        throw new NotSupportedException("Not suportet Render Type");
                    }
                }
                else
                {
                    throw new InvalidCastException("Invalid element type");
                }

            default:
                throw new NotSupportedException("Not suportet Element Type");
            }
        }
Esempio n. 29
0
        private void SetupMatricesSpace11(double localZoomFactor, RenderTypes renderType)
        {
            if (config.MultiChannelDome1 || config.MultiProjector || DomePreviewPopup.Active || rift)
            {
                SetupMatricesSpaceMultiChannel(localZoomFactor, renderType);
                return;
            }

            if ((Settings.Active.GalacticMode && !Settings.Active.LocalHorizonMode) && CurrentImageSet.DataSetType == ImageSetType.Sky)
            {
                // Show in galactic coordinates
                if (!galMatInit)
                {
                    galacticMatrix = Matrix3d.Identity;
                    galacticMatrix.Multiply(Matrix3d.RotationY(-(90 - (17.7603329867975 * 15)) / 180.0 * Math.PI));
                    galacticMatrix.Multiply(Matrix3d.RotationX(-((-28.9361739586894)) / 180.0 * Math.PI));
                    galacticMatrix.Multiply(Matrix3d.RotationZ(((31.422052860102041270114993238783) - 90) / 180.0 * Math.PI));
                    galMatInit = true;
                }

                WorldMatrix = galacticMatrix;
                WorldMatrix.Multiply(Matrix3d.RotationY(((az)) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(-((alt)) / 180.0 * Math.PI));


                double[] gPoint = Coordinates.GalactictoJ2000(az, alt);

                this.RA = gPoint[0] / 15;
                this.Dec = gPoint[1];
                viewCamera.Lat = targetViewCamera.Lat;
                viewCamera.Lng = targetViewCamera.Lng;

            }
            else
            {
                // Show in Ecliptic

                WorldMatrix = Matrix3d.RotationY(-((this.ViewLong + 90.0) / 180.0 * Math.PI));
                WorldMatrix.Multiply(Matrix3d.RotationX(((-this.ViewLat) / 180.0 * Math.PI)));
            }
            double camLocal = CameraRotate;

            // altaz
            if ((Settings.Active.LocalHorizonMode && !Settings.Active.GalacticMode) && CurrentImageSet.DataSetType == ImageSetType.Sky)
            {
                Coordinates zenithAltAz = new Coordinates(0, 0);

                zenithAltAz.Az = 0;

                zenithAltAz.Alt = 0;



                if (!config.Master)
                {
                    alt = 0;
                    az = 0;
                    config.DomeTilt = 0;
                    if (Properties.Settings.Default.DomeTilt != 0)
                    {
                        Properties.Settings.Default.DomeTilt = 0;
                    }
                }

                Coordinates zenith = Coordinates.HorizonToEquitorial(zenithAltAz, SpaceTimeController.Location, SpaceTimeController.Now);

                double raPart = -((zenith.RA - 6) / 24.0 * (Math.PI * 2));
                double decPart = -(((zenith.Dec)) / 360.0 * (Math.PI * 2));
                string raText = Coordinates.FormatDMS(zenith.RA);
                WorldMatrix = Matrix3d.RotationY(-raPart);
                WorldMatrix.Multiply(Matrix3d.RotationX(decPart));

                if (SpaceTimeController.Location.Lat < 0)
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((alt) / 180.0 * Math.PI)));
                    camLocal += Math.PI;
                }
                else
                {
                    WorldMatrix.Multiply(Matrix3d.RotationY(((-az) / 180.0 * Math.PI)));

                    WorldMatrix.Multiply(Matrix3d.RotationX(((-alt) / 180.0 * Math.PI)));
                }

                Coordinates currentRaDec = Coordinates.HorizonToEquitorial(Coordinates.FromLatLng(alt, az), SpaceTimeController.Location, SpaceTimeController.Now);

                TargetLat = ViewLat = currentRaDec.Dec;
                TargetLong = ViewLong = RAtoViewLng(currentRaDec.RA);
            }

            RenderContext11.World = WorldMatrix;
            RenderContext11.WorldBase = WorldMatrix;
            // altaz

            ViewPoint = Coordinates.RADecTo3d(this.RA, -this.Dec, 1.0);



            double distance = (4.0 * (localZoomFactor / 180)) + 0.000001;

            FovAngle = ((localZoomFactor/**16*/) / FOVMULT) / Math.PI * 180;
            RenderContext11.CameraPosition = new Vector3d(0.0, 0.0, 0.0);
            // This is for distance Calculation. For space everything is the same distance, so camera target is key.

            RenderContext11.View = Matrix3d.LookAtLH(RenderContext11.CameraPosition, new Vector3d(0.0, 0.0, -1.0), new Vector3d(Math.Sin(camLocal), Math.Cos(camLocal), 0.0));

            if (config.MultiChannelGlobe)
            {
                Matrix3d globeCameraRotation =
                    Matrix3d.RotationZ((config.Roll / 180 * Math.PI)) *
                    Matrix3d.RotationY((config.Heading / 180 * Math.PI)) *
                    Matrix3d.RotationX(((config.Pitch) / 180 * Math.PI));
                RenderContext11.View = RenderContext11.View * globeCameraRotation;
            }



            if (multiMonClient)
            {
                RenderContext11.View = RenderContext11.View * Matrix3d.RotationY((config.Heading / 180 * Math.PI));
            }


            RenderContext11.ViewBase = RenderContext11.View;

            m_nearPlane = 0f;
            if (multiMonClient)
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH((localZoomFactor/**16*/) / FOVMULT, (double)(monitorWidth * MonitorCountX) / (double)(monitorHeight * MonitorCountY), .1, -2.0);

            }
            else
            {
                ProjMatrix = Matrix3d.PerspectiveFovLH((localZoomFactor/**16*/) / FOVMULT, (double)ViewWidth / (double)renderWindow.ClientRectangle.Height, .1, -2.0);

            }
            RenderContext11.PerspectiveFov = (localZoomFactor) / FOVMULT;


            if (multiMonClient)
            {
                ProjMatrix.M11 *= MonitorCountX * bezelSpacing;
                ProjMatrix.M22 *= MonitorCountY * bezelSpacing;
                ProjMatrix.M31 = (MonitorCountX - 1) - (MonitorX * bezelSpacing * 2);
                ProjMatrix.M32 = -((MonitorCountY - 1) - (MonitorY * bezelSpacing * 2));
            }

            if (config.MultiChannelGlobe)
            {
                ProjMatrix = Matrix3d.OrthoLH(config.Aspect * 2.0, 2.0, 0.0, 2.0);
            }



            RenderContext11.Projection = ProjMatrix;

            ViewMatrix = RenderContext11.View;

            MakeFrustum();

        }