CGPdocs

OBJ files

Read the parts of an OBJ file, load a model with several materials, save a mesh.

I/O 6

std::vector<mesh_obj_advanced_loader::shape_element_node> mesh_load_file_obj_advanced(
    std::string const& directory,
    std::string const& filename
)

Load an .obj file with its .mtl materials using tinyobjloader, returning one mesh per material change, each paired with its diffuse texture uploaded to the GPU.

void mesh_save_file_obj(
    std::string const& filename,
    std::vector<vec3> const& position,
    std::vector<vec3> const& normal
)

Save a triangle soup (three consecutive positions per triangle) and its normals as an .obj file.

std::vector<uint3> obj_read_connectivity(std::string const& filename)

Reads the first three vertex indices of every face (f line) of an .obj file as a 0-based triangle, ignoring the texture and normal indices.

std::vector<vec3> obj_read_normals(std::string const& filename)

Read only the vertex normals (vn lines) of an .obj file.

std::vector<vec3> obj_read_positions(std::string const& filename)

Reads the vertex positions (v lines) of an .obj file.

std::vector<vec2> obj_read_texture_uv(std::string const& filename)

Reads the texture coordinates (vt lines, u and v) of an .obj file.

CGP - Computer Graphics Programming.