Exemplo n.º 1
0
        public DSFFile ParseFromBytes(byte[] dsfFileData)
        {
            this.dsfFile = new DSFFile();

            var header    = dsfFileData.SubArray(0, 8);
            var headerStr = Encoding.ASCII.GetString(header);

            if (headerStr == "XPLNEDSF")
            {
                var versionBytes = dsfFileData.SubArray(8, 4);
                int version      = BitConverter.ToInt32(versionBytes, 0);

                // Start reading atoms from position 12
                int position = 12;


                var firstAtom     = dsfFileData.SubArray(12, 8);
                var atomTypeBytes = firstAtom.SubArray(0, 4);
                var atomType      = Encoding.ASCII.GetString(EndianUtilities.Swap(atomTypeBytes));


                using (var stream = new MemoryStream(dsfFileData))
                {
                    stream.Position = position;

                    //stream.re
                }
            }
            else
            {
                log.Error("Invalid DSF File");
            }

            return(this.dsfFile);
        }
        public override void GenerateScripts(string icao, DATFile datFile, DSFFile dsfFile, TSCFile tscFile, string outputFolder, string texturesFolder)
        {
            this.icao    = icao;
            this.datFile = datFile;
            this.dsfFile = dsfFile;
            this.tscFile = tscFile;

            var maxScriptFilePath = AppDomain.CurrentDomain.BaseDirectory + "\\ScriptGenerators\\ScriptTemplates\\MaxScript.liquid";
            var maxScript         = File.ReadAllText(maxScriptFilePath);

            var scriptModel = new ScriptModel();

            this.CalculateRunways(scriptModel);
            this.CalculateDATFilePavements(scriptModel);
            this.CalculateDSFFileBuildings(scriptModel);
            this.CalculateAirportBoundary(scriptModel);

            scriptModel.AirportName  = datFile.AirportHeader.Name;
            scriptModel.AirportICAO  = datFile.AirportHeader.ICAOCode;
            scriptModel.GeneratedOn  = DateTime.UtcNow;
            scriptModel.SaveFilePath = (outputFolder + @"\Input\" + icao + ".max").Replace(@"\", @"\\");;
            scriptModel.TexturesPath = (texturesFolder + @"\").Replace(@"\", @"\\");

            Template template = Template.Parse(maxScript);

            Template.NamingConvention = new CSharpNamingConvention();
            var maxScriptFinal = template.Render(Hash.FromAnonymousObject(scriptModel));

            var outputFilePath = outputFolder + @"\Input\" + icao + ".py";

            File.WriteAllText(outputFilePath, maxScriptFinal);
        }
Exemplo n.º 3
0
 public void Convert(DSFFile dsfFile, TSCFile tscFile, TOCFile tocFile)
 {
     this.dsfFile = dsfFile;
 }
Exemplo n.º 4
0
        // https://github.com/X-Plane/xptools/tree/master/src/DSFTools
        //https://developer.x-plane.com/?article=dsf-usage-in-x-plane

        public DSFFile ParseFromString(string data)
        {
            this.dsfFile = new DSFFile();

            // We need to read Object and Polygon Defs first
            int i = 0;

            var newlineSeparator = "\n";

            foreach (var line in data.Split(new string[] { newlineSeparator }, StringSplitOptions.RemoveEmptyEntries))
            {
                // This might having Windows line endings
                var cleanLine = line.Replace("\r", "");
                //log.Debug("Line " + (i + 1));
                string[] elements = cleanLine.Split(' ');

                if (elements.Length > 0)
                {
                    switch (elements[0])
                    {
                    case "OBJECT_DEF":
                        this.ParseObjectDef(elements);
                        break;

                    case "POLYGON_DEF":
                        this.ParsePolygonDef(elements);
                        break;
                    }
                }
                i++;
            }



            int j = 0;

            foreach (var line in data.Split(new string[] { newlineSeparator }, StringSplitOptions.RemoveEmptyEntries))
            {
                var cleanLine = line.Replace("\r", "");
                //log.Debug("Line " + (j + 1));
                string[] elements = cleanLine.Split(' ');

                if (elements.Length > 0)
                {
                    switch (elements[0])
                    {
                    case "OBJECT":
                        this.ParseObjectLocation(elements);
                        break;

                    case "BEGIN_POLYGON":
                        this.ParseBeginPolygon(elements);
                        break;

                    case "BEGIN_WINDING":
                        this.ParseBeginWinding(elements);
                        break;

                    case "POLYGON_POINT":
                        this.ParsePolygonPoint(elements);
                        break;

                    case "END_WINDING":
                        this.ParseEndPolygonWinding(elements);
                        break;

                    case "END_POLYGON":
                        this.ParseEndPolygon(elements);
                        break;
                    }
                }
                j++;
            }

            return(this.dsfFile);
        }
 public override void GenerateScripts(string icao, DATFile datFile, DSFFile dsfFile, TSCFile tscFile, string outputFolder, string texturesFolder)
 {
     throw new NotImplementedException();
 }
 public abstract void GenerateScripts(string icao, DATFile datFile, DSFFile dsfFile, TSCFile tscFile, string outputFolder, string texturesFolder);