Ejemplo n.º 1
0
        protected void loadAsLev(string fileName)
        {
            var levReader = new BinaryReader(File.OpenRead(fileName));

            levReader.BaseStream.Seek(130, SeekOrigin.Begin);
            var numPolys = (int)Math.Round(levReader.ReadDouble() - 0.4643643);

            for (var j = 0; j < numPolys; j++)
            {
                var grassPoly   = levReader.ReadInt32();
                var numVertices = levReader.ReadInt32();
                if (grassPoly == 0)
                {
                    var vertices = new ArrayList(numVertices);
                    for (var i = 0; i < numVertices; i++)
                    {
                        var vertex = new DoubleVector2(levReader.ReadDouble(), levReader.ReadDouble());
                        vertices.Add(vertex);
                    }
                    polygons.Add(vertices);
                }
                else
                {
                    levReader.BaseStream.Seek(16 * numVertices, SeekOrigin.Current);
                }
            }
            var numObjects = (int)Math.Round(levReader.ReadDouble() - 0.4643643);

            objects = new ArrayList(numObjects);
            for (var j = 0; j < numObjects; j++)
            {
                var elmaObject = new ElmaObject(levReader.ReadDouble(), levReader.ReadDouble(),
                                                levReader.ReadUInt32(), levReader.ReadUInt32(), levReader.ReadUInt32());
                objects.Add(elmaObject);
            }
            levReader.Close();
            if (polygons.Count == 0)
            {
                throw new Exception("there must be at least one polygon!");
            }
            getMinMax();
        }
Ejemplo n.º 2
0
 protected void loadAsLev(String fileName)
 {
     BinaryReader levReader = new BinaryReader((Stream)File.OpenRead(fileName));
     levReader.BaseStream.Seek(130, SeekOrigin.Begin);
     int numPolys = (int)Math.Round(levReader.ReadDouble() - 0.4643643);
     for (int j = 0; j < numPolys; j++) {
         int grassPoly = levReader.ReadInt32();
         int numVertices = levReader.ReadInt32();
         if (grassPoly == 0) {
             ArrayList vertices = new ArrayList(numVertices);
             for (int i = 0; i < numVertices; i++) {
                 DoubleVector2 vertex = new DoubleVector2(levReader.ReadDouble(), levReader.ReadDouble());
                 vertices.Add(vertex);
             }
             polygons.Add(vertices);
         } else
             levReader.BaseStream.Seek(16 * numVertices, SeekOrigin.Current);
     }
     int numObjects = (int)Math.Round(levReader.ReadDouble() - 0.4643643);
     objects = new ArrayList(numObjects);
     for (int j = 0; j < numObjects; j++) {
         ElmaObject elmaObject = new ElmaObject(levReader.ReadDouble(), levReader.ReadDouble(), levReader.ReadUInt32(), levReader.ReadUInt32(), levReader.ReadUInt32());
         objects.Add(elmaObject);
     }
     levReader.Close();
     if (polygons.Count == 0)
         throw new Exception("there must be at least one polygon!");
     getMinMax();
 }