]> git.lizzy.rs Git - dragonfireclient.git/blob - src/treegen.h
Pre-select current game in world creation dialog
[dragonfireclient.git] / src / treegen.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>,
4                           2012-2013 RealBadAngel, Maciej Kasatkin <mk@realbadangel.pl>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef TREEGEN_HEADER
21 #define TREEGEN_HEADER
22
23 #include <matrix4.h>
24 #include "noise.h"
25
26 class ManualMapVoxelManipulator;
27 class INodeDefManager;
28
29
30 namespace treegen {
31
32         struct TreeDef {
33                 std::string initial_axiom;
34                 std::string rules_a;
35                 std::string rules_b;
36                 std::string rules_c;
37                 std::string rules_d;
38
39                 MapNode trunknode;
40                 MapNode leavesnode;
41                 MapNode leaves2node;
42
43                 int leaves2_chance;
44                 int angle;
45                 int iterations;
46                 int iterations_random_level;
47                 std::string trunk_type;
48                 bool thin_branches;
49                 MapNode fruitnode;
50                 int fruit_chance;
51                 int seed;
52         };
53
54         // Add default tree
55         void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
56                 bool is_apple_tree, INodeDefManager *ndef, int seed);
57         // Add jungle tree
58         void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
59                 INodeDefManager *ndef, int seed);
60
61         // Add L-Systems tree (used by engine)
62         void make_ltree(ManualMapVoxelManipulator &vmanip, v3s16 p0, INodeDefManager *ndef,
63                 TreeDef tree_definition);
64         // Spawn L-systems tree from LUA
65         void spawn_ltree (ServerEnvironment *env, v3s16 p0, INodeDefManager *ndef,
66                 TreeDef tree_definition);
67
68         // L-System tree gen helper functions
69         void tree_node_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
70                 MapNode node);
71         void tree_trunk_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
72                 TreeDef &tree_definition);
73         void tree_leaves_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
74                 PseudoRandom ps, TreeDef &tree_definition);
75         void tree_single_leaves_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
76                 PseudoRandom ps, TreeDef &tree_definition);
77         void tree_fruit_placement(ManualMapVoxelManipulator &vmanip, v3f p0,
78                 TreeDef &tree_definition);
79         irr::core::matrix4 setRotationAxisRadians(irr::core::matrix4 M, double angle, v3f axis);
80
81         v3f transposeMatrix(irr::core::matrix4 M ,v3f v);
82
83 }; // namespace treegen
84 #endif