2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>,
|
|
|
|
// Copyright (C) 2012-2018 RealBadAngel, Maciej Kasatkin
|
|
|
|
// Copyright (C) 2015-2018 paramat
|
2012-12-29 16:20:09 +01:00
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2012-12-29 16:20:09 +01:00
|
|
|
|
2024-03-12 14:13:24 +01:00
|
|
|
#include <string>
|
|
|
|
#include "irr_v3d.h"
|
|
|
|
#include "nodedef.h"
|
|
|
|
#include "mapnode.h"
|
2012-12-29 16:20:09 +01:00
|
|
|
|
2015-01-05 02:42:27 -05:00
|
|
|
class MMVManip;
|
2018-02-10 22:04:16 +02:00
|
|
|
class NodeDefManager;
|
2020-04-11 19:59:43 +02:00
|
|
|
class ServerMap;
|
2012-12-29 16:20:09 +01:00
|
|
|
|
2013-03-11 21:32:52 -04:00
|
|
|
namespace treegen {
|
2012-12-29 16:20:09 +01:00
|
|
|
|
2014-08-07 15:39:12 +10:00
|
|
|
enum error {
|
|
|
|
SUCCESS,
|
|
|
|
UNBALANCED_BRACKETS
|
|
|
|
};
|
|
|
|
|
2024-03-12 20:10:28 +01:00
|
|
|
struct TreeDef : public NodeResolver {
|
2024-03-17 17:32:35 +01:00
|
|
|
TreeDef() :
|
|
|
|
// Initialize param1 and param2
|
|
|
|
trunknode(CONTENT_IGNORE),
|
|
|
|
leavesnode(CONTENT_IGNORE),
|
|
|
|
leaves2node(CONTENT_IGNORE),
|
|
|
|
fruitnode(CONTENT_IGNORE)
|
|
|
|
{}
|
2024-03-12 20:10:28 +01:00
|
|
|
virtual void resolveNodeNames();
|
|
|
|
|
2013-03-11 21:32:52 -04:00
|
|
|
std::string initial_axiom;
|
|
|
|
std::string rules_a;
|
|
|
|
std::string rules_b;
|
|
|
|
std::string rules_c;
|
|
|
|
std::string rules_d;
|
|
|
|
|
|
|
|
MapNode trunknode;
|
|
|
|
MapNode leavesnode;
|
|
|
|
MapNode leaves2node;
|
|
|
|
|
|
|
|
int leaves2_chance;
|
|
|
|
int angle;
|
|
|
|
int iterations;
|
|
|
|
int iterations_random_level;
|
|
|
|
std::string trunk_type;
|
|
|
|
bool thin_branches;
|
|
|
|
MapNode fruitnode;
|
|
|
|
int fruit_chance;
|
2016-06-04 01:35:37 -04:00
|
|
|
s32 seed;
|
2014-08-07 15:39:12 +10:00
|
|
|
bool explicit_seed;
|
2013-03-11 21:32:52 -04:00
|
|
|
};
|
2012-12-29 16:20:09 +01:00
|
|
|
|
|
|
|
// Add default tree
|
2015-01-05 02:42:27 -05:00
|
|
|
void make_tree(MMVManip &vmanip, v3s16 p0,
|
2018-02-10 22:04:16 +02:00
|
|
|
bool is_apple_tree, const NodeDefManager *ndef, s32 seed);
|
2013-03-11 21:32:52 -04:00
|
|
|
// Add jungle tree
|
2015-03-28 05:14:53 +00:00
|
|
|
void make_jungletree(MMVManip &vmanip, v3s16 p0,
|
2018-02-10 22:04:16 +02:00
|
|
|
const NodeDefManager *ndef, s32 seed);
|
2015-03-28 05:14:53 +00:00
|
|
|
// Add pine tree
|
|
|
|
void make_pine_tree(MMVManip &vmanip, v3s16 p0,
|
2018-02-10 22:04:16 +02:00
|
|
|
const NodeDefManager *ndef, s32 seed);
|
2013-01-23 04:57:49 +01:00
|
|
|
|
2024-03-12 14:13:24 +01:00
|
|
|
// Spawn L-Systems tree on VManip
|
|
|
|
treegen::error make_ltree(MMVManip &vmanip, v3s16 p0, const TreeDef &def);
|
|
|
|
// Helper to spawn it directly on map
|
|
|
|
treegen::error spawn_ltree(ServerMap *map, v3s16 p0, const TreeDef &def);
|
2024-12-08 20:27:22 +01:00
|
|
|
|
|
|
|
// Helper to get a string from the error message
|
|
|
|
std::string error_to_string(error e);
|
2012-12-29 16:20:09 +01:00
|
|
|
}; // namespace treegen
|