LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
|
Functions | |
LG_Mesh * | lg_load_vbo (const char *path, zboolean force_reload_obj, zboolean do_normalize_xyz) |
LG_Mesh * | lg_mesh_new_from_objfile (const char *path, zboolean do_normalize_xyz) |
void | lg_mesh_free (LG_Mesh *mesh) |
void | lg_mesh_info (LG_Mesh *mesh) |
int | lg_obj_file_save_to_cache (void *asset_buf, const char *file_name, size_t size, size_t *written_size) |
void * | lg_obj_file_open_from_cache (const char *file_name) |
int | lg_vbo_save_to_file (const char *path, LG_Mesh *mesh) |
int | lg_vbo_load_from_file (const char *path, LG_Mesh **mesh) |
This module deals with meshes, ie data that will feed VBOs and IBOs for fast and efficient drawing.
=== MESHES MUST BE PURE-TRIANGULAR ===
Using MeshLab filters: remeshing, simplification and reconstruction turn into a pure-triangle mesh Also: normals, curvatures and orientation transform: translate, center, set origin -> center on layer bbox normals, curvatures and orientation transform: scale, normalize -> scale to unit bbox
At the moment, read only a limited set of data from WAVEFRONT OBJ files: vertex/index values for v (coords), vt (texture coords), vn (normals), f (triangular faces), mtllib, usemtl (materials/textures stuff), plus newmtl, and map_K* (in MTL files).
Will create a Vertex_uv_n VBO (see lg_vertex.h).
You can/should only use this func to load meshes:
LG_Mesh *lg_load_vbo(const char *path, zboolean force_reload_obj, zboolean do_normalize_xyz)
and you can/should only use this func when done with a mesh:
void lg_mesh_free(LG_Mesh *)
and just ignore the details.
(Use everything here only if you know what you're doing).
LG_Mesh* lg_load_vbo | ( | const char * | path, |
zboolean | force_reload_obj, | ||
zboolean | do_normalize_xyz | ||
) |
Load VBO &co
=== This is the entry point for loading meshes (obj, vbo, ibo) ===
THIS WHOLE MODULE WORKS GREAT BUT NEED TO FIND A MORE DESCRIPTIVE AND ACCURATE NAME FOR THIS FUNC (AND OTHERS AS WELL ?)
We use a cache mechanism:
All mesh data is saved
On Android, obj files are cached as well
path | Path to obj file |
force_reload_obj | |
do_normalize_xyz |
LG_Mesh* lg_mesh_new_from_objfile | ( | const char * | path, |
zboolean | do_normalize_xyz | ||
) |
Create mesh from obj file
path | |
do_normalize_xyz |
void lg_mesh_free | ( | LG_Mesh * | mesh | ) |
Free mesh
mesh |
int lg_obj_file_save_to_cache | ( | void * | asset_buf, |
const char * | file_name, | ||
size_t | size, | ||
size_t * | written_size | ||
) |
Save obj file to cache
void* lg_obj_file_open_from_cache | ( | const char * | file_name | ) |
Load obj file from cache
int lg_vbo_save_to_file | ( | const char * | path, |
LG_Mesh * | mesh | ||
) |
Actually save mesh with VBO and IBO in binary form, so should find a more accurate name. Don't add suffix LG_MESH_INFO_EXT, LG_MESH_VBO_EXT, LG_MESH_IBO_EXT to path, it's done automagically. Only the basename of path is used. All binary files are saved in the cache.
int lg_vbo_load_from_file | ( | const char * | path, |
LG_Mesh ** | mesh | ||
) |
Same as above but for reading binary files