public override bool Load(string matId, List <Material> materials, Dictionary <string, int> matMap, out string err) { err = null; if (!m_Stream.CanRead) { err = "WARN: Material stream in error state."; return(false); } try { using (StreamReader matIStream = new StreamReader(m_Stream)) { TinyObjLoader.LoadMtl(matMap, materials, matIStream, out string warning); if (!string.IsNullOrWhiteSpace(warning)) { err = warning; } return(true); } } catch (IOException ex) { err = string.Format("WARN: Material file not ready: {0}", ex.Message); return(false); } }
public override bool Load(string matId, List <Material> materials, Dictionary <string, int> matMap, out string err) { string filepath; err = null; if (!string.IsNullOrWhiteSpace(m_mtlBaseDir)) { filepath = m_mtlBaseDir + matId; } else { filepath = matId; } try { using (StreamReader matIStream = new StreamReader(filepath)) { TinyObjLoader.LoadMtl(matMap, materials, matIStream, out string warning); if (!string.IsNullOrWhiteSpace(warning)) { err = warning; } return(true); } } catch (IOException ex) { err = string.Format("WARN: Material file [ {0} ] not found: {1}", filepath, ex.Message); return(false); } }