Kohi Game Engine
|
Go to the source code of this file.
Data Structures | |
struct | kgeometry |
Represents geometry to be used for various purposes (rendering objects in the world, physics/collision, etc.). More... | |
Macros | |
#define | GEOMETRY_NAME_MAX_LENGTH 256 |
The maximum length of a geometry name. More... | |
Typedefs | |
typedef enum kgeometry_type | kgeometry_type |
Indicates a geometry type, typically used to infer things like vertex and index sizes. More... | |
typedef struct kgeometry | kgeometry |
Represents geometry to be used for various purposes (rendering objects in the world, physics/collision, etc.). More... | |
typedef enum grid_orientation | grid_orientation |
Enumerations | |
enum | kgeometry_type { KGEOMETRY_TYPE_UNKNOWN = 0x00 , KGEOMETRY_TYPE_2D_STATIC = 0x01 , KGEOMETRY_TYPE_2D_DYNAMIC = 0x02 , KGEOMETRY_TYPE_3D_STATIC = 0x03 , KGEOMETRY_TYPE_3D_STATIC_COLOUR_ONLY = 0x04 , KGEOMETRY_TYPE_3D_DYNAMIC = 0x05 , KGEOMETRY_TYPE_3D_SKINNED = 0x06 , KGEOMETRY_TYPE_3D_HEIGHTMAP_TERRAIN = 0x07 , KGEOMETRY_TYPE_CUSTOM = 0xFF } |
Indicates a geometry type, typically used to infer things like vertex and index sizes. More... | |
enum | grid_orientation { GRID_ORIENTATION_XZ = 0 , GRID_ORIENTATION_XY = 1 , GRID_ORIENTATION_YZ = 2 } |
Functions | |
KAPI void | geometry_generate_normals (u32 vertex_count, vertex_3d *vertices, u32 index_count, u32 *indices) |
Calculates normals for the given vertex and index data. Modifies vertices in place. More... | |
KAPI void | geometry_generate_tangents (u32 vertex_count, vertex_3d *vertices, u32 index_count, u32 *indices) |
Calculates tangents for the given vertex and index data. Modifies vertices in place. More... | |
KAPI void | geometry_deduplicate_vertices (u32 vertex_count, vertex_3d *vertices, u32 index_count, u32 *indices, u32 *out_vertex_count, vertex_3d **out_vertices) |
De-duplicates vertices, leaving only unique ones. Leaves the original vertices array intact. Allocates a new array in out_vertices. Modifies indices in-place. Original vertex array should be freed by caller. More... | |
KAPI void | generate_uvs_from_image_coords (u32 img_width, u32 img_height, u32 px_x, u32 px_y, f32 *out_tx, f32 *out_ty) |
Generates texture coordinates based on pixel position within an image's dimensions. More... | |
KAPI kgeometry | geometry_generate_quad (f32 width, f32 height, f32 tx_min, f32 tx_max, f32 ty_min, f32 ty_max, kname name) |
Generates a two-dimensional quad (two triangles) of geometry. Note that memory for the vertex and index arrays are dynamically allocated, so this should be cleaned up with geometry_destroy(). Dimensions account for the x- and y-axes only. More... | |
KAPI kgeometry | geometry_generate_line2d (vec2 point_0, vec2 point_1, kname name) |
Generates a two-dimensional line of geometry. Note that the memory for the vertex array is dynamically allocated, so this should be cleaned up with geometry_destroy(). Note that index data is not used for this geometry. More... | |
KAPI kgeometry | geometry_generate_line3d (vec3 point_0, vec3 point_1, kname name) |
Generates a three-dimensional line of geometry. Note that the memory for the vertex array is dynamically allocated, so this should be cleaned up with geometry_destroy(). Note that index data is not used for this geometry. More... | |
KAPI kgeometry | geometry_generate_line_sphere3d (f32 radius, u32 segment_count, vec4 colour, kname name) |
KAPI kgeometry | geometry_generate_plane (f32 width, f32 height, u32 x_segment_count, u32 y_segment_count, f32 tile_x, f32 tile_y, kname name) |
Generates a three-dimensional plane of geometry. Note that memory for the vertex and index arrays are dynamically allocated, so this should be cleaned up with geometry_destroy(). Dimensions account for the x- and y-axes, z is always 0. More... | |
KAPI void | geometry_recalculate_line_box3d_by_points (kgeometry *geometry, vec3 points[8]) |
Recalculates the vertices in the given geometry based off the given points. More... | |
KAPI void | geometry_recalculate_line_box3d_by_extents (kgeometry *geometry, extents_3d extents) |
Recalculates the vertices in the given geometry based off the given extents. More... | |
KAPI kgeometry | geometry_generate_line_box3d (vec3 size, kname name) |
Generates a line-based 3d box based on the provided size. More... | |
KAPI kgeometry | geometry_generate_cube (f32 width, f32 height, f32 depth, f32 tile_x, f32 tile_y, kname name) |
Generates a three-dimensional cube of geometry. Note that memory for the vertex and index arrays are dynamically allocated, so this should be cleaned up with geometry_destroy(). More... | |
KAPI kgeometry | geometry_generate_grid (grid_orientation orientation, u32 segment_count_dim_0, u32 segment_count_dim_1, f32 segment_size, b8 use_third_axis, kname name) |
Create a geometry-based grid using the given parameters. The grid is based on line geometry and has no indices. Note that the vertex array data is dynamically allocated and should be cleaned up using geometry_destroy(). More... | |
KAPI void | geometry_destroy (kgeometry *geometry) |
Destroys the given geometry. More... | |
#define GEOMETRY_NAME_MAX_LENGTH 256 |
The maximum length of a geometry name.
typedef enum grid_orientation grid_orientation |
Represents geometry to be used for various purposes (rendering objects in the world, physics/collision, etc.).
typedef enum kgeometry_type kgeometry_type |
Indicates a geometry type, typically used to infer things like vertex and index sizes.
enum grid_orientation |
enum kgeometry_type |
Indicates a geometry type, typically used to infer things like vertex and index sizes.
KAPI void generate_uvs_from_image_coords | ( | u32 | img_width, |
u32 | img_height, | ||
u32 | px_x, | ||
u32 | px_y, | ||
f32 * | out_tx, | ||
f32 * | out_ty | ||
) |
Generates texture coordinates based on pixel position within an image's dimensions.
img_width | The width of the image in pixels. |
img_height | The height of the image in pixels. |
px_x | The pixel position along the x-axis. |
px_y | The pixel position along the y-axis. |
out_tx | A pointer to hold the generated texture coordinate on the x-axis. |
out_ty | A pointer to hold the generated texture coordinate on the y-axis. |
KAPI void geometry_deduplicate_vertices | ( | u32 | vertex_count, |
vertex_3d * | vertices, | ||
u32 | index_count, | ||
u32 * | indices, | ||
u32 * | out_vertex_count, | ||
vertex_3d ** | out_vertices | ||
) |
De-duplicates vertices, leaving only unique ones. Leaves the original vertices array intact. Allocates a new array in out_vertices. Modifies indices in-place. Original vertex array should be freed by caller.
vertex_count | The number of vertices in the array. |
vertices | The original array of vertices to be de-duplicated. Not modified. |
index_count | The number of indices in the array. |
indices | The array of indices. Modified in-place as vertices are removed. |
out_vertex_count | A pointer to hold the final vertex count. |
out_vertices | A pointer to hold the array of de-duplicated vertices. |
Destroys the given geometry.
geometry | A pointer to the geometry to be destroyed. |
KAPI kgeometry geometry_generate_cube | ( | f32 | width, |
f32 | height, | ||
f32 | depth, | ||
f32 | tile_x, | ||
f32 | tile_y, | ||
kname | name | ||
) |
Generates a three-dimensional cube of geometry. Note that memory for the vertex and index arrays are dynamically allocated, so this should be cleaned up with geometry_destroy().
width | The width of the cube (x-axis). |
height | The height of the cube (y-axis). |
depth | The depth of the cube (z-axis). |
tile_x | The amount of tiling of the textures on each face of the cube on the x-axis. 1.0 means the texture is stretched across the entire surface. 2.0 means it's repeated, etc. |
tile_y | The amount of tiling of the textures on each face of the cube on the y-axis. 1.0 means the texture is stretched across the entire surface. 2.0 means it's repeated, etc. |
name | The name of the geometry. |
KAPI kgeometry geometry_generate_grid | ( | grid_orientation | orientation, |
u32 | segment_count_dim_0, | ||
u32 | segment_count_dim_1, | ||
f32 | segment_size, | ||
b8 | use_third_axis, | ||
kname | name | ||
) |
Create a geometry-based grid using the given parameters. The grid is based on line geometry and has no indices. Note that the vertex array data is dynamically allocated and should be cleaned up using geometry_destroy().
orientation | The orientation of the grid. |
segment_count_dim_0 | The number of segments in the first orientation axis. |
segment_count_dim_1 | The number of segments in the second orientation axis. |
segment_size | The size of each individual segment along all axes. |
use_third_axis | Indicates if the grid should also display on a third axis, orthogonal to the two in the orientation. |
name | The name of the geometry. |
Generates a two-dimensional line of geometry. Note that the memory for the vertex array is dynamically allocated, so this should be cleaned up with geometry_destroy(). Note that index data is not used for this geometry.
point_0 | The first point of the line. |
point_1 | The second point of the line. |
name | The name of the geometry. |
Generates a three-dimensional line of geometry. Note that the memory for the vertex array is dynamically allocated, so this should be cleaned up with geometry_destroy(). Note that index data is not used for this geometry.
point_0 | The first point of the line. |
point_1 | The second point of the line. |
name | The name of the geometry. |
Generates a line-based 3d box based on the provided size.
size | The size (extents) of the box. |
name | The name of the geometry. |
KAPI kgeometry geometry_generate_line_sphere3d | ( | f32 | radius, |
u32 | segment_count, | ||
vec4 | colour, | ||
kname | name | ||
) |
KAPI void geometry_generate_normals | ( | u32 | vertex_count, |
vertex_3d * | vertices, | ||
u32 | index_count, | ||
u32 * | indices | ||
) |
Calculates normals for the given vertex and index data. Modifies vertices in place.
vertex_count | The number of vertices. |
vertices | An array of vertices. |
index_count | The number of indices. |
indices | An array of vertices. |
KAPI kgeometry geometry_generate_plane | ( | f32 | width, |
f32 | height, | ||
u32 | x_segment_count, | ||
u32 | y_segment_count, | ||
f32 | tile_x, | ||
f32 | tile_y, | ||
kname | name | ||
) |
Generates a three-dimensional plane of geometry. Note that memory for the vertex and index arrays are dynamically allocated, so this should be cleaned up with geometry_destroy(). Dimensions account for the x- and y-axes, z is always 0.
width | The width of the plane (x-axis). |
height | The height of the plane (y-axis). |
x_segment_count | The number of segments to split the plane geometry into along the x-axis. Must be at least 1. |
y_segment_count | The number of segments to split the plane geometry into along the y-axis. Must be at least 1. |
tile_x | The amount of tiling of the textures on the face of the plane on the x-axis. 1.0 means the texture is stretched across the entire surface. 2.0 means it's repeated, etc. |
tile_y | The amount of tiling of the textures on the face of the plane on the y-axis. 1.0 means the texture is stretched across the entire surface. 2.0 means it's repeated, etc. |
name | The name of the geometry. |
KAPI kgeometry geometry_generate_quad | ( | f32 | width, |
f32 | height, | ||
f32 | tx_min, | ||
f32 | tx_max, | ||
f32 | ty_min, | ||
f32 | ty_max, | ||
kname | name | ||
) |
Generates a two-dimensional quad (two triangles) of geometry. Note that memory for the vertex and index arrays are dynamically allocated, so this should be cleaned up with geometry_destroy(). Dimensions account for the x- and y-axes only.
width | The width of the plane (x-axis). |
height | The height of the plane (y-axis). |
tx_min | The minimum texture coordinate along the x-axis. |
ty_min | The minimum texture coordinate along the y-axis. |
tx_max | The maximum texture coordinate along the x-axis. |
ty_max | The maximum texture coordinate along the y-axis. |
name | The name of the geometry. |
KAPI void geometry_generate_tangents | ( | u32 | vertex_count, |
vertex_3d * | vertices, | ||
u32 | index_count, | ||
u32 * | indices | ||
) |
Calculates tangents for the given vertex and index data. Modifies vertices in place.
vertex_count | The number of vertices. |
vertices | An array of vertices. |
index_count | The number of indices. |
indices | An array of vertices. |
KAPI void geometry_recalculate_line_box3d_by_extents | ( | kgeometry * | geometry, |
extents_3d | extents | ||
) |
Recalculates the vertices in the given geometry based off the given extents.
geometry | A pointer to the geometry to modify. |
extents | The extents of which to base the modification. |
Recalculates the vertices in the given geometry based off the given points.
geometry | A pointer to the geometry to modify. |
points | The 8 points (i.e. corners of a box) that will be used for the modification. |