Пример #1
0
        public void OnPSystemReady(RootDefinition Root, CelestialBody OriginalSun, Transform ScaledSun)
        {
            Debug.Log("Altering sun...");

            //Set Original Sun Parameters
            double SolarMasses;


            SolarMasses = Root.SolarMasses;

            OriginalSun.Mass               = SolarMasses * OriginalSun.Mass;
            OriginalSun.Radius             = (2 * (6.74E-11) * OriginalSun.Mass) / (Math.Pow(299792458, 2.0));
            OriginalSun.GeeASL             = OriginalSun.Mass * (6.674E-11 / 9.81) / Math.Pow(OriginalSun.Radius, 2.0);
            OriginalSun.gMagnitudeAtCenter = OriginalSun.GeeASL * 9.81 * Math.Pow(OriginalSun.Radius, 2.0);
            OriginalSun.gravParameter      = OriginalSun.gMagnitudeAtCenter;

            OriginalSun.scienceValues.InSpaceLowDataValue = OriginalSun.scienceValues.InSpaceLowDataValue * 10f;
            OriginalSun.scienceValues.RecoveryValue       = OriginalSun.scienceValues.RecoveryValue * 5f;

            OriginalSun.bodyName = "Blacky Karman";

            OriginalSun.bodyDescription =
                "This recently discovered black hole, named after its discoverer Billy-Hadrick Kerman, is the central point where multiple star systems revolve around.";

            OriginalSun.CBUpdate();

            //Make Sun Black
            ScaledSun.renderer.material.SetColor("_EmitColor0", new Color(0.0f, 0.0f, 0.0f, 1));
            ScaledSun.renderer.material.SetColor("_EmitColor1", new Color(0.0f, 0.0f, 0.0f, 1));
            ScaledSun.renderer.material.SetColor("_SunspotColor", new Color(0.0f, 0.0f, 0.0f, 1));
            ScaledSun.renderer.material.SetColor("_RimColor", new Color(0.0f, 0.0f, 0.0f, 1.0f));

            //Update Sun Scale
            var ScaledSunMeshFilter = (MeshFilter)ScaledSun.GetComponent(typeof(MeshFilter));
            var SunRatio            = (float)OriginalSun.Radius / 261600000f;

            MeshScaler.ScaleMesh(ScaledSunMeshFilter.mesh, SunRatio);

            //Change Sun Corona
            foreach (var SunCorona in ScaledSun.GetComponentsInChildren <SunCoronas>())
            {
                SunCorona.renderer.material.mainTexture =
                    GameDatabase.Instance.GetTexture("StarSystems/Resources/BlackHoleCorona", false);
                var SunCoronaMeshFilter = (MeshFilter)SunCorona.GetComponent(typeof(MeshFilter));
                MeshScaler.ScaleMesh(SunCoronaMeshFilter.mesh, SunRatio);
            }

            Debug.Log("Sun altered");
        }
Пример #2
0
        public void OnPSystemReady(RootDefinition Root, CelestialBody OriginalSun, Transform ScaledSun)
        {
            Debug.Log("Altering sun...");

            //Set Original Sun Parameters
            OriginalSun.Mass               = Root.SolarMasses * OriginalSun.Mass;
            OriginalSun.Radius             = (2 * (6.674E-11) * OriginalSun.Mass) / (Math.Pow(299792458, 2.0));
            OriginalSun.GeeASL             = OriginalSun.Mass * (6.674E-11 / 9.81) / Math.Pow(OriginalSun.Radius, 2.0);
            OriginalSun.gMagnitudeAtCenter = OriginalSun.GeeASL * 9.81 * Math.Pow(OriginalSun.Radius, 2.0);
            OriginalSun.gravParameter      = OriginalSun.gMagnitudeAtCenter;

            OriginalSun.scienceValues.InSpaceLowDataValue = OriginalSun.scienceValues.InSpaceLowDataValue * 10f;
            OriginalSun.scienceValues.RecoveryValue       = OriginalSun.scienceValues.RecoveryValue * 5f;

            OriginalSun.bodyName = Root.name;

            OriginalSun.bodyDescription = Root.description;

            OriginalSun.CBUpdate();

            //Make Sun Black
            ScaledSun.renderer.material.SetColor("_EmitColor0", Root.color.emitColor0);
            ScaledSun.renderer.material.SetColor("_EmitColor1", Root.color.emitColor1);
            ScaledSun.renderer.material.SetColor("_SunspotColor", Root.color.sunSpotColor);
            ScaledSun.renderer.material.SetColor("_RimColor", Root.color.rimColor);

            //Update Sun Scale
            var ScaledSunMeshFilter = (MeshFilter)ScaledSun.GetComponent(typeof(MeshFilter));
            var SunRatio            = (float)OriginalSun.Radius / 261600000f;

            MeshScaler.ScaleMesh(ScaledSunMeshFilter.mesh, SunRatio);

            //Change Sun Corona
            foreach (var SunCorona in ScaledSun.GetComponentsInChildren <SunCoronas>())
            {
                SunCorona.renderer.material.mainTexture = Root.color.coronaTexture;
                var SunCoronaMeshFilter = (MeshFilter)SunCorona.GetComponent(typeof(MeshFilter));
                MeshScaler.ScaleMesh(SunCoronaMeshFilter.mesh, SunRatio);
            }

            Debug.Log("Sun altered");
        }
