11#include "resource/asset/terrain_asset.h"
13namespace Vkm::Engine {
28inline constexpr char MAGIC[4] = {
'V',
'K',
'M',
'T'};
38 std::array<std::string, MaterialAsset::MAX_LAYERS> layers;
40 std::vector<std::vector<std::pair<std::string, std::string>>>
plants;
92bool readBody(
const std::filesystem::path& path, std::vector<uint8_t>& body, std::string& error);
Type-erased resource registry with typed handles and generational lifetimes.
Definition resource_manager.h:46
A terrain as bytes: the .terrain file the editor writes into a project, and the body of its cooked fi...
Definition asset_cook.h:17
constexpr uint32_t MAX_NAME
The longest name a body keeps.
Definition terrain_file.h:34
void resolve(TerrainAsset &terrain, const Names &names, const ResourceManager &resources)
Give terrain the handles names names, from resources; a name it does not hold stays empty,...
bool readBody(const std::filesystem::path &path, std::vector< uint8_t > &body, std::string &error)
The body of the .terrain file at path, its magic and version checked.
std::vector< uint8_t > encode(const TerrainAsset &terrain, const ResourceManager &resources)
terrain's body: its grid, maps and plants, its handles as their assets' names.
constexpr uint32_t VERSION
The body's layout; readBody() refuses a file of another.
Definition terrain_file.h:31
bool decode(const uint8_t *bytes, size_t size, TerrainAsset &out, Names &names, std::string &error)
Read a body back into out, its handles left empty and their names in names.
constexpr char MAGIC[4]
The magic a .terrain file starts with, then VERSION.
Definition terrain_file.h:28
bool write(const std::filesystem::path &path, const TerrainAsset &terrain, const ResourceManager &resources)
Write terrain to path as a .terrain file, through a temporary file.
A terrain: a square grid of heights, the share of each of four materials painted at each grid vertex,...
Definition terrain_asset.h:54
What a body names, in the order resolve() reads it back.
Definition terrain_file.h:37
std::vector< std::vector< std::pair< std::string, std::string > > > plants
Per foliage layer, per part: its mesh's name, then its material's.
Definition terrain_file.h:40