public override void OnVertexBuildHeight(PQS.VertexBuildData data)
        {
            double scalar = data.vertHeight - sphere.radius;

            scalar *= deformationBalance;
            scalar += sphere.radius;
            scalar *= tiling;
            Vector3d position = data.directionFromCenter * scalar;

            // Now that we have the position, we need to sample the MapSO
            // thrice, once for each plane.
            float x = tiledMap.GetPixelFloat(position.y, position.z);
            float y = tiledMap.GetPixelFloat(position.x, position.z);
            float z = tiledMap.GetPixelFloat(position.x, position.y);

            // Next, we need to process the normal (directionFromCenter).
            var blend = data.directionFromCenter;

            blend.x = Math.Pow(Math.Abs(blend.x), smoothness);
            blend.y = Math.Pow(Math.Abs(blend.y), smoothness);
            blend.z = Math.Pow(Math.Abs(blend.z), smoothness);
            blend  /= (blend.x + blend.y + blend.z);

            double height = (blend.x * x) + (blend.y * y) + (blend.z * z);

            if (scaleByRadius)
            {
                height *= sphere.radius;
            }

            data.vertHeight += deformity * height;
        }
        public override void OnVertexBuildHeight(PQS.VertexBuildData data)
        {
            if (useMap)
            {
                if (map.GetPixelFloat(data.u, data.v) == cutoff)
                {
                    //Get active range
                    if (data.vertHeight > finalStart && data.vertHeight < finalEnd)
                    {
                        //Current altitude to altitude ASL
                        var altitude = data.vertHeight - sphere.radius;

                        //Altitude ASL -> position in range
                        var position = altitude / endingAltitude;

                        //To inversely exponential curvepoint
                        var FloatCurve = (Math.Pow(position, 2)) + (-2 * position) + 1;

                        //Adapt strength to position on curve
                        var strengthConv = FloatCurve * (1 / strength);

                        //Get altitude fraction
                        var NewAlt = Math.Pow(altitude, strengthConv);

                        //Finalize
                        data.vertHeight = (altitude / NewAlt) + sphere.radius + offset;

                        //Ninja'd
                    }
                }
            }
            else
            {
                //Get active range
                if (data.vertHeight > finalStart && data.vertHeight < finalEnd)
                {
                    //Current altitude to altitude ASL
                    var altitude = data.vertHeight - sphere.radius;

                    //Altitude ASL -> position in range
                    var position = altitude / endingAltitude;

                    //To inversely exponential curvepoint
                    var FloatCurve = (Math.Pow(position, 2)) + (-2 * position) + 1;

                    //Adapt strength to position on curve
                    var strengthConv = FloatCurve * (1 / strength);

                    //Get altitude fraction
                    var NewAlt = Math.Pow(altitude, strengthConv);

                    //Finalize
                    data.vertHeight = (altitude / NewAlt) + sphere.radius + offset;

                    //Ninja'd again
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Update the heat
        /// </summary>
        /// <returns></returns>
        private void Update()
        {
            if (!FlightGlobals.ready)
            {
                return;
            }

            // Simple counter
            if (heatPosition > 0f)
            {
                heatPosition -= Time.deltaTime;
                return;
            }

            // We got past the counter - update time

            // Get all vessels
            List <Vessel> vessels = FlightGlobals.Vessels.FindAll(v => v.mainBody == _body);

            // Loop through them
            foreach (Vessel vessel in vessels)
            {
                Double altitude =
                    altitudeCurve.Evaluate((Single)Vector3d.Distance(vessel.transform.position,
                                                                     _body.transform.position));
                Double latitude  = latitudeCurve.Evaluate((Single)vessel.latitude);
                Double longitude = longitudeCurve.Evaluate((Single)vessel.longitude);

                Double heat = altitude * latitude * longitude * heatRate;
                if (heatMap)
                {
                    // Let's avoid divisions
                    // 1f / 360f = 0.002777778f
                    // 1f / 180f = 0.005555556f
                    // The accuracy loss here is insignificant, but it makes this line hundreds of times faster.
                    // heat *= heatMap.GetPixelFloat((longitude + 180) / 360f, (latitude + 90) / 180f);
                    heat *= heatMap.GetPixelFloat((longitude + 180) * 0.002777778f, (latitude + 90) * 0.005555556f);
                }

                foreach (Part part in vessel.Parts)
                {
                    // Scale the heat by the time between updates
                    part.temperature += heat * invertedInterval;
                }
            }

            // Reset the timer
            heatPosition = heatInterval;
        }
Beispiel #4
0
        void OnCalculateBackgroundRadiationTemperature(ModularFlightIntegrator flightIntegrator, ModularScatter system)
        {
            List <GameObject> scatters = system.scatterObjects;
            Vessel            vessel   = flightIntegrator.Vessel;
            CelestialBody     _body    = system.body;

            if (_body != vessel.mainBody)
            {
                return;
            }

            for (Int32 i = 0; i < scatters.Count; i++)
            {
                GameObject scatter = scatters[i];

                if (scatter?.activeSelf != true)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(biomeName))
                {
                    String biome = ScienceUtil.GetExperimentBiome(_body, vessel.latitude, vessel.longitude);

                    if (biomeName != biome)
                    {
                        continue;
                    }
                }

                Single distance = distanceCurve.Evaluate(Vector3.Distance(vessel.transform.position, scatter.transform.position));

                Double altitude  = altitudeCurve.Evaluate((Single)Vector3d.Distance(vessel.transform.position, _body.transform.position));
                Double latitude  = latitudeCurve.Evaluate((Single)vessel.latitude);
                Double longitude = longitudeCurve.Evaluate((Single)vessel.longitude);

                Double newTemp = altitude * latitude * longitude * ambientTemp;

                if (heatMap)
                {
                    Double x = ((450 - vessel.longitude) % 360) / 360.0;
                    Double y = (vessel.latitude + 90) / 180.0;
                    Double m = heatMap.GetPixelFloat(x, y);
                    newTemp *= m;
                }

                KopernicusHeatManager.NewTemp(newTemp, sumTemp);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Update the heat
        /// </summary>
        /// <returns></returns>
        private void Update()
        {
            // Check for an active vessel
            if (!FlightGlobals.ActiveVessel || FlightGlobals.ActiveVessel.packed)
            {
                return;
            }

            // Check if the vessel is near the body
            if (FlightGlobals.currentMainBody != _body)
            {
                return;
            }

            // Simple counter
            if (_heatPosition > 0f)
            {
                _heatPosition -= Time.deltaTime;
                return;
            }

            // We got past the counter - update time
            Double altitude =
                altitudeCurve.Evaluate((Single)Vector3d.Distance(FlightGlobals.ActiveVessel.transform.position,
                                                                 _body.transform.position));
            Double latitude  = latitudeCurve.Evaluate((Single)FlightGlobals.ActiveVessel.latitude);
            Double longitude = longitudeCurve.Evaluate((Single)FlightGlobals.ActiveVessel.longitude);

            Double heat = altitude * latitude * longitude * heatRate;

            if (heatMap)
            {
                const Single FULL_CIRCLE = 1f / 360f;
                const Single HALF_CIRCLE = 1f / 180f;

                heat *= heatMap.GetPixelFloat((longitude + 180) * FULL_CIRCLE, (latitude + 90) * HALF_CIRCLE);
            }

            foreach (Part part in FlightGlobals.ActiveVessel.Parts)
            {
                part.temperature += heat;
            }

            // Reset the timer
            _heatPosition = heatInterval;
        }
 public override void OnVertexBuildHeight(PQS.VertexBuildData data)
 {
     if (addSimplexNoise == true && smoothHeightMap == true)
     {
         data.vertHeight = data.vertHeight + (simplex1.noise(data.directionFromCenter) * deformity) + (simplex2.noise(data.directionFromCenter) * smoothDeformity) + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v));
     }
     if (addSimplexNoise == true && smoothHeightMap == false)
     {
         data.vertHeight = data.vertHeight + (simplex1.noise(data.directionFromCenter) * deformity) + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v));
     }
     if (addSimplexNoise == false && smoothHeightMap == true)
     {
         data.vertHeight = data.vertHeight + (simplex2.noise(data.directionFromCenter) * smoothDeformity) + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v));
     }
     if (addSimplexNoise == false && smoothHeightMap == false)
     {
         data.vertHeight = data.vertHeight + offset + (heightDeformity * heightMap.GetPixelFloat(data.u, data.v));
     }
 }
