public void NewMaterial(ReadOnlySpan <string> name) { _materials.Add(_currentMaterial = new ObjMaterial(name[0])); }
/// <summary> /// Parses and loads a line from an OBJ file. /// Currently only supports V, VT, F and MTLLIB prefixes /// </summary> private void processLine(string line) { string[] parts = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 0) { ObjMaterial CurrentMaterial = currentMaterial(); ObjColor c = new ObjColor(); switch (parts[0].Trim()) { case "d": CurrentMaterial.Dissolve = float.Parse(parts[1]); break; case "illum": CurrentMaterial.IlluminationModel = int.Parse(parts[1]); break; case "Ka": c.LoadFromStringArray(parts); CurrentMaterial.AmbientReflectivity = c; break; case "Kd": c.LoadFromStringArray(parts); CurrentMaterial.DiffuseReflectivity = c; break; case "Ks": c.LoadFromStringArray(parts); CurrentMaterial.SpecularReflectivity = c; break; case "Ke": c.LoadFromStringArray(parts); CurrentMaterial.EmissiveCoefficient = c; break; case "map_Kd": CurrentMaterial.DiffuseTextureFileName = parts[1]; break; case "Ni": CurrentMaterial.OpticalDensity = float.Parse(parts[1]); break; case "Ns": CurrentMaterial.SpecularExponent = float.Parse(parts[1]); break; case "newmtl": CurrentMaterial = new ObjMaterial(); CurrentMaterial.Name = parts[1]; MaterialList.Add(CurrentMaterial); break; case "Tf": c.LoadFromStringArray(parts); CurrentMaterial.TransmissionFilter = c; break; } } }