示例#1
0
        public static bool DrawAltAzGridText(RenderContext renderContext, float opacity, Color drawColor)
        {
            Coordinates zenithAltAz = new Coordinates(0, 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);
            Matrix3d mat     = Matrix3d.RotationY((float)-raPart - Math.PI);

            mat.Multiply(Matrix3d.RotationX((float)decPart));
            mat.Invert();

            MakeAltAzGridText();


            Matrix3d matOldWorld     = renderContext.World.Clone();
            Matrix3d matOldWorldBase = renderContext.WorldBase.Clone();

            renderContext.WorldBase = Matrix3d.MultiplyMatrix(mat, renderContext.World);
            renderContext.World     = renderContext.WorldBase.Clone();
            renderContext.MakeFrustum();

            AltAzTextBatch.ViewTransform = Matrix3d.InvertMatrix(mat);
            AltAzTextBatch.Draw(renderContext, opacity, drawColor);

            renderContext.WorldBase = matOldWorldBase;
            renderContext.World     = matOldWorld;
            renderContext.MakeFrustum();
            return(true);
        }
示例#2
0
 public override bool Draw(RenderContext renderContext, float opacity, bool flat)
 {
     if (!loaded)
     {
         return(false);
     }
     //if (!flat)
     //{
     //    renderContext.setRasterizerState(TriangleCullMode.CullClockwise);
     //}
     renderContext.WorldBase = renderContext.World;
     renderContext.ViewBase  = renderContext.View;
     renderContext.MakeFrustum();
     renderContext.DrawImageSet(imageSet, this.Opacity * opacity * 100);
     return(true);
 }
示例#3
0
        public static bool DrawAltAzGrid(RenderContext renderContext, float opacity, Color drawColor)
        {
            Coordinates zenithAltAz = new Coordinates(0, 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);
            Matrix3d mat     = Matrix3d.RotationY((float)-raPart);

            mat.Multiply(Matrix3d.RotationX((float)decPart));
            mat.Invert();

            if (altAzLineList == null)
            {
                altAzLineList = new SimpleLineList();
                altAzLineList.DepthBuffered = false;

                for (double l = 0; l < 360; l += 10)
                {
                    for (double b = -80; b < 80; b += 2)
                    {
                        altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15, b, 1), Coordinates.RADecTo3dAu(l / 15, b + 2, 1));
                    }
                }

                for (double b = -80; b <= 80; b += 10)
                {
                    for (double l = 0; l < 360; l += 5)
                    {
                        altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15, b, 1), Coordinates.RADecTo3dAu((l + 5) / 15, b, 1));
                    }
                }

                int counter = 0;
                for (double l = 0; l < 360; l += 1)
                {
                    double b = 0.25;
                    switch (counter % 10)
                    {
                    case 0:
                        counter++;
                        continue;

                    case 5:
                        b = .5;
                        break;
                    }
                    counter++;

                    altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15, b, 1), Coordinates.RADecTo3dAu(l / 15, -b, 1));
                }

                counter = 0;
                for (double l = 0; l < 360; l += 90)
                {
                    counter = 0;
                    for (double b = -80; b <= 80; b += 1)
                    {
                        double width = 0.5 / 2;
                        switch (counter % 10)
                        {
                        case 0:
                            counter++;
                            continue;

                        case 5:
                            width = .5;
                            break;
                        }
                        counter++;

                        altAzLineList.AddLine(Coordinates.RADecTo3dAu((l + width) / 15, b, 1), Coordinates.RADecTo3dAu((l - width) / 15, b, 1));
                    }
                }
            }

            Matrix3d matOldWorld     = renderContext.World.Clone();
            Matrix3d matOldWorldBase = renderContext.WorldBase.Clone();

            renderContext.WorldBase = Matrix3d.MultiplyMatrix(mat, renderContext.World);
            renderContext.World     = renderContext.WorldBase.Clone();
            renderContext.MakeFrustum();

            altAzLineList.ViewTransform = Matrix3d.InvertMatrix(mat);

            altAzLineList.DrawLines(renderContext, opacity, drawColor);

            renderContext.WorldBase = matOldWorldBase;
            renderContext.World     = matOldWorld;
            renderContext.MakeFrustum();
            return(true);
        }
