public TriangleMesh Build(IList <Vector3> vertexList, IList <Triangle> triangleList, IList <ushort> materialsList) { Init(vertexList, triangleList, materialsList); using (BinaryWriter writer = new BinaryWriter(File.Open("mesh.bin", FileMode.Create))) { Save(writer); } FBXHelper.CookTriangleCollision("mesh.bin", "cook.bin"); TriangleMesh cookedTriangleMesh = new TriangleMesh(); using (BinaryReader reader = new BinaryReader(File.Open("cook.bin", FileMode.Open))) { cookedTriangleMesh.Load(reader); } if (File.Exists("mesh.bin")) { File.Delete("mesh.bin"); } if (File.Exists("cook.bin")) { File.Delete("cook.bin"); } cookedTriangleMesh.Force32BitIndices(); return(cookedTriangleMesh); }
public void WriteToFile(BinaryWriter writer) { writer.Write(version); writer.Write(unk0); writer.Write(placementData.Count); for (int i = 0; i != placementData.Count; i++) { placementData[i].WriteToFile(writer); } writer.Write(nxsData.Count); for (int i = 0; i != nxsData.Count; i++) { NXSStruct data = nxsData.ElementAt(i).Value; using (BinaryWriter meshWriter = new BinaryWriter(File.Open("mesh.bin", FileMode.Create))) data.Data.WriteToFile(meshWriter); string args = "-CookCollisions "; args += ("\"" + "mesh" + ".bin\" "); args += ("\"" + "cook" + ".bin\""); FBXHelper.CookTriangleCollision("mesh.bin", "cook.bin"); using (BinaryReader meshReader = new BinaryReader(File.Open("cook.bin", FileMode.Open))) nxsData.ElementAt(i).Value.Data.ReadFromFile(meshReader); nxsData.ElementAt(i).Value.WriteToFile(writer); } if (File.Exists("mesh.bin")) { File.Delete("mesh.bin"); } if (File.Exists("cook.bin")) { File.Delete("cook.bin"); } }