SharpMesh GetSharpMesh(SharpDevice device) { SharpMesh mesh = new SharpMesh(device); List <int> indices = new List <int>( ); List <Face> faces = new List <Face>( ); List <string> texList = new List <string>( ); List <string> notFoundTexList = new List <string>( ); int icount = 0; foreach (Material item in Materials) { indices.AddRange(item.FlattenFace); int faceCount = item.FlattenFace.Count( ); SharpSubSet subSet = new SharpSubSet( ) { IndexCount = faceCount, StartIndex = icount, }; if (item.TexName != string.Empty) { var filename = TryGetResource(device, item.TexName); // 存在しないパスなら読まない filename.Match(() => notFoundTexList.Add(item.TexName), r => subSet.DiffuseMap = r); } if (item.SphereName != string.Empty) { var filename = TryGetResource(device, item.SphereName); filename.Match(() => notFoundTexList.Add(item.SphereName), r => subSet.SphereMap = r); } mesh.SubSets.Add(subSet); for (int i = icount; i < icount + faceCount; i += 3) { int ind1 = indices[i]; int ind2 = indices[i + 1]; int ind3 = indices[i + 2]; Face item1 = new Face(Vertice[ind1].Position, Vertice[ind2].Position, Vertice[ind3].Position, item.Name); //Debug.WriteLine("first " + item1.TriString); faces.Add(item1); } icount += faceCount; } Index = indices.ToArray( ); Faces = faces.ToArray( ); var inds = Index.Select(x => x.ToString( )); var facesS = Faces.Select(x => x.ToString( )); //inds.Concat( facesS ).Concat( texList ).WriteFile( DirPath + "loadedFile.txt" ); notFoundTexList.WriteFile(DirPath + "notFoundTextures.txt"); ModelStr = Faces.Select(f => f.TriString).ConcatStr( ); mesh.SetOnly(Vertice, Index); return(mesh); }