Пример #1
0
        private void ParseBSPTree(int offset = 0)
        {
            while (true)
            {
                int blockSize;
                reader.SetPtr(offset);
                BspTreeNodeType blockType = (BspTreeNodeType)reader.PeekInt();

                switch (blockType)
                {
                case BspTreeNodeType.EOF:
                    break;

                case BspTreeNodeType.DefinePoints:
                    blockSize = points.Read(reader);
                    offset    = offset + blockSize;
                    continue;

                case BspTreeNodeType.UntexturedPolygon:
                    blockSize = TranslateFlatPolygon();
                    offset    = offset + blockSize;
                    continue;

                case BspTreeNodeType.TexturedPolygon:
                    blockSize = TranslateTexturedPolygon();
                    offset    = offset + blockSize;
                    continue;

                case BspTreeNodeType.SortNormal:
                    InterpretSortNormalBlock(offset);
                    break;

                case BspTreeNodeType.BoundingBox:
                    blockSize = new BlockHeader(reader).size;
                    offset    = offset + blockSize;
                    continue;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                break;
            }
        }