Example #1
0
        public Sceen(StarSystem a_oStarSystem, GLEffect a_oDefaultEffect, Pulsar4X.UI.Handlers.SystemMap ParentSM)
        {
            // set member vars:
            m_v3ViewOffset = Vector3.Zero;
            MeasureMode    = false;

            ParentSystemMap    = ParentSM;
            SceenDefaultEffect = a_oDefaultEffect;

            /// <summary>
            /// These have to be initialized before the contactElements are created as contactElement uses these.
            /// </summary>
            ShowActives  = true;
            ShowPassives = true;
            ShowPassiveSignatureRange = (int)Constants.SensorTN.DefaultPassiveSignature;

            // Set Sceen Vars:
            m_oSceenEntity = a_oStarSystem;
            SceenID        = a_oStarSystem.Id;

            // Create measurement element:
            m_oMeasurementElement = new MeasurementElement();
            m_oMeasurementElement.PrimaryPrimitive = new GLLine(a_oDefaultEffect, Vector3.Zero, new Vector2(1.0f, 1.0f), Color.Yellow, UIConstants.Textures.DEFAULT_TEXTURE);
            m_oMeasurementElement.AddPrimitive(m_oMeasurementElement.PrimaryPrimitive);
            m_oMeasurementElement.Lable = new GLUtilities.GLFont(a_oDefaultEffect, Vector3.Zero, UIConstants.DEFAULT_TEXT_SIZE, Color.Yellow, UIConstants.Textures.DEFAULT_GLFONT2, "");

            // Creat Working Vars:
            //double dKMperAUdevby10 = (Pulsar4X.Constants.Units.KmPerAu / 10); // we scale everthing down by 10 to avoid float buffer overflows.
            int     iStarCounter       = 0;                                     // Keeps track of the number of stars.
            int     iPlanetCounter     = 0;                                     // Keeps track of the number of planets around the current star
            int     iMoonCounter       = 0;                                     // Keeps track of the number of moons around the current planet.
            double  dMaxOrbitDist      = 0;                                     // used for fit to zoom.
            Vector3 v3StarPos          = new Vector3(0, 0, 0);                  // used for storing the psoition of the current star in the system
            float   fStarSize          = 0.0f;                                  // Size of a star
            double  dPlanetOrbitRadius = 0;                                     // used for holding the orbit in Km for a planet.
            Vector3 v3PlanetPos        = new Vector3(0, 0, 0);                  // Used to store the planet Pos.
            float   fPlanetSize        = 0;                                     // used to hold the planets size.
            double  dMoonOrbitRadius   = 0;                                     // used for holding the orbit in Km for a Moon.
            float   fMoonSize          = 0;                                     // used to hold the Moons size.
            Vector3 v3MoonPos          = Vector3.Zero;                          // Used to store the Moons Position.

            // start creating star branches in the sceen graph:
            SceenElement oRootStar = null;
            SceenElement oCurrStar;

            foreach (Pulsar4X.Entities.Star oStar in a_oStarSystem.Stars)
            {
                if (iStarCounter <= 0)
                {
                    // then we have a secondary, etc star give random position around its orbit!
                    oRootStar = new StarElement(oStar, a_oDefaultEffect, Vector3.Zero, Pulsar4X.Constants.StarColor.LookupColor(oStar), null, true);
                    oCurrStar = oRootStar;
                }
                else
                {
                    Random rnd = new Random();
                    v3StarPos.X = (float)(oStar.Position.X);
                    v3StarPos.Y = (float)(oStar.Position.Y);
                    MaxOrbitDistTest(ref dMaxOrbitDist, oStar.Orbit.SemiMajorAxis);
                    oCurrStar = new StarElement(oStar, a_oDefaultEffect, v3StarPos, Pulsar4X.Constants.StarColor.LookupColor(oStar), oRootStar, false);
                }


                fStarSize = (float)(oStar.Radius * 2.0 * (Constants.Units.SolarRadiusInAu));

                GLUtilities.GLQuad oStarQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                      v3StarPos,
                                                                      new Vector2(fStarSize, fStarSize),
                                                                      Pulsar4X.Constants.StarColor.LookupColor(oStar),
                                                                      UIConstants.Textures.DEFAULT_PLANET_ICON);
                // create name lable:
                GLUtilities.GLFont oNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                                                                       new Vector3((float)(v3StarPos.X), (float)(v3StarPos.Y - (oStar.Radius / Constants.Units.KmPerAu)), 0),
                                                                       UIConstants.DEFAULT_TEXT_SIZE, Color.White, UIConstants.Textures.DEFAULT_GLFONT2, oStar.Name);

                oCurrStar.AddPrimitive(oStarQuad); // Add star icon to the Sceen element.
                oCurrStar.Lable            = oNameLable;
                oCurrStar.PrimaryPrimitive = oStarQuad;
                oCurrStar.RealSize         = new Vector2(fStarSize, fStarSize);
                this.AddElement(oCurrStar);

                // now go though and add each planet to render list.
                foreach (Pulsar4X.Entities.SystemBody oPlanet in oStar.Planets)
                {
                    SceenElement oPlanetElement = new PlanetElement(a_oDefaultEffect, v3StarPos, oPlanet, Color.FromArgb(255, 0, 205, 0), oCurrStar);
                    oPlanetElement.EntityID = oPlanet.Id;

                    if (iPlanetCounter == 0)
                    {
                        oCurrStar.SmallestOrbit = (float)(oPlanet.Orbit.SemiMajorAxis * 2);
                    }
                    dPlanetOrbitRadius = oPlanet.Orbit.SemiMajorAxis;

                    fPlanetSize = (float)((oPlanet.Radius * 2.0) / Constants.Units.KmPerAu);
                    MaxOrbitDistTest(ref dMaxOrbitDist, dPlanetOrbitRadius);

                    GLUtilities.GLQuad oPlanetQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                            v3PlanetPos,
                                                                            new Vector2(fPlanetSize, fPlanetSize),
                                                                            Color.FromArgb(255, 0, 255, 0), // lime green
                                                                            UIConstants.Textures.DEFAULT_PLANET_ICON);

                    // create name lable:
                    GLUtilities.GLFont oPlanetNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                                                                                 new Vector3((float)(v3PlanetPos.X), (float)(v3PlanetPos.Y - (oPlanet.Radius / Constants.Units.KmPerAu)), 0),
                                                                                 UIConstants.DEFAULT_TEXT_SIZE, Color.AntiqueWhite, UIConstants.Textures.DEFAULT_GLFONT2, oPlanet.Name);

                    oPlanetElement.AddPrimitive(oPlanetQuad);

                    oPlanetElement.Lable            = oPlanetNameLable;
                    oPlanetElement.PrimaryPrimitive = oPlanetQuad;
                    oPlanetElement.RealSize         = new Vector2(fPlanetSize, fPlanetSize);
                    oCurrStar.AddChildElement(oPlanetElement);

                    iPlanetCounter++;

                    // now again for the moons:
                    foreach (Pulsar4X.Entities.SystemBody oMoon in oPlanet.Moons)
                    {
                        SceenElement oMoonElement = new PlanetElement(a_oDefaultEffect, v3PlanetPos, oMoon, Color.FromArgb(255, 0, 205, 0), oPlanetElement);
                        oMoonElement.EntityID = oMoon.Id;

                        if (iMoonCounter == 0)
                        {
                            oPlanetElement.SmallestOrbit = (float)(oMoon.Orbit.SemiMajorAxis);
                        }

                        dMoonOrbitRadius = oMoon.Orbit.SemiMajorAxis;
                        fMoonSize        = (float)((oMoon.Radius * 2.0) / Constants.Units.KmPerAu);
                        v3MoonPos        = new Vector3((float)(oMoon.Position.X), (float)(oMoon.Position.Y), 0);
                        oMoon.Position.X = oMoon.Position.X + v3PlanetPos.X;
                        oMoon.Position.Y = oMoon.Position.Y + v3PlanetPos.Y;

                        GLUtilities.GLQuad oMoonQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                              v3MoonPos,                      // offset Pos by parent planet pos
                                                                              new Vector2(fMoonSize, fMoonSize),
                                                                              Color.FromArgb(255, 0, 205, 0), // lime green
                                                                              UIConstants.Textures.DEFAULT_PLANET_ICON);

                        GLUtilities.GLFont oMoonNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                                                                                   new Vector3((float)(v3MoonPos.X), (float)(v3MoonPos.Y - (oMoon.Radius / Constants.Units.KmPerAu)), 0),
                                                                                   UIConstants.DEFAULT_TEXT_SIZE, Color.AntiqueWhite, UIConstants.Textures.DEFAULT_GLFONT2, oMoon.Name);

                        oMoonElement.AddPrimitive(oMoonQuad);

                        oMoonElement.Lable            = oMoonNameLable;
                        oMoonElement.PrimaryPrimitive = oMoonQuad;
                        oMoonElement.RealSize         = new Vector2(fMoonSize, fMoonSize);
                        oPlanetElement.AddChildElement(oMoonElement);

                        iMoonCounter++;
                    }
                    iMoonCounter = 0;
                }
                iPlanetCounter = 0;
                foreach (Pulsar4X.Entities.JumpPoint oJumpPoint in a_oStarSystem.JumpPoints)
                {
                    CreateJumpPoint(oCurrStar, oJumpPoint);
                }

                int SPIndex = 1;
                foreach (Pulsar4X.Entities.SurveyPoint oSurveyPoint in a_oStarSystem._SurveyPoints)
                {
                    CreateSurveyPoint(oCurrStar, oSurveyPoint, a_oDefaultEffect, SPIndex);
                    SPIndex++;
                }

                iStarCounter++;
            }

            foreach (Pulsar4X.Entities.SystemContact systemContact in a_oStarSystem.SystemContactList)
            {
                AddContactElement(SceenDefaultEffect, systemContact);
            }

            a_oStarSystem.JumpPoints.ListChanged         += JumpPoints_ListChanged;
            a_oStarSystem.SystemContactList.ListChanging += SystemContactList_ListChanging;

            // Set Sceen Size basd on Max Orbit:
            m_v2SceenSize = new Vector2d(dMaxOrbitDist * 2, dMaxOrbitDist * 2);
        }
