![]() |
LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
|
Functions | |
| LG_Mesh * | lg_mesh_load (LG_Path path, LG_LoadMesh_Flags flags) |
| LG_Mesh * | lg_mesh_new_from_obj (LG_Path path, zboolean invert_z, zboolean normalize_xyz, zboolean horiz_center, zboolean vert_center, zboolean vert_bottom) |
| LG_Mesh * | lg_mesh_new_from_fbx (LG_Path path, zboolean invert_z, zboolean normalize_xyz, zboolean horiz_center, zboolean vert_center, zboolean vert_bottom) |
| void | lg_mesh_free (LG_Mesh *mesh) |
| void | lg_mesh_free_v2 (LG_Mesh **mesh) |
| int | lg_bmesh_save_to_file (LG_Path path, LG_Mesh *mesh) |
| LG_Mesh * | lg_bmesh_load_from_file (LG_Path path) |
| int | lg_mesh_reload_mats (LG_Mesh *mesh) |
| void | lg_serialize_LG_Material_64_to_32 (Serializable_LG_Material *s_mat, LG_Material *mat) |
| void | lg_unserialize_LG_Material_32_to_64 (LG_Material *mat, Serializable_LG_Material *s_mat) |
| void | lg_serialize_LG_Mesh_64_to_32 (Serializable_LG_Mesh *s_mesh, LG_Mesh *mesh) |
| void | lg_unserialize_LG_Mesh_32_to_64 (LG_Mesh *mesh, Serializable_LG_Mesh *s_mesh) |
| LG_LoadMesh_Flags | lg_loadmesh_flags (zboolean save_as_bmesh_linux, zboolean invert_z, zboolean normalize_xyz, zboolean horiz_center, zboolean vert_center, zboolean vert_bottom) |
| void | lg_mesh_override_bounding_cuboid_color (LG_Mesh *mesh, LG_Color_u color) |
| void | lg_mesh_info (LG_Mesh *mesh, int show_first_n) |
| char * | lg_mesh_info_to_string (LG_Mesh *mesh, int show_first_n) |
| char * | lg_replace_file_extension (const char *path, const char *new_ext) |
This module deals with meshes, ie data that will feed VBOs and IBOs for fast and efficient drawing.
You can only use this func to load meshes:
and you can only use this func when done with a mesh:
and just ignore the details.
(Use everything here only if you know what you're doing).
NEW CONVENTIONS FOR PATHS / FILE NAMES AS FUNC ARGS:
In funcs names:
This module deals with meshes, ie data that will feed VBOs and IBOs for fast and efficient drawing.
You can/should only use this func to load meshes, if they're all in an <assets_dir> folder, defined by the macro ASSETS_DIR
and you can/should only use this func when done with a mesh:
and just ignore the details.
(Use everything here only if you know what you're doing).
NEW CONVENTIONS FOR PATHS / FILE NAMES AS FUNC ARGS:
In funcs names:
| LG_Mesh * lg_mesh_load | ( | LG_Path | path, |
| LG_LoadMesh_Flags | flags | ||
| ) |
Load OBJ or FBX or BMESH mesh file
If all your meshes (OBJ, FBX, BMESH) are in the ASSETS dir, then this is the entry point for loading them and the only func you need to call
Valid extensions are OBJ, FBX, and BMESH
Usage examples:
On Linux, if OBJ or FBX file was successfully loaded from assets and flags.save_as_bmesh_linux is set to TRUE, it will be saved as a BMESH asset
BMESH is LibGame binary format for meshes - optimized, faster to load, not requiring parsing
WARNING: FBX support is not complete yet
| path | LG_Path of mesh file, with extension OBJ or FBX or BMESH |
| flags | Apply to OBJ/FBX meshes loading: save_as_bmesh_linux, invert_z, normalize_xyz, horiz_center, vert_center, vert_bottom |
| LG_Mesh * lg_mesh_new_from_obj | ( | LG_Path | path, |
| zboolean | invert_z, | ||
| zboolean | normalize_xyz, | ||
| zboolean | horiz_center, | ||
| zboolean | vert_center, | ||
| zboolean | vert_bottom | ||
| ) |
Create mesh from OBJ file.
Read 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).
Other data is ignored so far.
=== WARNING: MESHES MUST BE PURE-TRIANGULAR ===
Will create a Vertex_uv_n VBO (see lg_vertex.h).
NO-OP on Android as BMESH files should be used instead
| path | LG_PATH to OBJ file (with extension OBJ) |
| invert_z | Invert z spatial coord - should be set to TRUE if mesh uses RH coords sys, FALSE if mesh uses LH coords sys |
| 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 |
| LG_Mesh * lg_mesh_new_from_fbx | ( | LG_Path | path, |
| zboolean | invert_z, | ||
| zboolean | normalize_xyz, | ||
| zboolean | horiz_center, | ||
| zboolean | vert_center, | ||
| zboolean | vert_bottom | ||
| ) |
Create mesh from FBX file.
| path | LG_PATH to FBX file (with extension FBX) |
| invert_z | Invert z spatial coord - should be set to TRUE if mesh uses RH coords sys, FALSE if mesh uses LH coords sys |
| 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 |
| void lg_mesh_free | ( | LG_Mesh * | mesh | ) |
Free mesh.
| mesh | Pointer to mesh |
| void lg_mesh_free_v2 | ( | LG_Mesh ** | mesh | ) |
NEW - needs extensive testing
Free mesh v2.
Take pointer to pointer to mesh arg, so that it can be nullified afterwards.
| mesh | Pointer to pointer to mesh |
Save mesh in BINARY MESH (.bmesh) format. Don't add suffix BINARY_MESH_EXT, as it's done automagically.
Load mesh from BINARY MESH (.bmesh) file. Don't add suffix BINARY_MESH_EXT, as it's done automagically.
| int lg_mesh_reload_mats | ( | LG_Mesh * | mesh | ) |
Reload materials textures correctly, when mesh is not loaded from OBJ file.
| mesh | Pointer to a LG_Mesh |
| void lg_serialize_LG_Material_64_to_32 | ( | Serializable_LG_Material * | s_mat, |
| LG_Material * | mat | ||
| ) |
Serialize a LG_Material instance
| s_mat | Pointer to a Serializable_LG_Material |
| mat | Pointer to a Serializable_LG_Material |
| void lg_unserialize_LG_Material_32_to_64 | ( | LG_Material * | mat, |
| Serializable_LG_Material * | s_mat | ||
| ) |
Unserialize a LG_Material instance
| mat | Pointer to a Serializable_LG_Material |
| s_mat | Pointer to a Serializable_LG_Material |
| void lg_serialize_LG_Mesh_64_to_32 | ( | Serializable_LG_Mesh * | s_mesh, |
| LG_Mesh * | mesh | ||
| ) |
Serialize a LG_Mesh instance
| s_mesh | Pointer to a Serializable_LG_Mesh |
| mesh | Pointer to a LG_Mesh |
| void lg_unserialize_LG_Mesh_32_to_64 | ( | LG_Mesh * | mesh, |
| Serializable_LG_Mesh * | s_mesh | ||
| ) |
Unserialize a LG_Mesh instance
| mesh | Pointer to a LG_Mesh |
| s_mesh | Pointer to a Serializable_LG_Mesh |
| LG_LoadMesh_Flags lg_loadmesh_flags | ( | zboolean | save_as_bmesh_linux, |
| zboolean | invert_z, | ||
| zboolean | normalize_xyz, | ||
| zboolean | horiz_center, | ||
| zboolean | vert_center, | ||
| zboolean | vert_bottom | ||
| ) |
Mesh loading flags.
See lg_mesh_load().
You can use these helper, which are all set to TRUE:
| save_as_bmesh_linux | If OBJ or FBX loaded from assets, save as a BMESH asset, only on Linux |
| invert_z | Invert z spatial coord - should be set to TRUE if mesh uses RH coords sys, FALSE if mesh uses LH coords sys |
| normalize_xyz | |
| horiz_center | |
| vert_center | Center mesh vertically, if vert_bottom is not set |
| vert_bottom | Set mesh origin vertically at bottom, override vert_center |
| void lg_mesh_override_bounding_cuboid_color | ( | LG_Mesh * | mesh, |
| LG_Color_u | color | ||
| ) |
Override color of mesh bounding cuboid AND bounding cuboid VB
Why is this needed ? bc color is set at mesh creation time
mesh->b_cuboid = LG_Cuboid // Bounding cuboid mesh->Lines3D_VB = b_cuboid_l3d_vb // Lines3D_VB from bounding cuboid
| mesh | Pointer to a LG_Mesh |
| color | Color as a LG_Color_u |
| void lg_mesh_info | ( | LG_Mesh * | mesh, |
| int | show_first_n | ||
| ) |
| char * lg_mesh_info_to_string | ( | LG_Mesh * | mesh, |
| int | show_first_n | ||
| ) |
Get LG_Mesh info as a string
NOTE: mesh->b_cuboid is not output (so far)
| mesh | Pointer to a LG_Mesh |
| show_first_n | Show first n elements of:
|
| char * lg_replace_file_extension | ( | const char * | path, |
| const char * | new_ext | ||
| ) |
Replace file extension with another extension, ie 'bla_bla/hello.old_ext' -> 'bla_bla/hello.new_ext'
Extension must not include leading dot
Remove trailing dot if new_ext is empty string
Returned new path must be freed after use (dynamically allocated)
| path | |
| new_ext |