| 50 | |
| 51 | template <typename VertexType, typename IndexType> |
| 52 | int SaveMeshAsOBJSimple(const FString& FilePath, const Chaos::TArrayCollectionArray<VertexType>& Vertices, |
| 53 | const TArray<Chaos::TVector<IndexType, 3>>& Indices) |
| 54 | { |
| 55 | FString OutputString; |
| 56 | |
| 57 | // Write vertices |
| 58 | for (const auto& Vertex : Vertices) |
| 59 | { |
| 60 | OutputString += FString::Printf(TEXT("v %f %f %f\n"), Vertex.X / 100, -Vertex.Y / 100, Vertex.Z / 100); |
| 61 | } |
| 62 | |
| 63 | // Write indices |
| 64 | for (const auto& Index : Indices) |
| 65 | { |
| 66 | OutputString += FString::Printf(TEXT("f %d %d %d\n"), Index.Z + 1, Index.Y + 1, Index.X + 1); |
| 67 | } |
| 68 | |
| 69 | return FFileHelper::SaveStringToFile(OutputString, *FilePath) ? 1 : 0; |
| 70 | } |
| 71 | |
| 72 | template <typename VertexType, typename IndexType> |
| 73 | int SaveMeshAsOBJComplex(const FString& FilePath, const Chaos::TArrayCollectionArray<VertexType>& Vertices, |