} // Disable parameterless constructor public static Model LoadModel(string path) { if (path == null) { throw new ArgumentNullException("path", "Path must not be null"); } var mdl = new Model(); Scene scene; var lmp = LumpManager.GetLumpFullPath(path); using (Stream stream = lmp.AsStream) { using (AssimpContext context = new AssimpContext()) { LumpIOSystem ioSys = new LumpIOSystem(); context.SetIOSystem(ioSys); scene = context.ImportFileFromStream(stream, PostProcessSteps.Triangulate | PostProcessSteps.FlipUVs); if (scene == null || scene.SceneFlags.HasFlag(SceneFlags.Incomplete) || scene.RootNode == null) { throw new Core.FatalError(String.Format("Error loading model \"{0}\"", path)); } } } mdl.directory = Path.GetDirectoryName(path); mdl.meshes = new List <MeshData> (scene.MeshCount); mdl.ProcessNode(scene.RootNode, scene); return(mdl); }
private void OpenRead(String pathToFile, FileIOMode fileMode) { String fileName = Path.GetFileName(pathToFile); if (LumpManager.LumpExistsFullPath(pathToFile)) { lmp = LumpManager.GetLumpFullPath(pathToFile); stream = lmp.AsStream; } }