![]() |
LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
|
Functions | |
| LG_Mesh * | lg_obj2vbo (const char *obj_full_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_file, const char *obj_full_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 | ( | const char * | obj_full_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_full_path (user-provided full path to the OBJ file) to set mesh->full_path and locate MTL file and textures
Doesn't close the stream, you'll have to do it yourself after the func returns
| obj_full_path | User-provided full 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_file, |
| const char * | obj_full_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_file | 'mtllib' tag value in OBJ file, ie name of MTL files |
| obj_full_path | Full path to OBJ file |
| mat | Address of an array of N_MAT_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 | Addr of first Vertex_uv_n |
| v2 | Addr of second Vertex_uv_n |
| tex_coords | Also compare texture coords |
| normals | Also compare normals |
| zboolean lg_objparser_check_consistency | ( | ) |
Only for init-time checking