![]() |
LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
|
Functions | |
| LG_Mesh * | lg_obj2vbo (const char *mesh_name, 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, LG_Material *mat[]) |
| int | lg_vertex_cmp (Vertex_uv_n *v1, Vertex_uv_n *v2, zboolean tex_coords, zboolean normals) |
| void | lg_vbo_and_ibo_info (Vertex_uv_n *vbo_data, uint32_t *ibo_data, uint32_t vbo_size, uint32_t ibo_size, lg_vertex_type vertex_type, int n_lines_max) |
| void | lg_vb_info (Vertex *vb_data, uint32_t vb_size, int n_lines_max, const char *line_start, zboolean is_triangle_mesh) |
| void | lg_vb_rgba_info (Vertex_rgba *vb_data, uint32_t vb_size, int n_lines_max, const char *line_start, zboolean is_triangle_mesh) |
| zboolean | lg_objparser_check_consistency () |
=== The Wawefront OBJ file parser ===
| LG_Mesh* lg_obj2vbo | ( | const char * | mesh_name, |
| 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 the basename of the OBJ file only to set mesh->name but it's not used anywhere else, as the file is already opened (saying that to avoid any possible confusion)
| mesh_name | OBJ file name - only BASENAME is used |
| 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, |
| LG_Material * | mat[] | ||
| ) |
Parse a MTL file
Get materials names and associated textures
Don't set indice (it's done later)
| mtl_file | MTL file name |
| tex | Address of an array of N_MAX_MAT_PER_OBJ 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 |
| void lg_vbo_and_ibo_info | ( | Vertex_uv_n * | vbo_data, |
| uint32_t * | ibo_data, | ||
| uint32_t | vbo_size, | ||
| uint32_t | ibo_size, | ||
| lg_vertex_type | vertex_type, | ||
| int | n_lines_max | ||
| ) |
Print out nicely VBO and IBO (arrays of Vertex_uv_n and uint32_t)
vertex_type is one of lg_vertex_type: WITH_COORDS_ONLY, WITH_TEXCOORDS, WITH_NORMALS, WITH_TEXCOORDS_AND_NORMALS
| vbo_data | Pointer to (Vertex_uv_n) VBO with interleaved vertex data - sizeof(Vertex_uv_n) = 24 |
| ibo_data | Pointer to (uint32_t) IBO, indices start at 0, sizeof(uint32_t) = 4 |
| vbo_size | VBO size (uint32_t) |
| ibo_size | IBO size uint32_t |
| vertex_type | A lg_vertex_type, see above |
| n_lines_max | Print out up to n_lines_max lines |
| void lg_vb_info | ( | Vertex * | vb_data, |
| uint32_t | vb_size, | ||
| int | n_lines_max, | ||
| const char * | line_start, | ||
| zboolean | is_triangle_mesh | ||
| ) |
| void lg_vb_rgba_info | ( | Vertex_rgba * | vb_data, |
| uint32_t | vb_size, | ||
| int | n_lines_max, | ||
| const char * | line_start, | ||
| zboolean | is_triangle_mesh | ||
| ) |
Print out nicely a Vertex_rgba (ie spatial coords + RGBA color) buffer info, actually spatial coords info ONLY
v[1/2/3] applies only for triangle meshes
| vb_data | Pointer to a Vertex_rgba buffer |
| vb_size | Buffer size (uint32_t) |
| n_lines_max | Print out up to n_lines_max lines |
| line_start | String starting each line |
| is_triangle_mesh |
| zboolean lg_objparser_check_consistency | ( | ) |
Only for init-time checking