LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
|
Functions | |
LG_Mesh * | lg_obj2vbo (const char *mesh_name, FILE *stream, zboolean do_normalize_xyz) |
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 | do_normalize_xyz | ||
) |
Parse a readable stream (opened obj file) and create the mesh VBO and IBO
Will create a Vertex_uv_n VBO (see lg_vertex.h)
We use the full path 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 |
stream | An open stream of the obj file |
do_normalize_xyz | (self-explanatory enough) |
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
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 | (not sure - read the src) |
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 | (not sure - read the src) |
line_start | String starting each line |
is_triangle_mesh |
zboolean lg_objparser_check_consistency | ( | ) |
Only for init-time checking