Example #2
0
        public Sceen(StarSystem a_oStarSystem, GLEffect a_oDefaultEffect, Pulsar4X.UI.Handlers.SystemMap ParentSM)
        {
            // set member vars:
            m_v3ViewOffset = Vector3.Zero;
            MeasureMode = false;

            ParentSystemMap = ParentSM;
            SceenDefaultEffect = a_oDefaultEffect;

            /// <summary>
            /// These have to be initialized before the contactElements are created as contactElement uses these.
            /// </summary>
            ShowActives = true;
            ShowPassives = true;
            ShowPassiveSignatureRange = (int)Constants.SensorTN.DefaultPassiveSignature;

            // Set Sceen Vars:
            m_oSceenEntity = a_oStarSystem;
            SceenID = a_oStarSystem.Id;

            // Create measurement element:
            m_oMeasurementElement = new MeasurementElement();
            m_oMeasurementElement.PrimaryPrimitive = new GLLine(a_oDefaultEffect, Vector3.Zero, new Vector2(1.0f, 1.0f), Color.Yellow, UIConstants.Textures.DEFAULT_TEXTURE);
            m_oMeasurementElement.AddPrimitive(m_oMeasurementElement.PrimaryPrimitive);
            m_oMeasurementElement.Lable = new GLUtilities.GLFont(a_oDefaultEffect, Vector3.Zero, UIConstants.DEFAULT_TEXT_SIZE, Color.Yellow, UIConstants.Textures.DEFAULT_GLFONT2, "");

            // Creat Working Vars:
            //double dKMperAUdevby10 = (Pulsar4X.Constants.Units.KmPerAu / 10); // we scale everthing down by 10 to avoid float buffer overflows.
            int iStarCounter = 0;                                               // Keeps track of the number of stars.
            int iPlanetCounter = 0;                                             // Keeps track of the number of planets around the current star
            int iMoonCounter = 0;                                               // Keeps track of the number of moons around the current planet.
            double dMaxOrbitDist = 0;                                           // used for fit to zoom.
            Vector3 v3StarPos = new Vector3(0, 0, 0);                           // used for storing the psoition of the current star in the system
            float fStarSize = 0.0f;                                             // Size of a star
            double dPlanetOrbitRadius = 0;                                      // used for holding the orbit in Km for a planet.
            Vector3 v3PlanetPos = new Vector3(0, 0, 0);                         // Used to store the planet Pos.
            float fPlanetSize = 0;                                              // used to hold the planets size.
            double dMoonOrbitRadius = 0;                                        // used for holding the orbit in Km for a Moon.
            float fMoonSize = 0;                                                // used to hold the Moons size.
            Vector3 v3MoonPos = Vector3.Zero;                                   // Used to store the Moons Position.

            // start creating star branches in the sceen graph:
            SceenElement oRootStar;
            SceenElement oCurrStar;
            foreach (Pulsar4X.Entities.Star oStar in a_oStarSystem.Stars)
            {

                if (iStarCounter <= 0)
                {
                    // then we have a secondary, etc star give random position around its orbit!
                    oRootStar = new StarElement(oStar, a_oDefaultEffect, Vector3.Zero, Pulsar4X.Constants.StarColor.LookupColor(oStar), true);
                    oCurrStar = oRootStar;
                }
                else
                {
                    Random rnd = new Random();
                    v3StarPos.X = (float)(oStar.Position.X);
                    v3StarPos.Y = (float)(oStar.Position.Y);    
                    MaxOrbitDistTest(ref dMaxOrbitDist, oStar.Orbit.SemiMajorAxis);
                    oCurrStar = new StarElement(oStar, a_oDefaultEffect, v3StarPos, Pulsar4X.Constants.StarColor.LookupColor(oStar), false);
                }


                fStarSize = (float)(oStar.Radius * 2.0 * (Constants.Units.SolarRadiusInAu));

                GLUtilities.GLQuad oStarQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                        v3StarPos,
                                                                        new Vector2(fStarSize, fStarSize),
                                                                        Pulsar4X.Constants.StarColor.LookupColor(oStar),
                                                                        UIConstants.Textures.DEFAULT_PLANET_ICON);
                // create name lable:
                GLUtilities.GLFont oNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                    new Vector3((float)(v3StarPos.X), (float)(v3StarPos.Y - (oStar.Radius / Constants.Units.KmPerAu)), 0),
                    UIConstants.DEFAULT_TEXT_SIZE, Color.White, UIConstants.Textures.DEFAULT_GLFONT2, oStar.Name);

                oCurrStar.AddPrimitive(oStarQuad); // Add star icon to the Sceen element.
                oCurrStar.Lable = oNameLable;
                oCurrStar.PrimaryPrimitive = oStarQuad;
                oCurrStar.RealSize = new Vector2(fStarSize, fStarSize);
                this.AddElement(oCurrStar);

                // now go though and add each planet to render list.
                foreach (Pulsar4X.Entities.SystemBody oPlanet in oStar.Planets)
                {
                    SceenElement oPlanetElement = new PlanetElement(a_oDefaultEffect, v3StarPos, oPlanet, Color.FromArgb(255, 0, 205, 0));
                    oPlanetElement.EntityID = oPlanet.Id;

                    if (iPlanetCounter == 0)
                    {
                        oCurrStar.SmallestOrbit = (float)(oPlanet.Orbit.SemiMajorAxis * 2);
                    }
                    dPlanetOrbitRadius = oPlanet.Orbit.SemiMajorAxis;

                    fPlanetSize = (float)((oPlanet.Radius * 2.0) / Constants.Units.KmPerAu);
                    MaxOrbitDistTest(ref dMaxOrbitDist, dPlanetOrbitRadius);

                    GLUtilities.GLQuad oPlanetQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                        v3PlanetPos,
                        new Vector2(fPlanetSize, fPlanetSize),
                        Color.FromArgb(255, 0, 255, 0),  // lime green
                        UIConstants.Textures.DEFAULT_PLANET_ICON);

                    // create name lable:
                    GLUtilities.GLFont oPlanetNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                        new Vector3((float)(v3PlanetPos.X), (float)(v3PlanetPos.Y - (oPlanet.Radius / Constants.Units.KmPerAu)), 0),
                        UIConstants.DEFAULT_TEXT_SIZE, Color.AntiqueWhite, UIConstants.Textures.DEFAULT_GLFONT2, oPlanet.Name);

                    oPlanetElement.AddPrimitive(oPlanetQuad);

                    oPlanetElement.Lable = oPlanetNameLable;
                    oPlanetElement.PrimaryPrimitive = oPlanetQuad;
                    oPlanetElement.RealSize = new Vector2(fPlanetSize, fPlanetSize);
                    oCurrStar.AddChildElement(oPlanetElement);

                    iPlanetCounter++;

                    // now again for the moons:
                    foreach (Pulsar4X.Entities.SystemBody oMoon in oPlanet.Moons)
                    {
                        SceenElement oMoonElement = new PlanetElement(a_oDefaultEffect, v3PlanetPos, oMoon, Color.FromArgb(255, 0, 205, 0));
                        oMoonElement.EntityID = oMoon.Id;

                        if (iMoonCounter == 0)
                        {
                            oPlanetElement.SmallestOrbit = (float)(oMoon.Orbit.SemiMajorAxis);
                        }

                        dMoonOrbitRadius = oMoon.Orbit.SemiMajorAxis;
                        fMoonSize = (float)((oMoon.Radius * 2.0) / Constants.Units.KmPerAu);
                        v3MoonPos = new Vector3((float)(oMoon.Position.X), (float)(oMoon.Position.Y), 0);
                        oMoon.Position.X = oMoon.Position.X + v3PlanetPos.X;
                        oMoon.Position.Y = oMoon.Position.Y + v3PlanetPos.Y;

                        GLUtilities.GLQuad oMoonQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                            v3MoonPos,                                    // offset Pos by parent planet pos
                            new Vector2(fMoonSize, fMoonSize),
                            Color.FromArgb(255, 0, 205, 0),  // lime green
                            UIConstants.Textures.DEFAULT_PLANET_ICON);

                        GLUtilities.GLFont oMoonNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                        new Vector3((float)(v3MoonPos.X), (float)(v3MoonPos.Y - (oMoon.Radius / Constants.Units.KmPerAu)), 0),
                        UIConstants.DEFAULT_TEXT_SIZE, Color.AntiqueWhite, UIConstants.Textures.DEFAULT_GLFONT2, oMoon.Name);

                        oMoonElement.AddPrimitive(oMoonQuad);

                        oMoonElement.Lable = oMoonNameLable;
                        oMoonElement.PrimaryPrimitive = oMoonQuad;
                        oMoonElement.RealSize = new Vector2(fMoonSize, fMoonSize);
                        oPlanetElement.AddChildElement(oMoonElement);

                        iMoonCounter++;
                    }
                    iMoonCounter = 0;
                }
                iPlanetCounter = 0;
                foreach (Pulsar4X.Entities.JumpPoint oJumpPoint in a_oStarSystem.JumpPoints)
                {
                    CreateJumpPoint(oCurrStar, oJumpPoint);
                }

                iStarCounter++;
            }

            foreach (Pulsar4X.Entities.SystemContact systemContact in a_oStarSystem.SystemContactList)
            {
                AddContactElement(SceenDefaultEffect, systemContact);
            }

            a_oStarSystem.JumpPoints.ListChanged += JumpPoints_ListChanged;
            a_oStarSystem.SystemContactList.ListChanging += SystemContactList_ListChanging;

            // Set Sceen Size basd on Max Orbit:
            m_v2SceenSize = new Vector2d(dMaxOrbitDist * 2, dMaxOrbitDist * 2);
        }
