Kohi Game Engine
terrain.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "core/frame_data.h"
4 #include "defines.h"
5 #include "math/math_types.h"
7 
8 /*
9 Need to modify the geometry structure/functions to allow for multiple materials.
10 Write shader to handle 8 material weights/blending
11 Multi-materials (combine maps using uv offsets)?
12 Load terrain configuration from file
13 Load heightmaps
14 calculate normals/tangents (copy-pasta of existing, but using terrain_vertex
15 structure) New material type? (terrain/multi material)
16 */
17 
18 typedef struct terrain_vertex {
29 
33 
34 typedef struct terrain_vertex_data {
37 
38 typedef struct terrain_config {
39  char *name;
42  // How large each tile is on the x axis.
44  // How large each tile is on the z axis.
46  // The max height of the generated terrain.
48 
50 
53 
57 
58 typedef struct terrain {
60  char *name;
64  // How large each tile is on the x axis.
66  // How large each tile is on the z axis.
68  // The max height of the generated terrain.
70 
73 
76 
79 
82 
84 
88 
89 KAPI b8 terrain_create(const terrain_config *config, terrain *out_terrain);
91 
95 
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:177
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
float f32
32-bit floating point number
Definition: defines.h:47
Contains various math types required for the engine.
This file contains the types for common resources the engine uses.
#define TERRAIN_MAX_MATERIAL_COUNT
Definition: resource_types.h:16
Represents the extents of a 3d object.
Definition: math_types.h:165
Represents actual geometry in the world. Typically (but not always, depending on use) paired with a m...
Definition: resource_types.h:311
Definition: terrain.h:38
u32 material_count
Definition: terrain.h:54
transform xform
Definition: terrain.h:49
char * name
Definition: terrain.h:39
u32 vertex_data_length
Definition: terrain.h:51
f32 scale_y
Definition: terrain.h:47
f32 tile_scale_x
Definition: terrain.h:43
char ** material_names
Definition: terrain.h:55
f32 tile_scale_z
Definition: terrain.h:45
u32 tile_count_z
Definition: terrain.h:41
u32 tile_count_x
Definition: terrain.h:40
terrain_vertex_data * vertex_datas
Definition: terrain.h:52
Definition: terrain.h:34
f32 height
Definition: terrain.h:35
Definition: terrain.h:18
vec3 position
The position of the vertex.
Definition: terrain.h:20
vec3 normal
The normal of the vertex.
Definition: terrain.h:22
vec2 texcoord
The texture coordinate of the vertex.
Definition: terrain.h:24
vec4 tangent
The tangent of the vertex.
Definition: terrain.h:28
f32 material_weights[TERRAIN_MAX_MATERIAL_COUNT]
A collection of material weights for this vertex.
Definition: terrain.h:31
vec4 colour
The colour of the vertex.
Definition: terrain.h:26
Definition: terrain.h:58
u32 material_count
Definition: terrain.h:85
transform xform
Definition: terrain.h:61
u32 * indices
Definition: terrain.h:81
geometry geo
Definition: terrain.h:83
u32 unique_id
Definition: terrain.h:59
u32 index_count
Definition: terrain.h:80
char * name
Definition: terrain.h:60
vec3 origin
Definition: terrain.h:75
u32 vertex_data_length
Definition: terrain.h:71
f32 scale_y
Definition: terrain.h:69
terrain_vertex * vertices
Definition: terrain.h:78
u32 vertex_count
Definition: terrain.h:77
f32 tile_scale_x
Definition: terrain.h:65
char ** material_names
Definition: terrain.h:86
f32 tile_scale_z
Definition: terrain.h:67
u32 tile_count_z
Definition: terrain.h:63
u32 tile_count_x
Definition: terrain.h:62
extents_3d extents
Definition: terrain.h:74
terrain_vertex_data * vertex_datas
Definition: terrain.h:72
Represents the transform of an object in the world. Transforms can have a parent whose own transform ...
Definition: math_types.h:215
KAPI b8 terrain_update(terrain *t)
KAPI void terrain_destroy(terrain *t)
struct terrain_vertex terrain_vertex
KAPI b8 terrain_unload(terrain *t)
KAPI b8 terrain_load(terrain *t)
struct terrain terrain
KAPI b8 terrain_create(const terrain_config *config, terrain *out_terrain)
struct terrain_vertex_data terrain_vertex_data
KAPI b8 terrain_initialize(terrain *t)
struct terrain_config terrain_config
A 2-element vector.
Definition: math_types.h:19
A 3-element vector.
Definition: math_types.h:49
A 4-element vector.
Definition: math_types.h:89