Пример #1
0
        public void Parse()
        {
            while (Reader.BaseStream.Position < Reader.BaseStream.Length)
            {
                string sectionName   = Encoding.UTF8.GetString(Reader.ReadBytes(4));
                int    sectionLength = Reader.ReadInt32();
                byte[] sectionBytes  = Reader.ReadBytes(sectionLength);

                BinaryReader sectionReader = new BinaryReader(new MemoryStream(sectionBytes));

                switch (sectionName)
                {
                case "VERS":
                    // TODO: Implement parsing of VERS section
                    break;

                case "TEXT":
                    // TODO: Implement parsing of TEXT section
                    break;

                case "SMTL":
                    // TODO: Implement parsing of SMTL section
                    break;

                case "BONE":
                    Bones = BoneReader.ReadAllBones(sectionReader);
                    break;

                case "ANIM":
                    // TODO: Implement parsing of ANIM section
                    break;

                case "MESH":
                    Vertices = VertexReader.ReadAllVertices(sectionReader);
                    Polygons = PolygonReader.ReadAllPolygons(sectionReader);
                    break;

                case "FANM":
                    // TODO: Implement parsing of FANM section
                    break;

                case "FRAM":
                    // TODO: Implement parsing of FRAM section
                    break;

                case "MOTI":
                    Motions = MotionReader.ReadAllMotions(sectionReader);
                    break;

                case "COLL":
                    CollisionBoxes = CollisionBoxReader.ReadAllCollisionBoxes(sectionReader);
                    break;
                }

                sectionReader.Close();
            }
        }
Пример #2
0
        private static IShapeCollection ExtractPolygons(System.IO.BinaryReader shpReader, ShxReader shxReader, List <Indexing.ShpIndex> indexes)
        {
            List <Polygon> geometries = new List <Polygon>(indexes.Count);

            for (int i = 0; i < indexes.Count; i++)
            {
                int offset, contentLength;

                shxReader.GetRecord(indexes[i].RecordNumber, out offset, out contentLength);

                geometries[i] = PolygonReader.Read(shpReader, offset, contentLength);
            }

            return(new ShapeCollection <Polygon>(geometries));
        }