![]() |
LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
|
Functions | |
| zboolean | lg_raycast_bsphere (LG_Camera *cam, LG_BSphere bsphere, float *inters_dist, int *click_type, zboolean flush_clicks) |
| vec4_t | vec4 (float x, float y, float z, float w) |
| vec4_t | m4_mul_v4 (mat4_t m, vec4_t v) |
| float | m4_det (mat4_t mat) |
| mat4_t | m4_invert (mat4_t mat) |
=== Ray casting ===
Also implement extra mat4 funcs: vec4 x mat4, determinant, and inverse
Sources:
https://github.com/capnramses/antons_opengl_tutorials_book/tree/master https://github.com/capnramses/antons_opengl_tutorials_book/blob/master/07_ray_picking/main.cpp https://github.com/capnramses/antons_opengl_tutorials_book/blob/master/07_ray_picking/maths_funcs.cpp
| zboolean lg_raycast_bsphere | ( | LG_Camera * | cam, |
| LG_BSphere | bsphere, | ||
| float * | inters_dist, | ||
| int * | click_type, | ||
| zboolean | flush_clicks | ||
| ) |
Ray casting
Check intersection of ray (emitted from mouse pointer location on left/right-click) with sphere
| cam | |
| bsphere | |
| inters_dist | Intersection distance, set if intersection occurs |
| click_type | Set to RAYCAST_LEFT_CLICK, RAYCAST_RIGHT_CLICK, or RAYCAST_NO_CLICK |
| flush_clicks | If TRUE, call lg_flush_in_clicks() after intersection occurs and before returning |
| vec4_t vec4 | ( | float | x, |
| float | y, | ||
| float | z, | ||
| float | w | ||
| ) |
Multiply 4x4 matrix by vec4 ("apply" mat4 to vec4)
| m | 4x4 matrix |
| v | Vec4 |
| float m4_det | ( | mat4_t | mat | ) |
Get determinant of a 4x4 matrix
Source: http://www.euclideanspace.com/maths/algebra/matrix/functions/determinant/fourD/index.htm
| m | Matrix |
Invert a 4x4 matrix if invertible, ie if its determinant is != 0
Source: http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
| m | Matrix |