public IReadOnlyList<IModel> Load(string name, IFileSystem fileSystem, Scene scene, BinaryReader reader, bool computeCRC) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } //Check if we can actually load this //TODO: because BSP files don't have a separate identifier, this will fail on invalid BSP versions //Should remove this once the other formats can be loaded if (!BSPLoader.IsBSPFile(reader)) { return null; } var loader = new BSPLoader(reader); var bspFile = loader.ReadBSPFile(); uint crc = 0; if (computeCRC) { crc = loader.ComputeCRC(); } var hull0 = MakeHull0(bspFile); var models = new BSPModel[bspFile.Models.Count]; models[0] = new BSPModel(name, crc, bspFile, bspFile.Models[0], hull0); //add all of its submodels //First submodel (0) is the world for (var i = 1; i < bspFile.Models.Count; ++i) { models[i] = new BSPModel($"{_bspModelNamePrefix}{i}", crc, bspFile, bspFile.Models[i], hull0); } if (scene != null) { foreach (var model in models) { model.ResourceContainer = new BSPModelResourceContainer(scene, model); scene.AddContainer(model.ResourceContainer); } } return models; }
public IModel Load(string name, IFileSystem fileSystem, BinaryReader reader, Delegates.AddModel addModelCallback, bool computeCRC) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } //Check if we can actually load this //TODO: because BSP files don't have a separate identifier, this will fail on invalid BSP versions //Should remove this once the other formats can be loaded if (!BSPLoader.IsBSPFile(reader)) { return(null); } var loader = new BSPLoader(reader); var bspFile = loader.ReadBSPFile(); uint crc = 0; if (computeCRC) { crc = loader.ComputeCRC(); } var hull0 = MakeHull0(bspFile); //add all of its submodels //First submodel (0) is the world for (var i = 1; i < bspFile.Models.Count; ++i) { var subModelName = $"{_bspModelNamePrefix}{i}"; addModelCallback(subModelName, new BSPModel(subModelName, crc, bspFile, bspFile.Models[i], hull0)); } return(new BSPModel(name, crc, bspFile, bspFile.Models[0], hull0)); }