Пример #3
0
        public void OnPSystemReady(CelestialBody Sun, CelestialBody star, Transform starTransform)
        {
            var LocalSunCB           = Sun;
            var LocalStarCB          = star;
            var StarRatio            = (float)defintion.Radius / 261600000f;
            var ScaledStar           = starTransform;
            var ScaledStarMeshFilter = (MeshFilter)ScaledStar.GetComponent(typeof(MeshFilter));

            //Set Star Variables
            LocalStarCB.Mass               = defintion.Mass;
            LocalStarCB.Radius             = defintion.Radius;
            LocalStarCB.GeeASL             = LocalStarCB.Mass * (6.674E-11 / 9.81) / Math.Pow(LocalStarCB.Radius, 2.0);
            LocalStarCB.gMagnitudeAtCenter = LocalStarCB.GeeASL * 9.81 * Math.Pow(LocalStarCB.Radius, 2.0);
            LocalStarCB.gravParameter      = LocalStarCB.gMagnitudeAtCenter;
            LocalStarCB.bodyDescription    = defintion.BodyDescription;

            //Set Science parameters
            LocalStarCB.scienceValues.InSpaceLowDataValue = LocalStarCB.scienceValues.InSpaceLowDataValue *
                                                            defintion.ScienceMultiplier;
            LocalStarCB.scienceValues.RecoveryValue = LocalStarCB.scienceValues.RecoveryValue *
                                                      defintion.ScienceMultiplier;

            //Create new Orbitdriver
            OrbitDriver NewOrbitDriver = LocalStarCB.gameObject.AddComponent <OrbitDriver>();

            //Add new OrbitDriver to Kerbol
            LocalStarCB.orbitDriver = NewOrbitDriver;

            //Set OrbitDriver parameters
            LocalStarCB.orbitDriver.name          = LocalStarCB.name;
            LocalStarCB.orbitDriver.celestialBody = LocalStarCB;
            LocalStarCB.orbitDriver.referenceBody = LocalSunCB;
            LocalStarCB.orbitDriver.updateMode    = OrbitDriver.UpdateMode.UPDATE;
            LocalStarCB.orbitDriver.QueuedUpdate  = true;

            //Create new orbit
            LocalStarCB.orbitDriver.orbit = defintion.orbit.getOrbit(LocalSunCB);

            //Calculate SOI
            LocalStarCB.sphereOfInfluence = (LocalStarCB.orbit.semiMajorAxis *
                                             Math.Pow(LocalStarCB.Mass / LocalStarCB.orbit.referenceBody.Mass, (2.0 / 5)));
            LocalStarCB.hillSphere = LocalStarCB.orbit.semiMajorAxis * (1.0 - LocalStarCB.orbit.eccentricity) *
                                     Math.Pow((LocalStarCB.Mass / (3.0 * LocalStarCB.orbit.referenceBody.Mass)), 1.0 / 3.0);

            //Update CelestialBody
            LocalStarCB.CBUpdate();

            //Update OrbitDriver
            NewOrbitDriver.UpdateOrbit();

            //Update Star Scale
            MeshScaler.ScaleMesh(ScaledStarMeshFilter.mesh, StarRatio);

            //Update Corona Ratio
            foreach (var StarCorona in ScaledStar.GetComponentsInChildren <SunCoronas>())
            {
                var StarCoronaMeshFilter = (MeshFilter)StarCorona.GetComponent(typeof(MeshFilter));
                MeshScaler.ScaleMesh(StarCoronaMeshFilter.mesh, StarRatio);
            }

            if (defintion.StarColor != null)
            {
                ScaledStar.renderer.material.SetColor("_EmitColor0", defintion.StarColor.emitColor0);
                ScaledStar.renderer.material.SetColor("_EmitColor1", defintion.StarColor.emitColor1);
                ScaledStar.renderer.material.SetColor("_SunspotColor", defintion.StarColor.sunSpotColor);
                ScaledStar.renderer.material.SetColor("_RimColor", defintion.StarColor.rimColor);

                foreach (var StarCorona in ScaledStar.GetComponentsInChildren <SunCoronas>())
                {
                    StarCorona.renderer.material.mainTexture = defintion.StarColor.coronaTexture;
                }
            }
            else
            {
                Debug.Log("StarColor for " + defintion.Name + " is null!");
            }
        }
