#pragma once #include #include #include namespace fn::gfx { // CPU-side mesh: positions interleaved with normals stride 3 floats each, // indexed by `indices`. struct Mesh { std::vector positions; // x,y,z stride=3 (count = num_vertices*3) std::vector normals; // x,y,z stride=3 (same length as positions) std::vector indices; // tri-list (count multiple of 3) }; // Parse Wavefront .obj from a text buffer. Pure: no I/O. // Supports: v, vn, f (triangles and quads). Ignores: vt, mtllib, usemtl, o, g, s. // If the file has no vn, normals are generated per-face (flat shading). // Quads in `f` are split into 2 triangles (fan). N-gons (>4 verts) are not supported. // // Returns an empty Mesh ({}, {}, {}) on parse failure (no vertices found). Mesh mesh_obj_parse(const char* obj_text, size_t len); // Read file from disk and parse. IMPURE (file I/O). // Returns empty Mesh on read or parse failure. Mesh mesh_obj_load(const char* path); } // namespace fn::gfx