Exemplo n.º 1
0
        public Render(string outputFilePath, Program program)
        {
            this._xBounds = new Vector2(float.PositiveInfinity, float.NegativeInfinity);
            this._yBounds = new Vector2(float.PositiveInfinity, float.NegativeInfinity);
            this._program = program;
            using (OutputLineReader reader = new OutputLineReader("#", new StreamReader(outputFilePath))) {
                if (!reader.NextLine(out string version))
                {
                    throw new FormatException("Expected version line!");
                }
                switch (version)
                {
                case "flo v1.0.2":
                    this.ParseFLO_v1_0_2(reader);
                    break;

                case "flo v1.0.1":
                    this.ParseFLO_v1_0_1(reader);
                    break;

                case "flo v1.0.0":
                    this.ParseFLO_v1_0_0(reader);
                    break;

                case "flod v1.0.0":
                    this.ParseFLOD_v1_0_0(reader);
                    break;

                default:
                    throw new FormatException("File format was not recognized!");
                }
            }
            this.ShowFrame(0);
        }
Exemplo n.º 2
0
 private void ParseFLO_v1_0_2(OutputLineReader reader)
 {
     if (!reader.NextLine(out string shapeNumberLine))
     {
         throw new FormatException("Expected shape number line!");
     }
     if (!int.TryParse(shapeNumberLine, out int shapeNumber))
     {
         throw new FormatException("Shape number line could not be parsed to an integer!");
     }
     this._renderObjects = new List <RenderObject>();
     for (int i = 0; i < shapeNumber; i++)
     {
         if (!reader.NextLine(out string shapeLine))
         {
             throw new FormatException("Expected shape line!");
         }
         this._renderObjects.Add(this._program.CreateRenderObject(shapeLine));
     }
     this._frameTimes = new List <float>();
     List <Vector3>[] positions = new List <Vector3> [this._renderObjects.Count];
     for (int i = 0; i < this._renderObjects.Count; i++)
     {
         positions[i] = new List <Vector3>();
     }
     while (reader.NextLine(out string timeLine))
     {
         if (!float.TryParse(timeLine, NumberStyles.Any, CultureInfo.InvariantCulture, out float time))
         {
             break;
         }
         this._frameTimes.Add(time);
         foreach (List <Vector3> positionList in positions)
         {
             if (!reader.NextLine(out string positionLine))
             {
                 throw new FormatException("Incorrect number of position lines!");
             }
             Vector2 position = this._program.ParseVector3FromCSV(positionLine);
             this._xBounds = new Vector2(Mathf.Min(this._xBounds.x, position.x), Mathf.Max(this._xBounds.y, position.x));
             this._yBounds = new Vector2(Mathf.Min(this._yBounds.x, position.y), Mathf.Max(this._yBounds.y, position.y));
             positionList.Add(position);
         }
         ++this._maxFrame;
     }
     for (int i = 0; i < this._renderObjects.Count; i++)
     {
         this._renderObjects[i].AddPositions(positions[i]);
     }
 }
Exemplo n.º 3
0
 private void ParseFLOD_v1_0_0(OutputLineReader reader)
 {
     throw new NotImplementedException("Parsing of flounder output debug file version 1.0.0 is unsupported!");
 }