Beispiel #1
0
 public TerrainImporter(MftData terrainMft, MftData vtMft, MftData[] otherMfts)
 {
     this.terrainMft = terrainMft;
     this.vtMft      = vtMft;
     this.otherMfts  = otherMfts;
     this.done       = false;
 }
        public static MftData FromFile(string mftFilePath)
        {
            var result = new MftData();

            result.Folder = Path.GetDirectoryName(mftFilePath);

            var xml = new XmlDocument();

            xml.LoadXml(File.ReadAllText(mftFilePath));
            XmlNamespaceManager ns = new XmlNamespaceManager(xml.NameTable);

            ns.AddNamespace("ns", xml.DocumentElement.NamespaceURI);

            result.DatasetName    = xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database", ns).Attributes["name"].Value;
            result.TerrainExtentX = double.Parse(xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database/ns:Coverage/ns:Extent/ns:x", ns).InnerText);
            result.TerrainExtentY = double.Parse(xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database/ns:Coverage/ns:Extent/ns:y", ns).InnerText);
            result.TerrainOriginX = double.Parse(xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database/ns:Coverage/ns:Origin/ns:x", ns).InnerText);
            result.TerrainOriginY = double.Parse(xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database/ns:Coverage/ns:Origin/ns:y", ns).InnerText);
            result.TerrainRefLat  = /*0;*/ double.Parse(xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database/ns:ProjectedCoordSys/ns:FlatEarth/ns:OriginLatitude", ns).InnerText);
            result.TerrainRefLon  = /*0;*/ double.Parse(xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database/ns:ProjectedCoordSys/ns:FlatEarth/ns:OriginLongitude", ns).InnerText);
            try
            {
                result.NumTileTexels = int.Parse(xml.SelectSingleNode("/ns:MetaFlightRoot/ns:Database/ns:VirtualTextureDataset/ns:NumTileTexels", ns).InnerText);
            }
            catch (System.Exception e) { }

            result.LevelsData = new Dictionary <int, LevelData>();
            int number = 0;

            foreach (XmlNode gridLevel in xml.SelectNodes("/ns:MetaFlightRoot/ns:Database/ns:GridStructure/ns:GridLevel", ns))
            {
                int rows = 1;
                for (int i = 0; i <= number; i++)
                {
                    rows *= int.Parse(xml.SelectNodes("/ns:MetaFlightRoot/ns:Database/ns:GridStructure/ns:GridLevel/ns:NumRowDivisions", ns)[i].InnerText);
                }

                int columns = 1;
                for (int i = 0; i <= number; i++)
                {
                    columns *= int.Parse(xml.SelectNodes("/ns:MetaFlightRoot/ns:Database/ns:GridStructure/ns:GridLevel/ns:NumColDivisions", ns)[i].InnerText);
                }

                result.LevelsData.Add(number, new LevelData()
                {
                    Number  = number++,
                    Rows    = rows,
                    Columns = columns
                });
            }

            return(result);
        }
Beispiel #3
0
        private void LoadLayerPart(MftData layerMft, PostProcessingFunc postProcessing = null)
        {
            string fltFile = GetFltPath(layerMft);

            if (File.Exists(fltFile))
            {
                var result = LoadFltToGameObject(fltFile);

                result.name = Path.GetFileName(fltFile);
                PositionTerrainPart(result);

                if (postProcessing != null)
                {
                    postProcessing(result);
                }

                AddColliders(result);
            }
        }
Beispiel #4
0
 private string GetFltPath(MftData mft)
 {
     return(Path.Combine(mft.Folder, string.Format(@"v{1}\r{3}\{0}-v{1}-c{2}-r{3}.flt", mft.DatasetName, PadNumber(curPartLevel, 2), PadNumber(curPartCol, 3), PadNumber(curPartRow, 3))));
 }