示例#4
0
        //        private static Matrix bias = Matrix.Scaling(new Vector3(.5f, .5f, .5f)) * Matrix.Translation(new Vector3(.5f, .5f, .5f));
        private static void DrawPlanet3d(RenderContext renderContext, int planetID, Vector3d centerPoint)
        {
            if (planetID == (int)SolarSystemObjects.Sun)
            {
            //    device.RenderState.Lighting = false;
            }
            else
            {
             //   device.RenderState.Lighting = Settings.Active.SolarSystemLighting;
            }

            double radius = GetAdjustedPlanetRadius(planetID);

            double rotationCurrent = 0;
            if (planetID == (int)SolarSystemObjects.Earth)
            {
                rotationCurrent = Coordinates.MstFromUTC2(SpaceTimeController.Now, 0) / 180.0 * Math.PI;
            }
            else
            {
                rotationCurrent = (((jNow - 2451545.0) / planetRotationPeriod[planetID]) * Math.PI * 2) % (Math.PI * 2);
            }

            //Matrix3d matOldWV = renderContext.WV.Clone();

            Matrix3d matOld = renderContext.World;
            Matrix3d matOldBase = renderContext.WorldBase;
            Matrix3d matOldNonRotating = renderContext.WorldBaseNonRotating;

            Matrix3d matLocal = renderContext.World.Clone();
            Matrix3d matLocalNR = renderContext.World.Clone();

            Vector3d translation = Vector3d.SubtractVectors(planet3dLocations[planetID], centerPoint);

            matLocal.Scale(Vector3d.Create(radius, radius, radius));
            matLocal.Multiply(Matrix3d.RotationY((double)-rotationCurrent));
            matLocal.Multiply(Matrix3d.RotationX((double)(planetTilts[planetID] * RC)));
            matLocal.Multiply(Matrix3d.Translation(translation));

            matLocalNR.Scale(Vector3d.Create(radius, radius, radius));
            matLocalNR.Multiply(Matrix3d.RotationX((double)(planetTilts[planetID] * RC)));
            matLocalNR.Multiply(Matrix3d.Translation(translation));

            renderContext.World = matLocal;
            renderContext.WorldBase = matLocal.Clone();
            renderContext.WorldBaseNonRotating = matLocalNR;
            renderContext.MakeFrustum();

            float planetWidth = 1;

            if (planetID == (int)SolarSystemObjects.Saturn)
            {
                planetWidth = 3;
            }

            if (IsPlanetInFrustum(renderContext,planetWidth))
            {
                //Matrix3d matOld2 = renderContext.World.Clone();
                //Matrix3d matOldBase2 = renderContext.WorldBase.Clone();
                //Matrix3d matOldNonRotating2 = renderContext.WorldBaseNonRotating;

                Vector3d sun = planet3dLocations[0].Copy();
                Vector3d planet = planet3dLocations[planetID].Copy();

                sun = matOld.Transform(sun);
                planet = matOld.Transform(planet);

                Vector3d sunPosition = Vector3d.SubtractVectors(sun, planet);
                sunPosition.Normalize();

                renderContext.SunPosition = sunPosition;

                Vector3d loc = Vector3d.SubtractVectors(planet3dLocations[planetID], centerPoint);
                loc.Subtract(renderContext.CameraPosition);
                double dist = loc.Length();
                double sizeIndexParam = (2 * Math.Atan(.5 * (radius / dist))) / Math.PI * 180;

                int sizeIndex = 0;
                if (sizeIndexParam > 10.5)
                {
                    sizeIndex = 0;
                }
                else if (sizeIndexParam > 3.9)
                {
                    sizeIndex = 1;
                }
                else if (sizeIndexParam > .72)
                {
                    sizeIndex = 2;
                }
                else if (sizeIndexParam > 0.05)
                {
                    sizeIndex = 3;
                }
                else
                {
                    sizeIndex = 4;
                }

                //ShadowStuff
                if (planetID == (int)SolarSystemObjects.Earth && sizeIndex < 2)
                {
                    float width = Settings.Active.SolarSystemScale * .00001f;
                  //todo add shadows  centerPoint = SetupShadow(device, centerPoint, width, SolarSystemObjects.Moon);
                }
                //ShadowStuff end

                if (sizeIndex < 3)
                {
                     bool oldLighting = renderContext.Lighting;
                   //double planetDistance = Vector3d.SubtractVectors(planet3dLocations[planetID], renderContext.CameraPosition).Length();
                    if (planetID == 5)
                    {
                        renderContext.Lighting = false;
                        // DRAW BACK HALF OF RINGS
                        DrawSaturnsRings(renderContext, false, dist);
                        renderContext.Lighting = oldLighting;
                        //if (Settings.Active.SolarSystemLighting)
                        //{
                        //    SetupRingShadow(device, centerPoint, SolarSystemObjects.Saturn, rotationCurrent);
                        //}
                        // todo saturns rings DrawRings(device);

                    }

                    if (planetID == 0)
                    {
                        renderContext.Lighting = false;
                    }

                    DrawSphere(renderContext, planetID);

                    if (planetID == 5)
                    {
                        renderContext.Lighting = false;
                        DrawSaturnsRings(renderContext, true, dist);
                        // DRAW FRONT HALF OF RINGS
                        //if (Settings.Active.SolarSystemLighting)
                        //{
                        //    SetupRingShadow(device, centerPoint, SolarSystemObjects.Saturn, rotationCurrent);
                        //}
                       // todo saturns rings DrawRings(device);

                    }

                    renderContext.Lighting = oldLighting;

                }
                else
                {
                    if (planetID == 0)
                    {
                        DrawPointPlanet(renderContext, new Vector3d(), (double)(10 * planetDiameters[planetID]), planetColors[planetID], true);
                    }
                    else if (planetID < (int)SolarSystemObjects.Moon || planetID == (int)SolarSystemObjects.Earth)
                    {
                        double size = (800 * planetDiameters[planetID]);
                        DrawPointPlanet(renderContext, new Vector3d(), (double)Math.Max(.05, Math.Min(.1f, size)), planetColors[planetID], true);
                    }
                    else if (sizeIndexParam > .002)
                    {
                        double size = (800 * planetDiameters[planetID]);
                        DrawPointPlanet(renderContext, new Vector3d(), (double)Math.Max(.05, Math.Min(.1f, size)), planetColors[planetID], true);
                    }
                }
                //renderContext.World = matOld2;
                //renderContext.WorldBase = matOldBase2;
                //renderContext.WorldBaseNonRotating = matOldNonRotating2;
            }

            renderContext.World = matOld;
            renderContext.WorldBase = matOldBase;
            renderContext.WorldBaseNonRotating = matOldNonRotating;
        }