Пример #4
0
        public void OnPSystemReady(CelestialBody Sun, CelestialBody star, Transform starTransform)
        {
            var LocalSunCB           = Sun;
            var LocalStarCB          = star;
            var StarRatio            = (float)defintion.Radius / 261600000f;
            var ScaledStar           = starTransform;
            var ScaledStarMeshFilter = (MeshFilter)ScaledStar.GetComponent(typeof(MeshFilter));

            //Set Star Variables
            LocalStarCB.Mass               = defintion.Mass;
            LocalStarCB.Radius             = defintion.Radius;
            LocalStarCB.GeeASL             = LocalStarCB.Mass * (6.674E-11 / 9.81) / Math.Pow(LocalStarCB.Radius, 2.0);
            LocalStarCB.gMagnitudeAtCenter = LocalStarCB.GeeASL * 9.81 * Math.Pow(LocalStarCB.Radius, 2.0);
            LocalStarCB.gravParameter      = LocalStarCB.gMagnitudeAtCenter;
            LocalStarCB.bodyDescription    = defintion.BodyDescription;

            //Set Science parameters
            LocalStarCB.scienceValues.InSpaceLowDataValue = LocalStarCB.scienceValues.InSpaceLowDataValue *
                                                            defintion.ScienceMultiplier;
            LocalStarCB.scienceValues.RecoveryValue = LocalStarCB.scienceValues.RecoveryValue *
                                                      defintion.ScienceMultiplier;

            //Create new Orbitdriver
            OrbitDriver NewOrbitDriver = LocalStarCB.gameObject.AddComponent <OrbitDriver>();

            //Add new OrbitDriver to Kerbol
            LocalStarCB.orbitDriver = NewOrbitDriver;

            //Set OrbitDriver parameters
            LocalStarCB.orbitDriver.name          = LocalStarCB.name;
            LocalStarCB.orbitDriver.celestialBody = LocalStarCB;
            LocalStarCB.orbitDriver.referenceBody = LocalSunCB;
            LocalStarCB.orbitDriver.updateMode    = OrbitDriver.UpdateMode.UPDATE;
            LocalStarCB.orbitDriver.QueuedUpdate  = true;

            //Create new orbit
            LocalStarCB.orbitDriver.orbit = new Orbit(defintion.Inclination, defintion.Eccentricity, defintion.SemiMajorAxis,
                                                      defintion.LAN, defintion.ArgumentOfPeriapsis, defintion.MeanAnomalyAtEpoch, defintion.Epoch, LocalSunCB);

            //Calculate SOI
            LocalStarCB.sphereOfInfluence = (LocalStarCB.orbit.semiMajorAxis *
                                             Math.Pow(LocalStarCB.Mass / LocalStarCB.orbit.referenceBody.Mass, (2.0 / 5)));
            LocalStarCB.hillSphere = LocalStarCB.orbit.semiMajorAxis * (1.0 - LocalStarCB.orbit.eccentricity) *
                                     Math.Pow((LocalStarCB.Mass / (3.0 * LocalStarCB.orbit.referenceBody.Mass)), 1.0 / 3.0);

            //Update CelestialBody
            LocalStarCB.CBUpdate();

            //Update OrbitDriver
            NewOrbitDriver.UpdateOrbit();

            //Update Star Scale
            MeshScaler.ScaleMesh(ScaledStarMeshFilter.mesh, StarRatio);

            //Update Corona Ratio
            foreach (var StarCorona in ScaledStar.GetComponentsInChildren <SunCoronas>())
            {
                var StarCoronaMeshFilter = (MeshFilter)StarCorona.GetComponent(typeof(MeshFilter));
                MeshScaler.ScaleMesh(StarCoronaMeshFilter.mesh, StarRatio);
            }
            switch (defintion.StarColor)
            {
            case PlanetColor.Blue:
                //Change to Blue Star

                ScaledStar.renderer.material.SetColor("_EmitColor0", new Color(0.357f, 0.588f, 0.405f, 1));
                ScaledStar.renderer.material.SetColor("_EmitColor1", new Color(0.139f, 0.061f, 1.0f, 1));
                ScaledStar.renderer.material.SetColor("_SunspotColor", new Color(1.0f, 1.0f, 1.0f, 1));
                ScaledStar.renderer.material.SetColor("_RimColor", new Color(0.388f, 0.636f, 1.0f, 1.0f));

                foreach (var StarCorona in ScaledStar.GetComponentsInChildren <SunCoronas>())
                {
                    StarCorona.renderer.material.mainTexture =
                        GameDatabase.Instance.GetTexture("StarSystems/Resources/BlueStarCorona", false);
                }
                break;

            case PlanetColor.Red:
                //Change to Red Star

                ScaledStar.renderer.material.SetColor("_EmitColor0", new Color(0.861f, 0.704f, 0.194f, 1));
                ScaledStar.renderer.material.SetColor("_EmitColor1", new Color(0.398f, 0.071f, 1.0f, 1));
                ScaledStar.renderer.material.SetColor("_SunspotColor", new Color(0.01f, 0.003f, 0.007f, 1));
                ScaledStar.renderer.material.SetColor("_RimColor", new Color(0.626f, 0.231f, 0.170f, 1.0f));

                foreach (var StarCorona in ScaledStar.GetComponentsInChildren <SunCoronas>())
                {
                    StarCorona.renderer.material.mainTexture =
                        GameDatabase.Instance.GetTexture("StarSystems/Resources/RedStarCorona", false);
                }
                break;
            }
        }