Beispiel #7
0
            /// <summary>
            /// Update the heat
            /// </summary>
            /// <returns></returns>
            private IEnumerator <WaitForSeconds> Worker()
            {
                while (true)
                {
                    if (!FlightGlobals.ready)
                    {
                        yield return(new WaitForSeconds(HeatInterval));

                        continue;
                    }

                    // Get all vessels
                    List <Vessel> vessels = FlightGlobals.Vessels.FindAll(v => v.mainBody == _body);

                    // Loop through them
                    foreach (Vessel vessel in vessels)
                    {
                        Double altitude =
                            AltitudeCurve.Evaluate((Single)Vector3d.Distance(vessel.transform.position, _body.transform.position));
                        Double latitude  = LatitudeCurve.Evaluate((Single)vessel.latitude);
                        Double longitude = LongitudeCurve.Evaluate((Single)vessel.longitude);

                        Double heat = altitude * latitude * longitude * HeatRate;
                        if (HeatMap != null)
                        {
                            heat *= HeatMap.GetPixelFloat((longitude + 180) / 360f, (latitude + 90) / 180f);
                        }
                        foreach (Part part in vessel.Parts)
                        {
                            part.temperature += heat;
                        }
                    }

                    // Wait
                    yield return(new WaitForSeconds(HeatInterval));
                }
                // ReSharper disable once IteratorNeverReturns
            }
        void OnCalculateBackgroundRadiationTemperature(ModularFlightIntegrator flightIntegrator)
        {
            Vessel        vessel = flightIntegrator?.Vessel;
            CelestialBody _body  = GetComponent <CelestialBody>();

            if (_body != vessel.mainBody)
            {
                return;
            }

            if (!string.IsNullOrEmpty(biomeName))
            {
                String biome = ScienceUtil.GetExperimentBiome(_body, vessel.latitude, vessel.longitude);

                if (biomeName != biome)
                {
                    return;
                }
            }

            Double altitude  = altitudeCurve.Evaluate((Single)Vector3d.Distance(vessel.transform.position, _body.transform.position));
            Double latitude  = latitudeCurve.Evaluate((Single)vessel.latitude);
            Double longitude = longitudeCurve.Evaluate((Single)vessel.longitude);

            Double newTemp = altitude * latitude * longitude * ambientTemp;

            if (heatMap)
            {
                Double x = ((450 - vessel.longitude) % 360) / 360.0;
                Double y = (vessel.latitude + 90) / 180.0;
                Double m = heatMap.GetPixelFloat(x, y);
                newTemp *= m;
            }

            KopernicusHeatManager.NewTemp(newTemp, sumTemp);
        }
 /// <summary>
 /// Called when the parent sphere builds it's height
 /// </summary>
 public override void OnVertexBuildHeight(VertexBuildData data)
 {
     data.vertHeight += heightMapOffset + heightDeformity * heightMap.GetPixelFloat(data.u, data.v);
 }