![]() |
LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
|
Functions | |
| LG_Mesh * | lg_obj2vbo (LG_Path obj_path, FILE *stream, zboolean invert_z, zboolean normalize_xyz, zboolean horiz_center, zboolean vert_center, zboolean vert_bottom) |
| int | lg_mtl_parser (const char *mtl_filename, LG_Path obj_path, LG_Material *mat[]) |
| int | lg_vertex_cmp (Vertex_uv_n *v1, Vertex_uv_n *v2, zboolean tex_coords, zboolean normals) |
| zboolean | lg_objparser_check_consistency () |
=== The Wawefront OBJ file parser ===
| LG_Mesh * lg_obj2vbo | ( | LG_Path | obj_path, |
| FILE * | stream, | ||
| zboolean | invert_z, | ||
| zboolean | normalize_xyz, | ||
| zboolean | horiz_center, | ||
| zboolean | vert_center, | ||
| zboolean | vert_bottom | ||
| ) |
Parse a readable stream (an opened OBJ file) and create the mesh VBO and IBO
Will create a Vertex_uv_n VBO (see lg_vertex.h)
We use obj_path (user-provided LG_Path to the OBJ file) to set mesh->path and locate MTL file and textures
The MTL file is expected to be in the same dir as the OBJ file
Doesn't close the stream, you'll have to do it yourself after the func returns
| obj_path | User-provided LG_Path to the OBJ file |
| stream | An open stream of the OBJ file |
| invert_z | Invert z spatial coord (left_handed vs right_handed coords sys) - STILL EXPERIMENTAL |
| normalize_xyz | Normalize spatial coords |
| horiz_center | Center mesh horizontally |
| vert_center | Center mesh vertically, if vert_bottom is not set |
| vert_bottom | Set mesh origin vertically at bottom, override vert_center |
| int lg_mtl_parser | ( | const char * | mtl_filename, |
| LG_Path | obj_path, | ||
| LG_Material * | mat[] | ||
| ) |
Parse a MTL file
Get (materials) names and associated textures referenced by 'map_K' tags
Doesn't set indice (it's done later)
| mtl_filename | 'mtllib' tag value in OBJ file, ie name of MTL files - expected to be in the same dir as the OBJ file |
| obj_path | LG_Path to OBJ file |
| mat | Pointer to an array of N_NEWMTL_USEMTL_TAGS_MAX pointers to LG_Material structs |
| int lg_vertex_cmp | ( | Vertex_uv_n * | v1, |
| Vertex_uv_n * | v2, | ||
| zboolean | tex_coords, | ||
| zboolean | normals | ||
| ) |
Compare two vertices
FIXME: should use adaptative epsilon or another better way of comparison.
| v1 | Pointer to first Vertex_uv_n |
| v2 | Pointer to second Vertex_uv_n |
| tex_coords | Also compare texture coords |
| normals | Also compare normals |
| zboolean lg_objparser_check_consistency | ( | ) |
Only for init-time checking