add 'lowering' generated structures property
This commit is contained in:
parent
d72f758dc5
commit
4b0b643342
@ -72,17 +72,20 @@ Fragments used by the generator must present in the directory:
|
|||||||
|
|
||||||
## Structures
|
## Structures
|
||||||
|
|
||||||
A structure is a set of rules for inserting a fragment into the world by the generator. It currently has no properties, being created as empty objects in the `generators/generator_name.files/structures.toml` file. Example:
|
A structure is a set of rules for inserting a fragment into the world by the generator. Structures are declared as objects in the file `generators/generator_name.files/structures.toml`. Example:
|
||||||
```toml
|
```toml
|
||||||
tree0 = {}
|
tree0 = {}
|
||||||
tree1 = {}
|
tree1 = {}
|
||||||
tree2 = {}
|
tree2 = {}
|
||||||
tower = {}
|
tower = {lowering=2}
|
||||||
coal_ore0 = {}
|
coal_ore0 = {}
|
||||||
```
|
```
|
||||||
|
|
||||||
Currently, the name of the structure must match the name of the fragment used.
|
Currently, the name of the structure must match the name of the fragment used.
|
||||||
|
|
||||||
|
Available properties:
|
||||||
|
- lowering - depth of structure lowering.
|
||||||
|
|
||||||
## Biomes
|
## Biomes
|
||||||
|
|
||||||
A biome defines what blocks and layers the terrain is generated from, as well as a set of plants and structures.
|
A biome defines what blocks and layers the terrain is generated from, as well as a set of plants and structures.
|
||||||
|
|||||||
@ -72,17 +72,20 @@
|
|||||||
|
|
||||||
## Структуры
|
## Структуры
|
||||||
|
|
||||||
Структура - набор правил по вставке фрагмента в мир генератором. На данный момент не имеет свойств, создаваясь в виде пустых объектов в файле `generators/имя_генератора.files/structures.toml`. Пример:
|
Структура - набор правил по вставке фрагмента в мир генератором. Структуры объявляются в виде объектов в файле `generators/имя_генератора.files/structures.toml`. Пример:
|
||||||
```toml
|
```toml
|
||||||
tree0 = {}
|
tree0 = {}
|
||||||
tree1 = {}
|
tree1 = {}
|
||||||
tree2 = {}
|
tree2 = {}
|
||||||
tower = {}
|
tower = {lowering=-2}
|
||||||
coal_ore0 = {}
|
coal_ore0 = {}
|
||||||
```
|
```
|
||||||
|
|
||||||
На данный момент, имя структуры должно совпадать с именем использованного фрагмента.
|
На данный момент, имя структуры должно совпадать с именем использованного фрагмента.
|
||||||
|
|
||||||
|
Доступные свойства:
|
||||||
|
- lowering - глубина погружения структуры под поверхность.
|
||||||
|
|
||||||
## Биомы
|
## Биомы
|
||||||
|
|
||||||
Биом определяет то, из каких блоков и какими слоями генерируется ландшафт, а так же набор растений, структур.
|
Биом определяет то, из каких блоков и какими слоями генерируется ландшафт, а так же набор растений, структур.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
tree0 = {}
|
tree0 = {}
|
||||||
tree1 = {}
|
tree1 = {}
|
||||||
tree2 = {}
|
tree2 = {}
|
||||||
tower = {}
|
tower = {lowering=2}
|
||||||
coal_ore0 = {}
|
coal_ore0 = {}
|
||||||
|
|||||||
@ -127,7 +127,7 @@ static VoxelStructureMeta load_structure_meta(
|
|||||||
) {
|
) {
|
||||||
VoxelStructureMeta meta;
|
VoxelStructureMeta meta;
|
||||||
meta.name = name;
|
meta.name = name;
|
||||||
|
config.at("lowering").get(meta.lowering);
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,10 @@ class VoxelFragment;
|
|||||||
struct GeneratorDef;
|
struct GeneratorDef;
|
||||||
|
|
||||||
struct VoxelStructureMeta {
|
struct VoxelStructureMeta {
|
||||||
|
/// @brief Structure name
|
||||||
std::string name;
|
std::string name;
|
||||||
|
/// @brief Structure lowering on placement
|
||||||
|
int lowering = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlocksLayer {
|
struct BlocksLayer {
|
||||||
|
|||||||
@ -270,10 +270,11 @@ void WorldGenerator::generateStructures(
|
|||||||
if (height < def.seaLevel) {
|
if (height < def.seaLevel) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto& structure = *def.structures[structureId]->fragments[rotation];
|
auto& structure = *def.structures[structureId];
|
||||||
glm::ivec3 position {x, height, z};
|
auto& fragment = *structure.fragments[rotation];
|
||||||
position.x -= structure.getSize().x / 2;
|
glm::ivec3 position {x, height-structure.meta.lowering, z};
|
||||||
position.z -= structure.getSize().z / 2;
|
position.x -= fragment.getSize().x / 2;
|
||||||
|
position.z -= fragment.getSize().z / 2;
|
||||||
placeStructure(
|
placeStructure(
|
||||||
StructurePlacement {
|
StructurePlacement {
|
||||||
structureId,
|
structureId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user