Beispiel #1
0
 private TerrainData(CelestialBody body)
 {
     if (body.pqsController == null)
     {
         throw new ArgumentException("Body doesn't have a PQS controller");
     }
     heightRatios = new Cell.Map <float>(MapOverlay.GridLevel, c => (float)(body.pqsController.GetSurfaceHeight(c.Position) / body.pqsController.radius));
 }
Beispiel #2
0
        /// <summary>
        /// Creates a new geodesic grid with the given number of triangle subdivisions.
        /// </summary>
        /// <param name="subdivisions">Number of times to subdivide triangles.</param>
        public GeodesicGrid(int subdivisions)
        {
            this.n         = 1 << subdivisions;
            this.positions = new Cell.Map <Vector3>(subdivisions);

            var cache = new Cell.Dictionary <Vector3d>(subdivisions);

            foreach (var cell in this)
            {
                positions[cell] = (Vector3)cell.GetPosition(cache);
            }
        }
Beispiel #3
0
        private static void export()
        {
            var sb = new StringBuilder();

            var cells = new Cell.Map <string>(MapOverlay.GridLevel);

            foreach (var cell in Cell.AtLevel(MapOverlay.GridLevel))
            {
                var pos = cell.Position;
                var lat = (float)(Math.Atan2(pos.y, Math.Sqrt(pos.x * pos.x + pos.z * pos.z)) * 180 / Math.PI);
                var lon = (float)(Math.Atan2(pos.z, pos.x) * 180 / Math.PI);
                cells[cell] = String.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3},{4},{5},", cell.Index, lat, lon, pos.x, pos.y, pos.z);
            }

            sb.AppendLine("body,resource,cellId,lat,lon,x,y,z,scanned,quantity");

            foreach (var body in FlightGlobals.Bodies)
            {
                foreach (var resource in KethaneController.ResourceDefinitions)
                {
                    foreach (var cell in Cell.AtLevel(MapOverlay.GridLevel))
                    {
                        var scanned = KethaneData.Current.Scans[resource.Resource][body.name][cell];
                        var deposit = KethaneData.Current.GetCellDeposit(resource.Resource, body, cell);

                        sb.Append(String.Format("{0},{1},", body.name, resource.Resource));
                        sb.Append(cells[cell]);
                        sb.Append(scanned ? "true" : "false");
                        if ((revealAll || scanned) && deposit != null)
                        {
                            sb.Append(String.Format(CultureInfo.InvariantCulture, ",{0}", deposit.Quantity));
                        }
                        else
                        {
                            sb.Append(",");
                        }
                        sb.AppendLine();
                    }
                }
            }

            KSP.IO.File.WriteAllText <KethaneController>(sb.ToString(), "kethane_export.csv");
        }