示例#5
0
        public static bool DrawAltAzGrid(RenderContext renderContext, float opacity, Color drawColor)
        {
            Coordinates zenithAltAz = new Coordinates(0, 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);
            Matrix3d mat = Matrix3d.RotationY((float)-raPart);
            mat.Multiply(Matrix3d.RotationX((float)decPart));
            mat.Invert();

            if (altAzLineList == null)
            {
                altAzLineList = new SimpleLineList();
                altAzLineList.DepthBuffered = false;

                for (double l = 0; l < 360; l += 10)
                {
                    for (double b = -80; b < 80; b += 2)
                    {
                        altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15 , b, 1), Coordinates.RADecTo3dAu(l / 15 , b + 2, 1));
                    }
                }

                for (double b = -80; b <= 80; b += 10)
                {
                    for (double l = 0; l < 360; l += 5)
                    {
                        altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15 , b, 1), Coordinates.RADecTo3dAu((l + 5) / 15 , b, 1));
                    }
                }

                int counter = 0;
                for (double l = 0; l < 360; l += 1)
                {

                    double b = 0.25;
                    switch (counter % 10)
                    {
                        case 0:
                            counter++;
                            continue;
                        case 5:
                            b = .5;
                            break;
                    }
                    counter++;

                    altAzLineList.AddLine(Coordinates.RADecTo3dAu(l / 15 , b, 1), Coordinates.RADecTo3dAu(l / 15, -b, 1));
                }

                counter = 0;
                for (double l = 0; l < 360; l += 90)
                {
                    counter = 0;
                    for (double b = -80; b <= 80; b += 1)
                    {
                        double width = 0.5 / 2;
                        switch (counter % 10)
                        {
                            case 0:
                                counter++;
                                continue;
                            case 5:
                                width = .5;
                                break;
                        }
                        counter++;

                        altAzLineList.AddLine(Coordinates.RADecTo3dAu((l + width) / 15 , b, 1), Coordinates.RADecTo3dAu((l - width) / 15 , b, 1));
                    }
                }
            }

            Matrix3d matOldWorld = renderContext.World.Clone();
            Matrix3d matOldWorldBase = renderContext.WorldBase.Clone();
            renderContext.WorldBase = Matrix3d.MultiplyMatrix(mat, renderContext.World);
            renderContext.World = renderContext.WorldBase.Clone();
            renderContext.MakeFrustum();

            altAzLineList.ViewTransform = Matrix3d.InvertMatrix(mat);

            altAzLineList.DrawLines(renderContext, opacity, drawColor);

            renderContext.WorldBase = matOldWorldBase;
            renderContext.World = matOldWorld;
            renderContext.MakeFrustum();
            return true;
        }
示例#6
0
        public static bool DrawAltAzGridText(RenderContext renderContext, float opacity, Color drawColor)
        {
            Coordinates zenithAltAz = new Coordinates(0, 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);
            Matrix3d mat = Matrix3d.RotationY((float)-raPart - Math.PI);
            mat.Multiply(Matrix3d.RotationX((float)decPart));
            mat.Invert();

            MakeAltAzGridText();

            Matrix3d matOldWorld = renderContext.World.Clone();
            Matrix3d matOldWorldBase = renderContext.WorldBase.Clone();

            renderContext.WorldBase = Matrix3d.MultiplyMatrix(mat, renderContext.World);
            renderContext.World = renderContext.WorldBase.Clone();
            renderContext.MakeFrustum();

            AltAzTextBatch.ViewTransform = Matrix3d.InvertMatrix(mat);
            AltAzTextBatch.Draw(renderContext, opacity, drawColor);

            renderContext.WorldBase = matOldWorldBase;
            renderContext.World = matOldWorld;
            renderContext.MakeFrustum();
            return true;
        }