![]() |
LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
|
=== Higher level scene/frame stuff === The starting point for scenes
LG_Scene lg_scene_new | ( | int | id, |
LG_Camera * | cam1, | ||
LG_Light | light1, | ||
Rec2Df | landscape_rec, | ||
uint16_t | grid_width | ||
) |
Create and init a new scene
Can not contain more than MESH_NTOS_MAX_NUM mesh references
LG_Mesh_NTOS, LG_Scene, and LG_SceneDZ are defined in lg_scene_graph.h
Generated nodes:
id | Scene's id, set to -1 on error |
cam1 | A pointer to a LG_Camera |
light1 | A LG_Light |
landscape_rec | A Rec2Df, should be centered |
grid_width | Grid width, ie number of units along one row or one column, should be even - if odd, we substract one |
void lg_scene_free | ( | LG_Scene * | scene | ) |
Free scene root, grid, and xyz_arrows nodes
scene | A LG_Scene |
LG_SceneNode* lg_scenenode_new_and_set | ( | int | id, |
LG_SceneNode * | parent, | ||
const char * | mesh_file, | ||
LG_LoadMesh_Flags | flags, | ||
vec3_t | transl, | ||
LG_Quat | orientation, | ||
vec3_t | scaling | ||
) |
Helper func to create and set a new LG_SceneNode instance
Create node, add node to scene graph, load node's mesh, and set node's local matrix
Helper macros for less confusion:
Mesh must be freed when done with the scene
id | Node's id |
parent | A pointer to a scene graph node |
mesh_file | Relative path to mesh file to load, inside the mesh folder |
flags | Apply to mesh: force_reload, invert_z, normalize_xyz, horiz_center, vert_center, vert_bottom |
transl | Translation/position vec3 |
orientation | Orientation quat |
scaling | Scaling vec3 |
LG_SceneNode* lg_mesh_NTOS_array_to_scenenodes | ( | LG_SceneNode * | node, |
LG_LoadMesh_Flags | flags, | ||
LG_Mesh_NTOS * | mesh_ntos, | ||
int | n_mesh_ntos | ||
) |
Get an array of LG_Mesh_NTOS and create and set scenenodes
NTOS stands for Name and TOS (Transl/Orientation/Scaling)
Generated scenenodes id start at MNTOS_ARRAY_INDEX_TO_SCENENODE_ID
Example code #1:
Example code #2:
node | A scene node |
flags | Flags for mesh loading |
mesh_ntos | An array of LG_Mesh_NTOS |
n_mesh_ntos | Num of LG_Mesh_NTOS in the array |
mat4_t lg_get_TRS_matrix_from_TOS_v | ( | vec3_t | transl, |
LG_EulerAng | orientation, | ||
vec3_t | scaling, | ||
const char * | rot_order | ||
) |
Create a TRS matrix (Transl/Rotation/Scaling) from TOS values (Transl/Orientation/Scaling)
transl | Translation vector |
orientation | Orientation LG_EulerAng |
scaling | Scaling vector |
zboolean lg_set_TRS_matrix_from_mesh_NTOS | ( | mat4_t * | m_TRS, |
LG_Mesh_NTOS * | tos | ||
) |
Set an existing TRS matrix (Transl/Rotation/Scaling) from a LG_Mesh_NTOS
m_TRS | Pointer to a mat4_t |
tos | Pointer to a LG_Mesh_NTOS |
scaling | Scaling vector |
void lg_mesh_NTOS_array_info | ( | LG_Mesh_NTOS * | mesh_ntos, |
int | n_mesh_ntos | ||
) |
Print out LG_Mesh_NTOS[] info
mesh_ntos | An array of LG_Mesh_NTOS |
n_mesh_ntos | Num of LG_Mesh_NTOS in the array |
LG_SceneDZ lg_scenedz_load_from_assets | ( | const char * | path | ) |
LG_SceneDZ lg_scenedz_load_from_file | ( | const char * | path | ) |
Load a LG_SceneDZ from a file in the APP WRITABLE folder
path | Path to scene file, inside env->app_wr_dir |
zboolean lg_scenedz_save_to_file | ( | LG_SceneDZ * | scenedz, |
const char * | path | ||
) |
Save a LG_SceneDZ to a file in the APP WRITABLE folder
scene | Pointer a to LG_SceneDZ |
path | Path to scene file, inside env->app_wr_dir |
zboolean lg_create_wr_scenes_dir | ( | ) |
Create the scene folder (SCENES_DIR) in the APP WRITABLE folder
void lg_scene_set_from_scenedz | ( | LG_Scene * | scene, |
LG_SceneDZ * | scenedz | ||
) |
Set LG_Scene data from LG_SceneDZ data
-> cam, landscape_rec, meshes_ntos[MESH_NTOS_MAX_NUM], and n_mesh_ntos
scene | Pointer to a LG_Scene |
scenedz | Pointer to a LG_SceneDZ |
void lg_scenedz_set_from_scene | ( | LG_SceneDZ * | scenedz, |
LG_Scene * | scene | ||
) |
Set LG_SceneDZ data from LG_Scene data
-> cam, landscape_rec, meshes_ntos[MESH_NTOS_MAX_NUM], and n_mesh_ntos
scenedz | Pointer to a LG_SceneDZ |
scene | Pointer to a LG_Scene |
LG_SceneNode* lg_generate_scenenodes_from_scenedz | ( | LG_SceneDZ * | sdz, |
LG_LoadMesh_Flags | flags | ||
) |
Helper func to generate scene nodes (LG_SceneNode *) from a LG_SceneDZ and mesh files
You can then add this node to your scene root node
Top node:
sdz | Pointer to a LG_SceneDZ |
flags | Mesh loading flags |