コード例 #1
0
ファイル: Utils.cs プロジェクト: yadenisyur/CollisionFX
        public static string GetCurrentBiomeName(Vessel vessel)
        {
            CBAttributeMapSO biomeMap = FlightGlobals.currentMainBody.BiomeMap;

            CBAttributeMapSO.MapAttribute mapAttribute = biomeMap.GetAtt(vessel.latitude * Mathf.Deg2Rad, vessel.longitude * Mathf.Deg2Rad);
            return(mapAttribute.name);
        }
コード例 #2
0
ファイル: KFDustFXUtils.cs プロジェクト: damerell/KF_plugin
        /// <summary>Gets the biome of the current colliding part.</summary>
        /// <param name="lat">Latitude of the vessel.</param>
        /// <param name="lon">Longitude of the vessel.</param>
        /// <returns>The name of the biome it finds.</returns>
        static string GetCurrentBiomeName(double lat, double lon)
        {
            CBAttributeMapSO biomeMap = FlightGlobals.currentMainBody.BiomeMap;

            CBAttributeMapSO.MapAttribute mapAttribute = biomeMap.GetAtt(lat * Mathf.Deg2Rad, lon * Mathf.Deg2Rad);
            string result = mapAttribute.name.Replace(' ', '_');

            return(result);
        }
コード例 #3
0
 protected override void Inspect(Vessel vessel)
 {
     if (vessel != null)
     {
         double        lat  = vessel.latitude * Math.PI / 180d;
         double        lon  = vessel.longitude * Math.PI / 180d;
         CelestialBody body = vessel.mainBody;
         if (body != null)
         {
             CBAttributeMapSO biomeMap = body.BiomeMap;
             if (biomeMap != null)
             {
                 mapAttribute = biomeMap.GetAtt(lat, lon);
             }
         }
     }
 }
コード例 #4
0
        private void prepareBiome()
        {
            CBAttributeMapSO.MapAttribute mapAttribute;

            try
            {
                Vessel           vessel   = FlightGlobals.ActiveVessel;
                CBAttributeMapSO BiomeMap = vessel.mainBody.BiomeMap;
                double           lat      = vessel.latitude * Math.PI / 180d;
                double           lon      = vessel.longitude * Math.PI / 180d;
                mapAttribute = BiomeMap.GetAtt(lat, lon);
            }
            catch (NullReferenceException)
            {
                mapAttribute      = new CBAttributeMapSO.MapAttribute();
                mapAttribute.name = "N/A";
            }

            this.biome.value = mapAttribute.name;
        }
コード例 #5
0
        public static CBAttributeMapSO.MapAttribute GetBiome(this Vessel vessel)
        {
            CBAttributeMapSO.MapAttribute mapAttribute;

            try
            {
                CBAttributeMapSO BiomeMap = vessel.mainBody.BiomeMap;

                double lat = vessel.latitude * Math.PI / 180d;
                double lon = vessel.longitude * Math.PI / 180d;

                mapAttribute = BiomeMap.GetAtt(lat, lon);

                /*
                 * lon -= Math.PI / 2d;
                 *
                 * if (lon < 0d)
                 * {
                 *      lon += 2d * Math.PI;
                 * }
                 *
                 * float v = (float)(lat / Math.PI) + 0.5f;
                 * float u = (float)(lon / (2d * Math.PI));
                 *
                 * Color pixelBilinear = BiomeMap.Map.GetPixelBilinear(u, v);
                 * mapAttribute = BiomeMap.defaultAttribute;
                 *
                 * if (BiomeMap.Map != null)
                 * {
                 *      if (BiomeMap.exactSearch)
                 *      {
                 *              for (int i = 0; i < BiomeMap.Attributes.Length; ++i)
                 *              {
                 *                      if (pixelBilinear == BiomeMap.Attributes[i].mapColor)
                 *                      {
                 *                              mapAttribute = BiomeMap.Attributes[i];
                 *                      }
                 *              }
                 *      }
                 *      else
                 *      {
                 *              float zero = 0;
                 *              float num = 1 / zero;
                 *              for (int j = 0; j < BiomeMap.Attributes.Length; ++j)
                 *              {
                 *                      Color mapColor = BiomeMap.Attributes[j].mapColor;
                 *                      float sqrMagnitude = ((Vector4)(mapColor - pixelBilinear)).sqrMagnitude;
                 *                      if (sqrMagnitude < num)
                 *                      {
                 *                              bool testCase = true;
                 *                              if (BiomeMap.nonExactThreshold != -1)
                 *                              {
                 *                                      testCase = (sqrMagnitude < BiomeMap.nonExactThreshold);
                 *                              }
                 *                              if (testCase)
                 *                              {
                 *                                      mapAttribute = BiomeMap.Attributes[j];
                 *                                      num = sqrMagnitude;
                 *                              }
                 *                      }
                 *              }
                 *      }
                 * }
                 */
            }
            catch (NullReferenceException)
            {
                mapAttribute      = new CBAttributeMapSO.MapAttribute();
                mapAttribute.name = "N/A";
            }

            return(mapAttribute);
        }