public override void Unpack(BinaryReader reader, BSPType treeType) { Type = reader.ReadUInt32(); SplittingPlane = new Plane(); SplittingPlane.Unpack(reader); PosNode = BSPNode.ReadNode(reader, treeType); NegNode = BSPNode.ReadNode(reader, treeType); if (treeType == BSPType.Drawing) { Sphere = new Sphere(); Sphere.Unpack(reader); var numPolys = reader.ReadUInt32(); var numPortals = reader.ReadUInt32(); InPolys = new List <ushort>(); for (uint i = 0; i < numPolys; i++) { InPolys.Add(reader.ReadUInt16()); } InPortals.Unpack(reader, numPortals); } }
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); }
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); }
public static BSPTree Read(DatReader datReader, BSPType treeType) { BSPTree obj = new BSPTree(); obj.RootNode = BSPNode.Read(datReader, treeType); return(obj); }
public static BSPPortal ReadPortal(DatReader datReader, BSPType treeType) { BSPPortal obj = new BSPPortal(); obj.Type = 0x504F5254; // PORT obj.SplittingPlane = Plane.Read(datReader); obj.PosNode = BSPNode.Read(datReader, treeType); obj.NegNode = BSPNode.Read(datReader, treeType); if (treeType == BSPType.Drawing) { obj.Sphere = CSphere.Read(datReader); uint numPolys = datReader.ReadUInt32(); uint numPortals = datReader.ReadUInt32(); for (uint i = 0; i < numPolys; i++) { obj.InPolys.Add(datReader.ReadUInt16()); } for (uint i = 0; i < numPortals; i++) { obj.InPortals.Add(PortalPoly.Read(datReader)); } } return(obj); }
} = new List <ushort>(); // List of PolygonIds public static BSPNode Read(DatReader datReader, BSPType treeType) { BSPNode obj = new BSPNode(); obj.Type = datReader.ReadUInt32(); switch (obj.Type) { case PORT: return(BSPPortal.ReadPortal(datReader, treeType)); case LEAF: return(BSPLeaf.ReadLeaf(datReader, treeType)); } obj.SplittingPlane = Plane.Read(datReader); switch (obj.Type) { case BPnn: case BPIn: obj.PosNode = BSPNode.Read(datReader, treeType); break; case BpIN: case BpnN: obj.NegNode = BSPNode.Read(datReader, treeType); break; case BPIN: case BPnN: obj.PosNode = BSPNode.Read(datReader, treeType); obj.NegNode = BSPNode.Read(datReader, treeType); break; } if (treeType == BSPType.Cell) { return(obj); } obj.Sphere = CSphere.Read(datReader); if (treeType == BSPType.Physics) { return(obj); } uint numPolys = datReader.ReadUInt32(); for (uint i = 0; i < numPolys; i++) { obj.InPolys.Add(datReader.ReadUInt16()); } return(obj); }
public virtual void Unpack(BinaryReader reader, BSPType treeType) { Type = Encoding.ASCII.GetString(reader.ReadBytes(4)).Reverse(); switch (Type) { // These types will unpack the data completely, in their own classes case "PORT": case "LEAF": throw new Exception(); } SplittingPlane = new Plane(); SplittingPlane.Unpack(reader); switch (Type) { case "BPnn": case "BPIn": PosNode = BSPNode.ReadNode(reader, treeType); break; case "BpIN": case "BpnN": NegNode = BSPNode.ReadNode(reader, treeType); break; case "BPIN": case "BPnN": PosNode = BSPNode.ReadNode(reader, treeType); NegNode = BSPNode.ReadNode(reader, treeType); break; } if (treeType == BSPType.Cell) { return; } Sphere = new Sphere(); Sphere.Unpack(reader); if (treeType == BSPType.Physics) { return; } InPolys = new List <ushort>(); uint numPolys = reader.ReadUInt32(); for (uint i = 0; i < numPolys; i++) { InPolys.Add(reader.ReadUInt16()); } }
public void Unpack(BinaryReader reader, BSPType treeType) { RootNode = BSPNode.ReadNode(reader, treeType); }