Пример #1
0
        public static BSPNode ReadNode(BinaryReader reader, BSPType treeType)
        {
            // We peek forward to get the type, then revert our position.
            var type = Encoding.ASCII.GetString(reader.ReadBytes(4)).Reverse();

            reader.BaseStream.Position -= 4;

            BSPNode node;

            switch (type)
            {
            case "PORT":
                node = new BSPPortal();
                break;

            case "LEAF":
                node = new BSPLeaf();
                break;

            case "BPnn":
            case "BPIn":
            case "BpIN":
            case "BpnN":
            case "BPIN":
            case "BPnN":
            default:
                node = new BSPNode();
                break;
            }

            node.Unpack(reader, treeType);

            return(node);
        }
Пример #2
0
        public static BSPNode ReadNode(BinaryReader reader, BSPType treeType)
        {
            // We peek forward to get the type, then revert our position.
            var type = reader.ReadUInt32();

            reader.BaseStream.Position -= 4;

            BSPNode node;

            switch (type)
            {
            case PORT:
                node = new BSPPortal();
                break;

            case LEAF:
                node = new BSPLeaf();
                break;

            case BPnn:
            case BPIn:
            case BpIN:
            case BpnN:
            case BPIN:
            case BPnN:
            default:
                node = new BSPNode();
                break;
            }

            node.Unpack(reader, treeType);

            return(node);
        }