Techneck/code/source-c/world.h

74 lines
1.8 KiB
C

#ifndef TC_WORLD_H
#define TC_WORLD_H
#include <stdbool.h>
#include <stdint.h>
#include "blocks.h"
#include "utility.h"
typedef struct tc_worldgen tc_worldgen_s;
typedef struct tc_block tc_block_s;
typedef struct tc_chunk tc_chunk_s;
typedef struct tc_world tc_world_s;
struct tc_worldgen
{
char *name;
bool (*fn_generate_chunk) (tc_worldgen_s *gen, tc_chunk_s *chunk);
};
struct tc_block
{
uint32_t type_identifier;
tc_vec3_s position;
tc_vec3_s rotation;
tc_object_s drawing;
};
struct tc_chunk
{
tc_vec3_s position;
uint32_t blocks[32][32][32];
uint32_t num_vertices;
float *vertex_positions;
float *vertex_uvs;
uint32_t vao;
uint32_t vertex_data;
};
struct tc_world
{
uint32_t chunks_capacity;
uint32_t num_chunks;
tc_chunk_s **chunks;
tc_worldgen_s *worldgen;
};
tc_world_s tc_init_worlds ();
void tc_draw_world (tc_world_s *world);
tc_chunk_s * tc_new_chunk (tc_world_s *world, float x, float y, float z); // must be integers
void tc_set_block_in_chunk(
tc_chunk_s *chunk,
uint32_t x, uint32_t y, uint32_t z,
tc_block_s block
);
uint32_t tc_count_chunk_vertices (tc_chunk_s *chunk);
void tc_meshize_chunk (tc_chunk_s *chunk);
bool tc_generate_default_terrain_chunk (tc_worldgen_s *gen, tc_chunk_s *chunk);
#endif