protected override void Parse(string keyword, string data) { switch (keyword) { case "newmtl": Materials.Add(_current = new Material(data)); break; case "Kd": _current.Kd = data.ToVect3f(); break; case "Ka": _current.Ka = data.ToVect3f(); break; case "Ks": _current.Ks = data.ToVect3f(); break; case "illum": _current.IllumunationModel = int.Parse(data); break; case "Tr": //TODO not sure what this is _current.Tr = data.ParseFloat(); break; case "Ns": _current.Ns = data.ParseFloat(); break; case "map_Kd": Textures.Add(data, Image.FromStream(FileSource.Get(data))); //TODO load image break; case "map_Ka": break; case "r": break; case "d": break; case "sharpness": break; case "Ni": break; default: throw new Exception(keyword); // } }
public void Get_Returns_Null_For_File_That_Doesnt_Exist() { const string name = "this file doesn't exist"; var source = new FileSource(); string value; var result = source.Get(name, null, out value); Assert.IsNull(value); Assert.IsFalse(result); }
public void Get_Returns_Value_From_xml_File() { const string name = "TestValue3"; const string expected = "<element>some xml</element>"; var source = new FileSource(); string value; var result = source.Get(name, null, out value); Assert.AreEqual(expected, value); Assert.IsTrue(result); }
public void Get_Returns_Value_From_json_File() { const string name = "TestValue2"; const string expected = "[\"string array\"]"; var source = new FileSource(); string value; var result = source.Get(name, null, out value); Assert.AreEqual(expected, value); Assert.IsTrue(result); }
public void Get_Returns_Value_From_conf_File() { const string name = "TestValue1"; const string expected = "This is a string value."; var source = new FileSource(); string value; var result = source.Get(name, null, out value); Assert.AreEqual(expected, value); Assert.IsTrue(result); }
protected override void Parse(string keyword, string data) { switch (keyword.ToLower()) { case "v": Vertices.Add(ParseVertex(data)); break; case "vp": throw new NotImplementedException(); break; case "vn": Normals.Add(ParseNormal(data)); break; case "vt": TextureVertices.Add(ParseTextureVertex(data)); break; case "g": break; case "f": Faces.Add(ParseFace(data)); break; case "usemtl": Materials.Add(_currentMaterial = LoadedMaterials.First(m => m.Name == data)); break; case "mtllib": using (var stream = FileSource.Get(data)) { MaterialFiles.Add(new MATFile(stream, FileSource)); } break; default: throw new Exception(keyword); break; // } }