import java.io.*; import java.nio.file.*; import java.util.*; public class OBJLoader { public static class Vertex { public float x, y, z; // Position public float u, v; // Texture coordinates public float nx, ny, nz; // Normal public Vertex(float x, float y, float z, float u, float v, float nx, float ny, float nz) { this.x = x; this.y = y; this.z = z; this.u = u; this.v = v; this.nx = nx; this.ny = ny; this.nz = nz; } } public static class Model { public List<Vertex> vertices = new ArrayList<>(); public List<Integer> indices = new ArrayList<>(); } public static Model loadModel(String filePath) throws IOException { List<float[]> positions = new ArrayList<>(); List<float[]> texCoords = new ArrayList<>(); List<float[]> normals = new ArrayList<>(); Model model = new Model(); List<String> lines = Files.readAllLines(Paths.get(filePath)); for (String line : lines) { String[] tokens = line.split("\\s+"); switch (tokens[0]) { case "v