Example #3
0
        public Sceen(StarSystem a_oStarSystem, GLEffect a_oDefaultEffect, Pulsar4X.UI.Handlers.SystemMap ParentSM)
        {
            // set member vars:
            m_v3ViewOffset = Vector3.Zero;
            MeasureMode    = false;

            ParentSystemMap    = ParentSM;
            SceenDefaultEffect = a_oDefaultEffect;

            // Set Sceen Vars:
            m_oSceenEntity = a_oStarSystem;
            SceenID        = a_oStarSystem.Id;

            // Create measurement element:
            m_oMeasurementElement = new MeasurementElement();
            m_oMeasurementElement.PrimaryPrimitive = new GLLine(a_oDefaultEffect, Vector3.Zero, new Vector2(1.0f, 1.0f), Color.Yellow, UIConstants.Textures.DEFAULT_TEXTURE);
            m_oMeasurementElement.AddPrimitive(m_oMeasurementElement.PrimaryPrimitive);
            m_oMeasurementElement.Lable = new GLUtilities.GLFont(a_oDefaultEffect, Vector3.Zero, UIConstants.DEFAULT_TEXT_SIZE, Color.Yellow, UIConstants.Textures.DEFAULT_GLFONT2, "");

            // Creat Working Vars:
            //double dKMperAUdevby10 = (Pulsar4X.Constants.Units.KM_PER_AU / 10); // we scale everthing down by 10 to avoid float buffer overflows.
            int     iStarCounter       = 0;                                     // Keeps track of the number of stars.
            int     iPlanetCounter     = 0;                                     // Keeps track of the number of planets around the current star
            int     iMoonCounter       = 0;                                     // Keeps track of the number of moons around the current planet.
            double  dMaxOrbitDist      = 0;                                     // used for fit to zoom.
            Vector3 v3StarPos          = new Vector3(0, 0, 0);                  // used for storing the psoition of the current star in the system
            float   fStarSize          = 0.0f;                                  // Size of a star
            double  dPlanetOrbitRadius = 0;                                     // used for holding the orbit in Km for a planet.
            Vector3 v3PlanetPos        = new Vector3(0, 0, 0);                  // Used to store the planet Pos.
            float   fPlanetSize        = 0;                                     // used to hold the planets size.
            double  dMoonOrbitRadius   = 0;                                     // used for holding the orbit in Km for a Moon.
            float   fMoonSize          = 0;                                     // used to hold the Moons size.
            Vector3 v3MoonPos          = Vector3.Zero;                          // Used to store the Moons Position.

            // start creating star branches in the sceen graph:
            SceenElement oRootStar;
            SceenElement oCurrStar;

            foreach (Pulsar4X.Entities.Star oStar in a_oStarSystem.Stars)
            {
                if (iStarCounter <= 0)
                {
                    // then we have a secondary, etc star give random position around its orbit!
                    oRootStar = new StarElement(oStar, a_oDefaultEffect, Vector3.Zero, Pulsar4X.Constants.StarColor.LookupColor(oStar.Class), true);
                    oCurrStar = oRootStar;
                }
                else
                {
                    Random rnd = new Random();
                    //float fAngle = 0.0f; // rnd.Next(0, 360);
                    //fAngle = MathHelper.DegreesToRadians(fAngle);
                    // double x, y;
                    Pulsar4X.Lib.OrbitTable.Instance.UpdatePosition(oStar, 0);
                    v3StarPos.X = (float)(oStar.XSystem); //(float)(Math.Cos(fAngle) * oStar.SemiMajorAxis * dKMperAUdevby10);
                    v3StarPos.Y = (float)(oStar.YSystem); //(float)(Math.Sin(fAngle) * oStar.SemiMajorAxis * dKMperAUdevby10);
                    MaxOrbitDistTest(ref dMaxOrbitDist, oStar.SemiMajorAxis);
                    oCurrStar = new StarElement(oStar, a_oDefaultEffect, v3StarPos, Pulsar4X.Constants.StarColor.LookupColor(oStar.Class), false);

                    // create orbit circle

                    /*GLUtilities.GLCircle oStarOrbitCirc = new GLUtilities.GLCircle(a_oDefaultEffect,
                     *  Vector3.Zero,                                                                      // base around parent star pos.
                     *  oStar, //(float)(oStar.SemiMajorAxis * dKMperAUdevby10) / 2,
                     *  Pulsar4X.Constants.StarColor.LookupColor(oStar.Class),
                     *  UIConstants.Textures.DEFAULT_TEXTURE);
                     * oCurrStar.AddPrimitive(oStarOrbitCirc);*/
                }


                fStarSize = (float)(oStar.Radius * 2.0 * (Constants.Units.SOLAR_RADIUS_IN_AU));

                GLUtilities.GLQuad oStarQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                      v3StarPos,
                                                                      new Vector2(fStarSize, fStarSize),
                                                                      Pulsar4X.Constants.StarColor.LookupColor(oStar.Class),
                                                                      UIConstants.Textures.DEFAULT_PLANET_ICON);
                // create name lable:
                GLUtilities.GLFont oNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                                                                       new Vector3((float)(v3StarPos.X), (float)(v3StarPos.Y - (oStar.Radius / Constants.Units.KM_PER_AU)), 0),
                                                                       UIConstants.DEFAULT_TEXT_SIZE, Color.White, UIConstants.Textures.DEFAULT_GLFONT2, oStar.Name);

                oCurrStar.AddPrimitive(oStarQuad); // Add star icon to the Sceen element.
                oCurrStar.Lable            = oNameLable;
                oCurrStar.PrimaryPrimitive = oStarQuad;
                oCurrStar.RealSize         = new Vector2(fStarSize, fStarSize);
                this.AddElement(oCurrStar);

                // now go though and add each planet to render list.
                foreach (Pulsar4X.Entities.Planet oPlanet in oStar.Planets)
                {
                    SceenElement oPlanetElement = new PlanetElement(a_oDefaultEffect, v3StarPos, oPlanet, Color.FromArgb(255, 0, 205, 0));
                    oPlanetElement.EntityID = oPlanet.Id;

                    if (iPlanetCounter == 0)
                    {
                        oCurrStar.SmallestOrbit = (float)(oPlanet.SemiMajorAxis * 2);
                    }

                    dPlanetOrbitRadius = oPlanet.SemiMajorAxis;
                    Pulsar4X.Lib.OrbitTable.Instance.UpdatePosition(oPlanet, 0);
                    v3PlanetPos     = new Vector3((float)(oPlanet.XSystem), (float)(oPlanet.YSystem), 0) + v3StarPos; // offset Pos by parent star pos
                    oPlanet.XSystem = oPlanet.XSystem + v3StarPos.X;
                    oPlanet.YSystem = oPlanet.YSystem + v3StarPos.Y;

                    fPlanetSize = (float)((oPlanet.Radius * 2.0) / Constants.Units.KM_PER_AU);
                    MaxOrbitDistTest(ref dMaxOrbitDist, dPlanetOrbitRadius);

                    GLUtilities.GLQuad oPlanetQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                            v3PlanetPos,
                                                                            new Vector2(fPlanetSize, fPlanetSize),
                                                                            Color.FromArgb(255, 0, 255, 0), // lime green
                                                                            UIConstants.Textures.DEFAULT_PLANET_ICON);

                    /*GLUtilities.GLCircle oPlanetOrbitCirc = new GLUtilities.GLCircle(a_oDefaultEffect,
                     *  v3StarPos,                                                                      // base around parent star pos.
                     *  oPlanet, //(float)dPlanetOrbitRadius / 2,
                     *  Color.FromArgb(255, 0, 205, 0),  // lime green
                     *  UIConstants.Textures.DEFAULT_TEXTURE);*/

                    // create name lable:
                    GLUtilities.GLFont oPlanetNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                                                                                 new Vector3((float)(v3PlanetPos.X), (float)(v3PlanetPos.Y - (oPlanet.Radius / Constants.Units.KM_PER_AU)), 0),
                                                                                 UIConstants.DEFAULT_TEXT_SIZE, Color.AntiqueWhite, UIConstants.Textures.DEFAULT_GLFONT2, oPlanet.Name);

                    oPlanetElement.AddPrimitive(oPlanetQuad);

                    //oPlanetElement.AddPrimitive(oPlanetOrbitCirc);

                    oPlanetElement.Lable            = oPlanetNameLable;
                    oPlanetElement.PrimaryPrimitive = oPlanetQuad;
                    oPlanetElement.RealSize         = new Vector2(fPlanetSize, fPlanetSize);
                    oCurrStar.AddChildElement(oPlanetElement);

                    iPlanetCounter++;

                    // now again for the moons:
                    foreach (Pulsar4X.Entities.Planet oMoon in oPlanet.Moons)
                    {
                        SceenElement oMoonElement = new PlanetElement(a_oDefaultEffect, v3PlanetPos, oMoon, Color.FromArgb(255, 0, 205, 0));
                        oMoonElement.EntityID = oMoon.Id;

                        if (iMoonCounter == 0)
                        {
                            oPlanetElement.SmallestOrbit = (float)(oMoon.SemiMajorAxis);
                        }

                        dMoonOrbitRadius = oMoon.SemiMajorAxis;
                        Pulsar4X.Lib.OrbitTable.Instance.UpdatePosition(oMoon, 0);
                        fMoonSize     = (float)((oMoon.Radius * 2.0) / Constants.Units.KM_PER_AU);
                        v3MoonPos     = new Vector3((float)(oMoon.XSystem), (float)(oMoon.YSystem), 0) + v3PlanetPos;
                        oMoon.XSystem = oMoon.XSystem + v3PlanetPos.X;
                        oMoon.YSystem = oMoon.YSystem + v3PlanetPos.Y;

                        GLUtilities.GLQuad oMoonQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                                              v3MoonPos,                      // offset Pos by parent planet pos
                                                                              new Vector2(fMoonSize, fMoonSize),
                                                                              Color.FromArgb(255, 0, 205, 0), // lime green
                                                                              UIConstants.Textures.DEFAULT_PLANET_ICON);

                        /*GLUtilities.GLCircle oMoonOrbitCirc = new GLUtilities.GLCircle(a_oDefaultEffect,
                         *  v3PlanetPos,                                                                      // base around parent planet pos.
                         *  oMoon, //(float)dMoonOrbitRadius / 2,
                         *  Color.FromArgb(255, 0, 205, 0),  // lime green
                         *  UIConstants.Textures.DEFAULT_TEXTURE);*/

                        GLUtilities.GLFont oMoonNameLable = new GLUtilities.GLFont(a_oDefaultEffect,
                                                                                   new Vector3((float)(v3MoonPos.X), (float)(v3MoonPos.Y - (oMoon.Radius / Constants.Units.KM_PER_AU)), 0),
                                                                                   UIConstants.DEFAULT_TEXT_SIZE, Color.AntiqueWhite, UIConstants.Textures.DEFAULT_GLFONT2, oMoon.Name);

                        oMoonElement.AddPrimitive(oMoonQuad);

                        //oMoonElement.AddPrimitive(oMoonOrbitCirc);

                        oMoonElement.Lable            = oMoonNameLable;
                        oMoonElement.PrimaryPrimitive = oMoonQuad;
                        oMoonElement.RealSize         = new Vector2(fMoonSize, fMoonSize);
                        oPlanetElement.AddChildElement(oMoonElement);

                        iMoonCounter++;
                    }
                    iMoonCounter = 0;
                }
                iPlanetCounter = 0;
                iStarCounter++;
            }

            // create any system contacts:
            foreach (Pulsar4X.Entities.SystemContact oContact in a_oStarSystem.SystemContactList)
            {
                SceenElement       oContactElement;
                Vector3            v3ContactPos;
                GLUtilities.GLFont oNameLable;
                GLUtilities.GLQuad oContactQuad;

                switch (oContact.SSEntity)
                {
                case StarSystemEntityType.TaskGroup:
                    oContactElement          = new ContactElement(a_oDefaultEffect, oContact);
                    oContactElement.EntityID = oContact.Id;

                    v3ContactPos = new Vector3((float)oContact.TaskGroup.Contact.XSystem, (float)oContact.TaskGroup.Contact.YSystem, 0.0f);

                    oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                          v3ContactPos,
                                                          new Vector2(0.0001f, 0.0001f),                                 // what size is a task groug anyway???
                                                          oContact.faction.FactionColor,
                                                          UIConstants.Textures.DEFAULT_TASKGROUP_ICON);

                    oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos,
                                                        UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, oContact.TaskGroup.Name);

                    oContactElement.Lable            = oNameLable;
                    oContactElement.PrimaryPrimitive = oContactQuad;
                    oContactElement.AddPrimitive(oContactQuad);
                    oContactElement.RealSize = new Vector2(0.0001f, 0.0001f);
                    this.AddElement(oContactElement);
                    (oContactElement as ContactElement).ParentSceen = this;
                    break;

                case StarSystemEntityType.Missile:
                    oContactElement          = new ContactElement(a_oDefaultEffect, oContact);
                    oContactElement.EntityID = oContact.Id;

                    v3ContactPos = new Vector3((float)oContact.MissileGroup.contact.XSystem, (float)oContact.MissileGroup.contact.YSystem, 0.0f);

                    oContactQuad = new GLUtilities.GLQuad(a_oDefaultEffect,
                                                          v3ContactPos,
                                                          new Vector2(0.0001f, 0.0001f),                             // what size is a missile?
                                                          oContact.faction.FactionColor,
                                                          UIConstants.Textures.DEFAULT_TASKGROUP_ICON);

                    oNameLable = new GLUtilities.GLFont(a_oDefaultEffect, v3ContactPos,
                                                        UIConstants.DEFAULT_TEXT_SIZE, oContact.faction.FactionColor, UIConstants.Textures.DEFAULT_GLFONT2, oContact.MissileGroup.Name);

                    oContactElement.Lable            = oNameLable;
                    oContactElement.PrimaryPrimitive = oContactQuad;
                    oContactElement.AddPrimitive(oContactQuad);
                    oContactElement.RealSize = new Vector2(0.0001f, 0.0001f);
                    this.AddElement(oContactElement);
                    (oContactElement as ContactElement).ParentSceen = this;
                    break;
                }

                oContact.ContactElementCreated = SystemContact.CEState.Created;
            }

            // Set Sceen Size basd on Max Orbit:
            m_v2SceenSize = new Vector2d(dMaxOrbitDist * 2, dMaxOrbitDist * 2);
        }