public static ElMeshContainer Parse(ElData data) { var rt = new ElMeshContainer { baseData = data, }; foreach (var i in data.Children) { switch (i.Name) { case "Name": rt.Name = i.Values.First().Trim('"'); break; case "VertexFormat": rt.VertexFormat = i.Children.Select(_ => Util.ParseEnum <ElVertexFormat>(_.Values.First().Trim('"'))).ToList(); break; case "BoneNames": rt.BoneNames = i.Children.Select(_ => _.Values.First().Trim('"')).ToList(); break; case "OffsetMatrices": rt.OffsetMatrices = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "Materials": rt.Materials = i.Children.Where(_ => _.Name == "Material").Select(ElMaterial.Parse).ToList(); break; case "Mesh": rt.Meshes.Add(ElMesh.Parse(i)); break; } } return(rt); }
public static ElMesh Parse(ElData data) { var rt = new ElMesh { baseData = data, }; foreach (var i in data.Children) { switch (i.Name) { case "Name": rt.Name = i.Values.First().Trim('"'); break; case "Positions": rt.Positions = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "Normals": rt.Normals = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "Diffuse": rt.Diffuse = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "BlendList": rt.BlendList = i.Children.Select(ElBlendPart.Parse).ToList(); break; case "TextureUV": case "Texture1UV": case "Texture2UV": case "Texture3UV": case "Texture4UV": case "Texture5UV": case "Texture6UV": case "Texture7UV": case "Texture8UV": rt.TextureUV[int.Parse(string.Join("", i.Name.Where(char.IsDigit).DefaultIfEmpty('0')))] = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "VertexIndices": rt.VertexIndices = i.Children.Select(_ => _.Values.Select(f => f.Split(',').Last()).Select(int.Parse).ToArray()).ToList(); break; case "Attributes": rt.Attributes = i.Children.Select(_ => int.Parse(_.Values.First())).ToList(); break; } } return(rt); }
public static ElMesh Parse(ElData data) { var rt = new ElMesh { baseData = data, }; foreach (var i in data.Children) switch (i.Name) { case "Name": rt.Name = i.Values.First().Trim('"'); break; case "Positions": rt.Positions = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "Normals": rt.Normals = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "Diffuse": rt.Diffuse = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "BlendList": rt.BlendList = i.Children.Select(ElBlendPart.Parse).ToList(); break; case "TextureUV": case "Texture1UV": case "Texture2UV": case "Texture3UV": case "Texture4UV": case "Texture5UV": case "Texture6UV": case "Texture7UV": case "Texture8UV": rt.TextureUV[int.Parse(string.Join("", i.Name.Where(char.IsDigit).DefaultIfEmpty('0')))] = i.Children.Select(_ => _.Values.Select(float.Parse).ToArray()).ToList(); break; case "VertexIndices": rt.VertexIndices = i.Children.Select(_ => _.Values.Select(f => f.Split(',').Last()).Select(int.Parse).ToArray()).ToList(); break; case "Attributes": rt.Attributes = i.Children.Select(_ => int.Parse(_.Values.First())).ToList(); break; } return rt; }